14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
22 typedef BLASLONG blasint;
24 #define blasabs(x) llabs(x)
26 #define blasabs(x) labs(x)
30 #define blasabs(x) abs(x)
33 typedef blasint integer;
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
63 /* Extern is for use with -E */
74 /*external read, write*/
83 /*internal read, write*/
113 /*rewind, backspace, endfile*/
125 ftnint *inex; /*parameters in standard's order*/
151 union Multitype { /* for multiple entry points */
162 typedef union Multitype Multitype;
164 struct Vardesc { /* for Namelist */
170 typedef struct Vardesc Vardesc;
177 typedef struct Namelist Namelist;
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b) ((a) >> (b) & 1)
186 #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle() continue;
256 #define myceiling(w) {ceil(w)}
257 #define myhuge(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
261 /* procedure parameter types for -A and -C++ */
263 #define F2C_proc_par_types 1
265 typedef logical (*L_fp)(...);
267 typedef logical (*L_fp)();
270 static float spow_ui(float x, integer n) {
271 float pow=1.0; unsigned long int u;
273 if(n < 0) n = -n, x = 1/x;
282 static double dpow_ui(double x, integer n) {
283 double pow=1.0; unsigned long int u;
285 if(n < 0) n = -n, x = 1/x;
295 static _Fcomplex cpow_ui(complex x, integer n) {
296 complex pow={1.0,0.0}; unsigned long int u;
298 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
300 if(u & 01) pow.r *= x.r, pow.i *= x.i;
301 if(u >>= 1) x.r *= x.r, x.i *= x.i;
305 _Fcomplex p={pow.r, pow.i};
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310 _Complex float pow=1.0; unsigned long int u;
312 if(n < 0) n = -n, x = 1/x;
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324 _Dcomplex pow={1.0,0.0}; unsigned long int u;
326 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
328 if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329 if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
333 _Dcomplex p = {pow._Val[0], pow._Val[1]};
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338 _Complex double pow=1.0; unsigned long int u;
340 if(n < 0) n = -n, x = 1/x;
350 static integer pow_ii(integer x, integer n) {
351 integer pow; unsigned long int u;
353 if (n == 0 || x == 1) pow = 1;
354 else if (x != -1) pow = x == 0 ? 1/x : 0;
357 if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
369 double m; integer i, mi;
370 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371 if (w[i-1]>m) mi=i ,m=w[i-1];
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
376 float m; integer i, mi;
377 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378 if (w[i-1]>m) mi=i ,m=w[i-1];
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382 integer n = *n_, incx = *incx_, incy = *incy_, i;
384 _Fcomplex zdotc = {0.0, 0.0};
385 if (incx == 1 && incy == 1) {
386 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387 zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388 zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
391 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392 zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393 zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
399 _Complex float zdotc = 0.0;
400 if (incx == 1 && incy == 1) {
401 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402 zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
405 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406 zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413 integer n = *n_, incx = *incx_, incy = *incy_, i;
415 _Dcomplex zdotc = {0.0, 0.0};
416 if (incx == 1 && incy == 1) {
417 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418 zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419 zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
422 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423 zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424 zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
430 _Complex double zdotc = 0.0;
431 if (incx == 1 && incy == 1) {
432 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433 zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
436 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437 zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444 integer n = *n_, incx = *incx_, incy = *incy_, i;
446 _Fcomplex zdotc = {0.0, 0.0};
447 if (incx == 1 && incy == 1) {
448 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449 zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450 zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
453 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454 zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455 zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
461 _Complex float zdotc = 0.0;
462 if (incx == 1 && incy == 1) {
463 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464 zdotc += Cf(&x[i]) * Cf(&y[i]);
467 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468 zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475 integer n = *n_, incx = *incx_, incy = *incy_, i;
477 _Dcomplex zdotc = {0.0, 0.0};
478 if (incx == 1 && incy == 1) {
479 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480 zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481 zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
484 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485 zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486 zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
492 _Complex double zdotc = 0.0;
493 if (incx == 1 && incy == 1) {
494 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495 zdotc += Cd(&x[i]) * Cd(&y[i]);
498 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499 zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
505 /* -- translated by f2c (version 20000121).
506 You must link the resulting object file with the libraries:
507 -lf2c -lm (in that order)
513 /* Table of constant values */
515 static complex c_b1 = {0.f,0.f};
516 static integer c__1 = 1;
517 static integer c__2 = 2;
518 static real c_b28 = 0.f;
520 /* > \brief \b CLARRV computes the eigenvectors of the tridiagonal matrix T = L D LT given L, D and the eigenv
523 /* =========== DOCUMENTATION =========== */
525 /* Online html documentation available at */
526 /* http://www.netlib.org/lapack/explore-html/ */
529 /* > Download CLARRV + dependencies */
530 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clarrv.
533 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clarrv.
536 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clarrv.
544 /* SUBROUTINE CLARRV( N, VL, VU, D, L, PIVMIN, */
545 /* ISPLIT, M, DOL, DOU, MINRGP, */
546 /* RTOL1, RTOL2, W, WERR, WGAP, */
547 /* IBLOCK, INDEXW, GERS, Z, LDZ, ISUPPZ, */
548 /* WORK, IWORK, INFO ) */
550 /* INTEGER DOL, DOU, INFO, LDZ, M, N */
551 /* REAL MINRGP, PIVMIN, RTOL1, RTOL2, VL, VU */
552 /* INTEGER IBLOCK( * ), INDEXW( * ), ISPLIT( * ), */
553 /* $ ISUPPZ( * ), IWORK( * ) */
554 /* REAL D( * ), GERS( * ), L( * ), W( * ), WERR( * ), */
555 /* $ WGAP( * ), WORK( * ) */
556 /* COMPLEX Z( LDZ, * ) */
559 /* > \par Purpose: */
564 /* > CLARRV computes the eigenvectors of the tridiagonal matrix */
565 /* > T = L D L**T given L, D and APPROXIMATIONS to the eigenvalues of L D L**T. */
566 /* > The input eigenvalues should have been computed by SLARRE. */
575 /* > The order of the matrix. N >= 0. */
578 /* > \param[in] VL */
581 /* > Lower bound of the interval that contains the desired */
582 /* > eigenvalues. VL < VU. Needed to compute gaps on the left or right */
583 /* > end of the extremal eigenvalues in the desired RANGE. */
586 /* > \param[in] VU */
589 /* > Upper bound of the interval that contains the desired */
590 /* > eigenvalues. VL < VU. Needed to compute gaps on the left or right */
591 /* > end of the extremal eigenvalues in the desired RANGE. */
594 /* > \param[in,out] D */
596 /* > D is REAL array, dimension (N) */
597 /* > On entry, the N diagonal elements of the diagonal matrix D. */
598 /* > On exit, D may be overwritten. */
601 /* > \param[in,out] L */
603 /* > L is REAL array, dimension (N) */
604 /* > On entry, the (N-1) subdiagonal elements of the unit */
605 /* > bidiagonal matrix L are in elements 1 to N-1 of L */
606 /* > (if the matrix is not split.) At the end of each block */
607 /* > is stored the corresponding shift as given by SLARRE. */
608 /* > On exit, L is overwritten. */
611 /* > \param[in] PIVMIN */
613 /* > PIVMIN is REAL */
614 /* > The minimum pivot allowed in the Sturm sequence. */
617 /* > \param[in] ISPLIT */
619 /* > ISPLIT is INTEGER array, dimension (N) */
620 /* > The splitting points, at which T breaks up into blocks. */
621 /* > The first block consists of rows/columns 1 to */
622 /* > ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1 */
623 /* > through ISPLIT( 2 ), etc. */
629 /* > The total number of input eigenvalues. 0 <= M <= N. */
632 /* > \param[in] DOL */
634 /* > DOL is INTEGER */
637 /* > \param[in] DOU */
639 /* > DOU is INTEGER */
640 /* > If the user wants to compute only selected eigenvectors from all */
641 /* > the eigenvalues supplied, he can specify an index range DOL:DOU. */
642 /* > Or else the setting DOL=1, DOU=M should be applied. */
643 /* > Note that DOL and DOU refer to the order in which the eigenvalues */
644 /* > are stored in W. */
645 /* > If the user wants to compute only selected eigenpairs, then */
646 /* > the columns DOL-1 to DOU+1 of the eigenvector space Z contain the */
647 /* > computed eigenvectors. All other columns of Z are set to zero. */
650 /* > \param[in] MINRGP */
652 /* > MINRGP is REAL */
655 /* > \param[in] RTOL1 */
657 /* > RTOL1 is REAL */
660 /* > \param[in] RTOL2 */
662 /* > RTOL2 is REAL */
663 /* > Parameters for bisection. */
664 /* > An interval [LEFT,RIGHT] has converged if */
665 /* > RIGHT-LEFT < MAX( RTOL1*GAP, RTOL2*MAX(|LEFT|,|RIGHT|) ) */
668 /* > \param[in,out] W */
670 /* > W is REAL array, dimension (N) */
671 /* > The first M elements of W contain the APPROXIMATE eigenvalues for */
672 /* > which eigenvectors are to be computed. The eigenvalues */
673 /* > should be grouped by split-off block and ordered from */
674 /* > smallest to largest within the block ( The output array */
675 /* > W from SLARRE is expected here ). Furthermore, they are with */
676 /* > respect to the shift of the corresponding root representation */
677 /* > for their block. On exit, W holds the eigenvalues of the */
678 /* > UNshifted matrix. */
681 /* > \param[in,out] WERR */
683 /* > WERR is REAL array, dimension (N) */
684 /* > The first M elements contain the semiwidth of the uncertainty */
685 /* > interval of the corresponding eigenvalue in W */
688 /* > \param[in,out] WGAP */
690 /* > WGAP is REAL array, dimension (N) */
691 /* > The separation from the right neighbor eigenvalue in W. */
694 /* > \param[in] IBLOCK */
696 /* > IBLOCK is INTEGER array, dimension (N) */
697 /* > The indices of the blocks (submatrices) associated with the */
698 /* > corresponding eigenvalues in W; IBLOCK(i)=1 if eigenvalue */
699 /* > W(i) belongs to the first block from the top, =2 if W(i) */
700 /* > belongs to the second block, etc. */
703 /* > \param[in] INDEXW */
705 /* > INDEXW is INTEGER array, dimension (N) */
706 /* > The indices of the eigenvalues within each block (submatrix); */
707 /* > for example, INDEXW(i)= 10 and IBLOCK(i)=2 imply that the */
708 /* > i-th eigenvalue W(i) is the 10-th eigenvalue in the second block. */
711 /* > \param[in] GERS */
713 /* > GERS is REAL array, dimension (2*N) */
714 /* > The N Gerschgorin intervals (the i-th Gerschgorin interval */
715 /* > is (GERS(2*i-1), GERS(2*i)). The Gerschgorin intervals should */
716 /* > be computed from the original UNshifted matrix. */
719 /* > \param[out] Z */
721 /* > Z is COMPLEX array, dimension (LDZ, f2cmax(1,M) ) */
722 /* > If INFO = 0, the first M columns of Z contain the */
723 /* > orthonormal eigenvectors of the matrix T */
724 /* > corresponding to the input eigenvalues, with the i-th */
725 /* > column of Z holding the eigenvector associated with W(i). */
726 /* > Note: the user must ensure that at least f2cmax(1,M) columns are */
727 /* > supplied in the array Z. */
730 /* > \param[in] LDZ */
732 /* > LDZ is INTEGER */
733 /* > The leading dimension of the array Z. LDZ >= 1, and if */
734 /* > JOBZ = 'V', LDZ >= f2cmax(1,N). */
737 /* > \param[out] ISUPPZ */
739 /* > ISUPPZ is INTEGER array, dimension ( 2*f2cmax(1,M) ) */
740 /* > The support of the eigenvectors in Z, i.e., the indices */
741 /* > indicating the nonzero elements in Z. The I-th eigenvector */
742 /* > is nonzero only in elements ISUPPZ( 2*I-1 ) through */
743 /* > ISUPPZ( 2*I ). */
746 /* > \param[out] WORK */
748 /* > WORK is REAL array, dimension (12*N) */
751 /* > \param[out] IWORK */
753 /* > IWORK is INTEGER array, dimension (7*N) */
756 /* > \param[out] INFO */
758 /* > INFO is INTEGER */
759 /* > = 0: successful exit */
761 /* > > 0: A problem occurred in CLARRV. */
762 /* > < 0: One of the called subroutines signaled an internal problem. */
763 /* > Needs inspection of the corresponding parameter IINFO */
764 /* > for further information. */
766 /* > =-1: Problem in SLARRB when refining a child's eigenvalues. */
767 /* > =-2: Problem in SLARRF when computing the RRR of a child. */
768 /* > When a child is inside a tight cluster, it can be difficult */
769 /* > to find an RRR. A partial remedy from the user's point of */
770 /* > view is to make the parameter MINRGP smaller and recompile. */
771 /* > However, as the orthogonality of the computed vectors is */
772 /* > proportional to 1/MINRGP, the user should be aware that */
773 /* > he might be trading in precision when he decreases MINRGP. */
774 /* > =-3: Problem in SLARRB when refining a single eigenvalue */
775 /* > after the Rayleigh correction was rejected. */
776 /* > = 5: The Rayleigh Quotient Iteration failed to converge to */
777 /* > full accuracy in MAXITR steps. */
783 /* > \author Univ. of Tennessee */
784 /* > \author Univ. of California Berkeley */
785 /* > \author Univ. of Colorado Denver */
786 /* > \author NAG Ltd. */
788 /* > \date June 2016 */
790 /* > \ingroup complexOTHERauxiliary */
792 /* > \par Contributors: */
793 /* ================== */
795 /* > Beresford Parlett, University of California, Berkeley, USA \n */
796 /* > Jim Demmel, University of California, Berkeley, USA \n */
797 /* > Inderjit Dhillon, University of Texas, Austin, USA \n */
798 /* > Osni Marques, LBNL/NERSC, USA \n */
799 /* > Christof Voemel, University of California, Berkeley, USA */
801 /* ===================================================================== */
802 /* Subroutine */ int clarrv_(integer *n, real *vl, real *vu, real *d__, real *
803 l, real *pivmin, integer *isplit, integer *m, integer *dol, integer *
804 dou, real *minrgp, real *rtol1, real *rtol2, real *w, real *werr,
805 real *wgap, integer *iblock, integer *indexw, real *gers, complex *
806 z__, integer *ldz, integer *isuppz, real *work, integer *iwork,
809 /* System generated locals */
810 integer z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5, i__6;
815 /* Local variables */
822 integer minwsize, itmp1, i__, j, k, p, q, indld;
826 integer iinfo, iindr;
830 integer nclus, zfrom;
831 extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *,
834 integer iindc1, iindc2, indin1, indin2;
835 extern /* Subroutine */ int clar1v_(integer *, integer *, integer *, real
836 *, real *, real *, real *, real *, real *, real *, complex *,
837 logical *, integer *, real *, real *, integer *, integer *, real *
838 , real *, real *, real *);
846 integer ibegin, indeig;
850 extern real slamch_(char *);
851 integer oldien, oldncl, wbegin, negcnt;
857 extern /* Subroutine */ int claset_(char *, integer *, integer *, complex
858 *, complex *, complex *, integer *);
860 integer iindwk, offset;
862 extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer
864 integer newcls, oldfst, indwrk, windex, oldlst;
866 integer newfst, newftt, parity, windmn, windpl, isupmn, newlst, zusedl;
868 integer newsiz, zusedu, zusedw;
872 extern /* Subroutine */ int slarrb_(integer *, real *, real *, integer *,
873 integer *, real *, real *, integer *, real *, real *, real *,
874 real *, integer *, real *, real *, integer *, integer *), slarrf_(
875 integer *, real *, real *, real *, integer *, integer *, real *,
876 real *, real *, real *, real *, real *, real *, real *, real *,
877 real *, real *, integer *);
878 real gap, eps, tau, tol, tmp;
883 /* -- LAPACK auxiliary routine (version 3.7.1) -- */
884 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
885 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
889 /* ===================================================================== */
891 /* Parameter adjustments */
902 z_offset = 1 + z_dim1 * 1;
911 /* Quick return if possible */
913 if (*n <= 0 || *m <= 0) {
917 /* The first N entries of WORK are reserved for the eigenvalues */
919 indlld = (*n << 1) + 1;
921 indin2 = (*n << 2) + 1;
925 for (i__ = 1; i__ <= i__1; ++i__) {
929 /* IWORK(IINDR+1:IINDR+N) hold the twist indices R for the */
930 /* factorization used to compute the FP vector */
932 /* IWORK(IINDC1+1:IINC2+N) are used to store the clusters of the current */
933 /* layer and the one above. */
939 for (i__ = 1; i__ <= i__1; ++i__) {
945 /* Set lower bound for use of Z */
950 /* Set lower bound for use of Z */
953 /* The width of the part of Z that is used */
954 zusedw = zusedu - zusedl + 1;
955 claset_("Full", n, &zusedw, &c_b1, &c_b1, &z__[zusedl * z_dim1 + 1], ldz);
956 eps = slamch_("Precision");
959 /* Set expert flags for standard code. */
961 if (*dol == 1 && *dou == *m) {
963 /* Only selected eigenpairs are computed. Since the other evalues */
964 /* are not refined by RQ iteration, bisection has to compute to full */
969 /* The entries WBEGIN:WEND in W, WERR, WGAP correspond to the */
970 /* desired eigenvalues. The support of the nonzero eigenvector */
971 /* entries is contained in the interval IBEGIN:IEND. */
972 /* Remark that if k eigenpairs are desired, then the eigenvectors */
973 /* are stored in k contiguous columns of Z. */
974 /* DONE is the number of eigenvectors already computed */
979 for (jblk = 1; jblk <= i__1; ++jblk) {
982 /* Find the eigenvectors of the submatrix indexed IBEGIN */
987 if (iblock[wend + 1] == jblk) {
995 } else if (wend < *dol || wbegin > *dou) {
1000 /* Find local spectral diameter of the block */
1001 gl = gers[(ibegin << 1) - 1];
1002 gu = gers[ibegin * 2];
1004 for (i__ = ibegin + 1; i__ <= i__2; ++i__) {
1006 r__1 = gers[(i__ << 1) - 1];
1007 gl = f2cmin(r__1,gl);
1009 r__1 = gers[i__ * 2];
1010 gu = f2cmax(r__1,gu);
1014 /* OLDIEN is the last index of the previous block */
1015 oldien = ibegin - 1;
1016 /* Calculate the size of the current block */
1017 in = iend - ibegin + 1;
1018 /* The number of eigenvalues in the current block */
1019 im = wend - wbegin + 1;
1020 /* This is for a 1x1 block */
1021 if (ibegin == iend) {
1023 i__2 = ibegin + wbegin * z_dim1;
1024 z__[i__2].r = 1.f, z__[i__2].i = 0.f;
1025 isuppz[(wbegin << 1) - 1] = ibegin;
1026 isuppz[wbegin * 2] = ibegin;
1028 work[wbegin] = w[wbegin];
1033 /* The desired (shifted) eigenvalues are stored in W(WBEGIN:WEND) */
1034 /* Note that these can be approximations, in this case, the corresp. */
1035 /* entries of WERR give the size of the uncertainty interval. */
1036 /* The eigenvalue approximations will be refined when necessary as */
1037 /* high relative accuracy is required for the computation of the */
1038 /* corresponding eigenvectors. */
1039 scopy_(&im, &w[wbegin], &c__1, &work[wbegin], &c__1);
1040 /* We store in W the eigenvalue approximations w.r.t. the original */
1043 for (i__ = 1; i__ <= i__2; ++i__) {
1044 w[wbegin + i__ - 1] += sigma;
1047 /* NDEPTH is the current depth of the representation tree */
1049 /* PARITY is either 1 or 0 */
1051 /* NCLUS is the number of clusters for the next level of the */
1052 /* representation tree, we start with NCLUS = 1 for the root */
1054 iwork[iindc1 + 1] = 1;
1055 iwork[iindc1 + 2] = im;
1056 /* IDONE is the number of eigenvectors already computed in the current */
1059 /* loop while( IDONE.LT.IM ) */
1060 /* generate the representation tree for the current block and */
1061 /* compute the eigenvectors */
1064 /* This is a crude protection against infinitely deep trees */
1069 /* breadth first processing of the current level of the representation */
1070 /* tree: OLDNCL = number of clusters on current level */
1072 /* reset NCLUS to count the number of child clusters */
1075 parity = 1 - parity;
1083 /* Process the clusters on the current level */
1085 for (i__ = 1; i__ <= i__2; ++i__) {
1086 j = oldcls + (i__ << 1);
1087 /* OLDFST, OLDLST = first, last index of current cluster. */
1088 /* cluster indices start with 1 and are relative */
1089 /* to WBEGIN when accessing W, WGAP, WERR, Z */
1090 oldfst = iwork[j - 1];
1093 /* Retrieve relatively robust representation (RRR) of cluster */
1094 /* that has been computed at the previous level */
1095 /* The RRR is stored in Z and overwritten once the eigenvectors */
1096 /* have been computed or when the cluster is refined */
1097 if (*dol == 1 && *dou == *m) {
1098 /* Get representation from location of the leftmost evalue */
1099 /* of the cluster */
1100 j = wbegin + oldfst - 1;
1102 if (wbegin + oldfst - 1 < *dol) {
1103 /* Get representation from the left end of Z array */
1105 } else if (wbegin + oldfst - 1 > *dou) {
1106 /* Get representation from the right end of Z array */
1109 j = wbegin + oldfst - 1;
1113 for (k = 1; k <= i__3; ++k) {
1114 i__4 = ibegin + k - 1 + j * z_dim1;
1115 d__[ibegin + k - 1] = z__[i__4].r;
1116 i__4 = ibegin + k - 1 + (j + 1) * z_dim1;
1117 l[ibegin + k - 1] = z__[i__4].r;
1120 i__3 = iend + j * z_dim1;
1121 d__[iend] = z__[i__3].r;
1122 i__3 = iend + (j + 1) * z_dim1;
1123 sigma = z__[i__3].r;
1124 /* Set the corresponding entries in Z to zero */
1125 claset_("Full", &in, &c__2, &c_b1, &c_b1, &z__[ibegin + j
1128 /* Compute DL and DLL of current RRR */
1130 for (j = ibegin; j <= i__3; ++j) {
1131 tmp = d__[j] * l[j];
1132 work[indld - 1 + j] = tmp;
1133 work[indlld - 1 + j] = tmp * l[j];
1137 /* P and Q are index of the first and last eigenvalue to compute */
1138 /* within the current block */
1139 p = indexw[wbegin - 1 + oldfst];
1140 q = indexw[wbegin - 1 + oldlst];
1141 /* Offset for the arrays WORK, WGAP and WERR, i.e., the P-OFFSET */
1142 /* through the Q-OFFSET elements of these arrays are to be used. */
1143 /* OFFSET = P-OLDFST */
1144 offset = indexw[wbegin] - 1;
1145 /* perform limited bisection (if necessary) to get approximate */
1146 /* eigenvalues to the precision needed. */
1147 slarrb_(&in, &d__[ibegin], &work[indlld + ibegin - 1], &p,
1148 &q, rtol1, rtol2, &offset, &work[wbegin], &wgap[
1149 wbegin], &werr[wbegin], &work[indwrk], &iwork[
1150 iindwk], pivmin, &spdiam, &in, &iinfo);
1155 /* We also recompute the extremal gaps. W holds all eigenvalues */
1156 /* of the unshifted matrix and must be used for computation */
1157 /* of WGAP, the entries of WORK might stem from RRRs with */
1158 /* different shifts. The gaps from WBEGIN-1+OLDFST to */
1159 /* WBEGIN-1+OLDLST are correctly computed in SLARRB. */
1160 /* However, we only allow the gaps to become greater since */
1161 /* this is what should happen when we decrease WERR */
1164 r__1 = wgap[wbegin + oldfst - 2], r__2 = w[wbegin +
1165 oldfst - 1] - werr[wbegin + oldfst - 1] - w[
1166 wbegin + oldfst - 2] - werr[wbegin + oldfst -
1168 wgap[wbegin + oldfst - 2] = f2cmax(r__1,r__2);
1170 if (wbegin + oldlst - 1 < wend) {
1172 r__1 = wgap[wbegin + oldlst - 1], r__2 = w[wbegin +
1173 oldlst] - werr[wbegin + oldlst] - w[wbegin +
1174 oldlst - 1] - werr[wbegin + oldlst - 1];
1175 wgap[wbegin + oldlst - 1] = f2cmax(r__1,r__2);
1177 /* Each time the eigenvalues in WORK get refined, we store */
1178 /* the newly found approximation with all shifts applied in W */
1180 for (j = oldfst; j <= i__3; ++j) {
1181 w[wbegin + j - 1] = work[wbegin + j - 1] + sigma;
1185 /* Process the current node. */
1188 for (j = oldfst; j <= i__3; ++j) {
1190 /* we are at the right end of the cluster, this is also the */
1191 /* boundary of the child cluster */
1193 } else if (wgap[wbegin + j - 1] >= *minrgp * (r__1 = work[
1194 wbegin + j - 1], abs(r__1))) {
1195 /* the right relative gap is big enough, the child cluster */
1196 /* (NEWFST,..,NEWLST) is well separated from the following */
1199 /* inside a child cluster, the relative gap is not */
1203 /* Compute size of child cluster found */
1204 newsiz = newlst - newfst + 1;
1205 /* NEWFTT is the place in Z where the new RRR or the computed */
1206 /* eigenvector is to be stored */
1207 if (*dol == 1 && *dou == *m) {
1208 /* Store representation at location of the leftmost evalue */
1209 /* of the cluster */
1210 newftt = wbegin + newfst - 1;
1212 if (wbegin + newfst - 1 < *dol) {
1213 /* Store representation at the left end of Z array */
1215 } else if (wbegin + newfst - 1 > *dou) {
1216 /* Store representation at the right end of Z array */
1219 newftt = wbegin + newfst - 1;
1224 /* Current child is not a singleton but a cluster. */
1225 /* Compute and store new representation of child. */
1228 /* Compute left and right cluster gap. */
1230 /* LGAP and RGAP are not computed from WORK because */
1231 /* the eigenvalue approximations may stem from RRRs */
1232 /* different shifts. However, W hold all eigenvalues */
1233 /* of the unshifted matrix. Still, the entries in WGAP */
1234 /* have to be computed from WORK since the entries */
1235 /* in W might be of the same order so that gaps are not */
1236 /* exhibited correctly for very close eigenvalues. */
1239 r__1 = 0.f, r__2 = w[wbegin] - werr[wbegin] - *vl;
1240 lgap = f2cmax(r__1,r__2);
1242 lgap = wgap[wbegin + newfst - 2];
1244 rgap = wgap[wbegin + newlst - 1];
1246 /* Compute left- and rightmost eigenvalue of child */
1247 /* to high precision in order to shift as close */
1248 /* as possible and obtain as large relative gaps */
1251 for (k = 1; k <= 2; ++k) {
1253 p = indexw[wbegin - 1 + newfst];
1255 p = indexw[wbegin - 1 + newlst];
1257 offset = indexw[wbegin] - 1;
1258 slarrb_(&in, &d__[ibegin], &work[indlld + ibegin
1259 - 1], &p, &p, &rqtol, &rqtol, &offset, &
1260 work[wbegin], &wgap[wbegin], &werr[wbegin]
1261 , &work[indwrk], &iwork[iindwk], pivmin, &
1262 spdiam, &in, &iinfo);
1266 if (wbegin + newlst - 1 < *dol || wbegin + newfst - 1
1268 /* if the cluster contains no desired eigenvalues */
1269 /* skip the computation of that branch of the rep. tree */
1271 /* We could skip before the refinement of the extremal */
1272 /* eigenvalues of the child, but then the representation */
1273 /* tree could be different from the one when nothing is */
1274 /* skipped. For this reason we skip at this place. */
1275 idone = idone + newlst - newfst + 1;
1279 /* Compute RRR of child cluster. */
1280 /* Note that the new RRR is stored in Z */
1282 /* SLARRF needs LWORK = 2*N */
1283 slarrf_(&in, &d__[ibegin], &l[ibegin], &work[indld +
1284 ibegin - 1], &newfst, &newlst, &work[wbegin],
1285 &wgap[wbegin], &werr[wbegin], &spdiam, &lgap,
1286 &rgap, pivmin, &tau, &work[indin1], &work[
1287 indin2], &work[indwrk], &iinfo);
1288 /* In the complex case, SLARRF cannot write */
1289 /* the new RRR directly into Z and needs an intermediate */
1292 for (k = 1; k <= i__4; ++k) {
1293 i__5 = ibegin + k - 1 + newftt * z_dim1;
1294 i__6 = indin1 + k - 1;
1295 q__1.r = work[i__6], q__1.i = 0.f;
1296 z__[i__5].r = q__1.r, z__[i__5].i = q__1.i;
1297 i__5 = ibegin + k - 1 + (newftt + 1) * z_dim1;
1298 i__6 = indin2 + k - 1;
1299 q__1.r = work[i__6], q__1.i = 0.f;
1300 z__[i__5].r = q__1.r, z__[i__5].i = q__1.i;
1303 i__4 = iend + newftt * z_dim1;
1304 i__5 = indin1 + in - 1;
1305 q__1.r = work[i__5], q__1.i = 0.f;
1306 z__[i__4].r = q__1.r, z__[i__4].i = q__1.i;
1308 /* a new RRR for the cluster was found by SLARRF */
1309 /* update shift and store it */
1310 ssigma = sigma + tau;
1311 i__4 = iend + (newftt + 1) * z_dim1;
1312 q__1.r = ssigma, q__1.i = 0.f;
1313 z__[i__4].r = q__1.r, z__[i__4].i = q__1.i;
1314 /* WORK() are the midpoints and WERR() the semi-width */
1315 /* Note that the entries in W are unchanged. */
1317 for (k = newfst; k <= i__4; ++k) {
1318 fudge = eps * 3.f * (r__1 = work[wbegin + k -
1320 work[wbegin + k - 1] -= tau;
1321 fudge += eps * 4.f * (r__1 = work[wbegin + k
1324 werr[wbegin + k - 1] += fudge;
1325 /* Gaps are not fudged. Provided that WERR is small */
1326 /* when eigenvalues are close, a zero gap indicates */
1327 /* that a new representation is needed for resolving */
1328 /* the cluster. A fudge could lead to a wrong decision */
1329 /* of judging eigenvalues 'separated' which in */
1330 /* reality are not. This could have a negative impact */
1331 /* on the orthogonality of the computed eigenvectors. */
1335 k = newcls + (nclus << 1);
1336 iwork[k - 1] = newfst;
1344 /* Compute eigenvector of singleton */
1348 tol = log((real) in) * 4.f * eps;
1351 windex = wbegin + k - 1;
1354 windmn = f2cmax(i__4,1);
1357 windpl = f2cmin(i__4,*m);
1358 lambda = work[windex];
1360 /* Check if eigenvector computation is to be skipped */
1361 if (windex < *dol || windex > *dou) {
1367 left = work[windex] - werr[windex];
1368 right = work[windex] + werr[windex];
1369 indeig = indexw[windex];
1370 /* Note that since we compute the eigenpairs for a child, */
1371 /* all eigenvalue approximations are w.r.t the same shift. */
1372 /* In this case, the entries in WORK should be used for */
1373 /* computing the gaps since they exhibit even very small */
1374 /* differences in the eigenvalues, as opposed to the */
1375 /* entries in W which might "look" the same. */
1377 /* In the case RANGE='I' and with not much initial */
1378 /* accuracy in LAMBDA and VL, the formula */
1379 /* LGAP = MAX( ZERO, (SIGMA - VL) + LAMBDA ) */
1380 /* can lead to an overestimation of the left gap and */
1381 /* thus to inadequately early RQI 'convergence'. */
1382 /* Prevent this by forcing a small left gap. */
1384 r__1 = abs(left), r__2 = abs(right);
1385 lgap = eps * f2cmax(r__1,r__2);
1387 lgap = wgap[windmn];
1390 /* In the case RANGE='I' and with not much initial */
1391 /* accuracy in LAMBDA and VU, the formula */
1392 /* can lead to an overestimation of the right gap and */
1393 /* thus to inadequately early RQI 'convergence'. */
1394 /* Prevent this by forcing a small right gap. */
1396 r__1 = abs(left), r__2 = abs(right);
1397 rgap = eps * f2cmax(r__1,r__2);
1399 rgap = wgap[windex];
1401 gap = f2cmin(lgap,rgap);
1402 if (k == 1 || k == im) {
1403 /* The eigenvector support can become wrong */
1404 /* because significant entries could be cut off due to a */
1405 /* large GAPTOL parameter in LAR1V. Prevent this. */
1412 /* Update WGAP so that it holds the minimum gap */
1413 /* to the left or the right. This is crucial in the */
1414 /* case where bisection is used to ensure that the */
1415 /* eigenvalue is refined up to the required precision. */
1416 /* The correct value is restored afterwards. */
1417 savgap = wgap[windex];
1419 /* We want to use the Rayleigh Quotient Correction */
1420 /* as often as possible since it converges quadratically */
1421 /* when we are close enough to the desired eigenvalue. */
1422 /* However, the Rayleigh Quotient can have the wrong sign */
1423 /* and lead us away from the desired eigenvalue. In this */
1424 /* case, the best we can do is to use bisection. */
1427 /* Bisection is initially turned off unless it is forced */
1430 /* Check if bisection should be used to refine eigenvalue */
1432 /* Take the bisection as new iterate */
1434 itmp1 = iwork[iindr + windex];
1435 offset = indexw[wbegin] - 1;
1437 slarrb_(&in, &d__[ibegin], &work[indlld + ibegin
1438 - 1], &indeig, &indeig, &c_b28, &r__1, &
1439 offset, &work[wbegin], &wgap[wbegin], &
1440 werr[wbegin], &work[indwrk], &iwork[
1441 iindwk], pivmin, &spdiam, &itmp1, &iinfo);
1446 lambda = work[windex];
1447 /* Reset twist index from inaccurate LAMBDA to */
1448 /* force computation of true MINGMA */
1449 iwork[iindr + windex] = 0;
1451 /* Given LAMBDA, compute the eigenvector. */
1453 clar1v_(&in, &c__1, &in, &lambda, &d__[ibegin], &l[
1454 ibegin], &work[indld + ibegin - 1], &work[
1455 indlld + ibegin - 1], pivmin, &gaptol, &z__[
1456 ibegin + windex * z_dim1], &L__1, &negcnt, &
1457 ztz, &mingma, &iwork[iindr + windex], &isuppz[
1458 (windex << 1) - 1], &nrminv, &resid, &rqcorr,
1463 } else if (resid < bstres) {
1468 i__4 = isupmn, i__5 = isuppz[(windex << 1) - 1];
1469 isupmn = f2cmin(i__4,i__5);
1471 i__4 = isupmx, i__5 = isuppz[windex * 2];
1472 isupmx = f2cmax(i__4,i__5);
1474 /* sin alpha <= |resid|/gap */
1475 /* Note that both the residual and the gap are */
1476 /* proportional to the matrix, so ||T|| doesn't play */
1477 /* a role in the quotient */
1479 /* Convergence test for Rayleigh-Quotient iteration */
1480 /* (omitted when Bisection has been used) */
1482 if (resid > tol * gap && abs(rqcorr) > rqtol * abs(
1483 lambda) && ! usedbs) {
1484 /* We need to check that the RQCORR update doesn't */
1485 /* move the eigenvalue away from the desired one and */
1486 /* towards a neighbor. -> protection with bisection */
1487 if (indeig <= negcnt) {
1488 /* The wanted eigenvalue lies to the left */
1491 /* The wanted eigenvalue lies to the right */
1494 /* We only use the RQCORR if it improves the */
1495 /* the iterate reasonably. */
1496 if (rqcorr * sgndef >= 0.f && lambda + rqcorr <=
1497 right && lambda + rqcorr >= left) {
1499 /* Store new midpoint of bisection interval in WORK */
1500 if (sgndef == 1.f) {
1501 /* The current LAMBDA is on the left of the true */
1504 /* We prefer to assume that the error estimate */
1505 /* is correct. We could make the interval not */
1506 /* as a bracket but to be modified if the RQCORR */
1507 /* chooses to. In this case, the RIGHT side should */
1508 /* be modified as follows: */
1509 /* RIGHT = MAX(RIGHT, LAMBDA + RQCORR) */
1511 /* The current LAMBDA is on the right of the true */
1514 /* See comment about assuming the error estimate is */
1515 /* correct above. */
1516 /* LEFT = MIN(LEFT, LAMBDA + RQCORR) */
1518 work[windex] = (right + left) * .5f;
1519 /* Take RQCORR since it has the correct sign and */
1520 /* improves the iterate reasonably */
1522 /* Update width of error interval */
1523 werr[windex] = (right - left) * .5f;
1527 if (right - left < rqtol * abs(lambda)) {
1528 /* The eigenvalue is computed to bisection accuracy */
1529 /* compute eigenvector and stop */
1532 } else if (iter < 10) {
1534 } else if (iter == 10) {
1543 if (usedrq && usedbs && bstres <= resid) {
1548 /* improve error angle by second step */
1550 clar1v_(&in, &c__1, &in, &lambda, &d__[ibegin]
1551 , &l[ibegin], &work[indld + ibegin -
1552 1], &work[indlld + ibegin - 1],
1553 pivmin, &gaptol, &z__[ibegin + windex
1554 * z_dim1], &L__1, &negcnt, &ztz, &
1555 mingma, &iwork[iindr + windex], &
1556 isuppz[(windex << 1) - 1], &nrminv, &
1557 resid, &rqcorr, &work[indwrk]);
1559 work[windex] = lambda;
1562 /* Compute FP-vector support w.r.t. whole matrix */
1564 isuppz[(windex << 1) - 1] += oldien;
1565 isuppz[windex * 2] += oldien;
1566 zfrom = isuppz[(windex << 1) - 1];
1567 zto = isuppz[windex * 2];
1570 /* Ensure vector is ok if support in the RQI has changed */
1571 if (isupmn < zfrom) {
1573 for (ii = isupmn; ii <= i__4; ++ii) {
1574 i__5 = ii + windex * z_dim1;
1575 z__[i__5].r = 0.f, z__[i__5].i = 0.f;
1581 for (ii = zto + 1; ii <= i__4; ++ii) {
1582 i__5 = ii + windex * z_dim1;
1583 z__[i__5].r = 0.f, z__[i__5].i = 0.f;
1587 i__4 = zto - zfrom + 1;
1588 csscal_(&i__4, &nrminv, &z__[zfrom + windex * z_dim1],
1592 w[windex] = lambda + sigma;
1593 /* Recompute the gaps on the left and right */
1594 /* But only allow them to become larger and not */
1595 /* smaller (which can only happen through "bad" */
1596 /* cancellation and doesn't reflect the theory */
1597 /* where the initial gaps are underestimated due */
1598 /* to WERR being too crude.) */
1602 r__1 = wgap[windmn], r__2 = w[windex] - werr[
1603 windex] - w[windmn] - werr[windmn];
1604 wgap[windmn] = f2cmax(r__1,r__2);
1606 if (windex < wend) {
1608 r__1 = savgap, r__2 = w[windpl] - werr[windpl]
1609 - w[windex] - werr[windex];
1610 wgap[windex] = f2cmax(r__1,r__2);
1615 /* here ends the code for the current child */
1618 /* Proceed to any remaining child nodes */