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 doublereal c_b5 = 0.;
516 static integer c__1 = 1;
517 static integer c__2 = 2;
519 /* > \brief \b DLARRV computes the eigenvectors of the tridiagonal matrix T = L D LT given L, D and the eigenv
522 /* =========== DOCUMENTATION =========== */
524 /* Online html documentation available at */
525 /* http://www.netlib.org/lapack/explore-html/ */
528 /* > Download DLARRV + dependencies */
529 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarrv.
532 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarrv.
535 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarrv.
543 /* SUBROUTINE DLARRV( N, VL, VU, D, L, PIVMIN, */
544 /* ISPLIT, M, DOL, DOU, MINRGP, */
545 /* RTOL1, RTOL2, W, WERR, WGAP, */
546 /* IBLOCK, INDEXW, GERS, Z, LDZ, ISUPPZ, */
547 /* WORK, IWORK, INFO ) */
549 /* INTEGER DOL, DOU, INFO, LDZ, M, N */
550 /* DOUBLE PRECISION MINRGP, PIVMIN, RTOL1, RTOL2, VL, VU */
551 /* INTEGER IBLOCK( * ), INDEXW( * ), ISPLIT( * ), */
552 /* $ ISUPPZ( * ), IWORK( * ) */
553 /* DOUBLE PRECISION D( * ), GERS( * ), L( * ), W( * ), WERR( * ), */
554 /* $ WGAP( * ), WORK( * ) */
555 /* DOUBLE PRECISION Z( LDZ, * ) */
558 /* > \par Purpose: */
563 /* > DLARRV computes the eigenvectors of the tridiagonal matrix */
564 /* > T = L D L**T given L, D and APPROXIMATIONS to the eigenvalues of L D L**T. */
565 /* > The input eigenvalues should have been computed by DLARRE. */
574 /* > The order of the matrix. N >= 0. */
577 /* > \param[in] VL */
579 /* > VL is DOUBLE PRECISION */
580 /* > Lower bound of the interval that contains the desired */
581 /* > eigenvalues. VL < VU. Needed to compute gaps on the left or right */
582 /* > end of the extremal eigenvalues in the desired RANGE. */
585 /* > \param[in] VU */
587 /* > VU is DOUBLE PRECISION */
588 /* > Upper bound of the interval that contains the desired */
589 /* > eigenvalues. VL < VU. */
590 /* > Note: VU is currently not used by this implementation of DLARRV, VU is */
591 /* > passed to DLARRV because it could be used compute gaps on the right end */
592 /* > of the extremal eigenvalues. However, with not much initial accuracy in */
593 /* > LAMBDA and VU, the formula can lead to an overestimation of the right gap */
594 /* > and thus to inadequately early RQI 'convergence'. This is currently */
595 /* > prevented this by forcing a small right gap. And so it turns out that VU */
596 /* > is currently not used by this implementation of DLARRV. */
599 /* > \param[in,out] D */
601 /* > D is DOUBLE PRECISION array, dimension (N) */
602 /* > On entry, the N diagonal elements of the diagonal matrix D. */
603 /* > On exit, D may be overwritten. */
606 /* > \param[in,out] L */
608 /* > L is DOUBLE PRECISION array, dimension (N) */
609 /* > On entry, the (N-1) subdiagonal elements of the unit */
610 /* > bidiagonal matrix L are in elements 1 to N-1 of L */
611 /* > (if the matrix is not split.) At the end of each block */
612 /* > is stored the corresponding shift as given by DLARRE. */
613 /* > On exit, L is overwritten. */
616 /* > \param[in] PIVMIN */
618 /* > PIVMIN is DOUBLE PRECISION */
619 /* > The minimum pivot allowed in the Sturm sequence. */
622 /* > \param[in] ISPLIT */
624 /* > ISPLIT is INTEGER array, dimension (N) */
625 /* > The splitting points, at which T breaks up into blocks. */
626 /* > The first block consists of rows/columns 1 to */
627 /* > ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1 */
628 /* > through ISPLIT( 2 ), etc. */
634 /* > The total number of input eigenvalues. 0 <= M <= N. */
637 /* > \param[in] DOL */
639 /* > DOL is INTEGER */
642 /* > \param[in] DOU */
644 /* > DOU is INTEGER */
645 /* > If the user wants to compute only selected eigenvectors from all */
646 /* > the eigenvalues supplied, he can specify an index range DOL:DOU. */
647 /* > Or else the setting DOL=1, DOU=M should be applied. */
648 /* > Note that DOL and DOU refer to the order in which the eigenvalues */
649 /* > are stored in W. */
650 /* > If the user wants to compute only selected eigenpairs, then */
651 /* > the columns DOL-1 to DOU+1 of the eigenvector space Z contain the */
652 /* > computed eigenvectors. All other columns of Z are set to zero. */
655 /* > \param[in] MINRGP */
657 /* > MINRGP is DOUBLE PRECISION */
660 /* > \param[in] RTOL1 */
662 /* > RTOL1 is DOUBLE PRECISION */
665 /* > \param[in] RTOL2 */
667 /* > RTOL2 is DOUBLE PRECISION */
668 /* > Parameters for bisection. */
669 /* > An interval [LEFT,RIGHT] has converged if */
670 /* > RIGHT-LEFT < MAX( RTOL1*GAP, RTOL2*MAX(|LEFT|,|RIGHT|) ) */
673 /* > \param[in,out] W */
675 /* > W is DOUBLE PRECISION array, dimension (N) */
676 /* > The first M elements of W contain the APPROXIMATE eigenvalues for */
677 /* > which eigenvectors are to be computed. The eigenvalues */
678 /* > should be grouped by split-off block and ordered from */
679 /* > smallest to largest within the block ( The output array */
680 /* > W from DLARRE is expected here ). Furthermore, they are with */
681 /* > respect to the shift of the corresponding root representation */
682 /* > for their block. On exit, W holds the eigenvalues of the */
683 /* > UNshifted matrix. */
686 /* > \param[in,out] WERR */
688 /* > WERR is DOUBLE PRECISION array, dimension (N) */
689 /* > The first M elements contain the semiwidth of the uncertainty */
690 /* > interval of the corresponding eigenvalue in W */
693 /* > \param[in,out] WGAP */
695 /* > WGAP is DOUBLE PRECISION array, dimension (N) */
696 /* > The separation from the right neighbor eigenvalue in W. */
699 /* > \param[in] IBLOCK */
701 /* > IBLOCK is INTEGER array, dimension (N) */
702 /* > The indices of the blocks (submatrices) associated with the */
703 /* > corresponding eigenvalues in W; IBLOCK(i)=1 if eigenvalue */
704 /* > W(i) belongs to the first block from the top, =2 if W(i) */
705 /* > belongs to the second block, etc. */
708 /* > \param[in] INDEXW */
710 /* > INDEXW is INTEGER array, dimension (N) */
711 /* > The indices of the eigenvalues within each block (submatrix); */
712 /* > for example, INDEXW(i)= 10 and IBLOCK(i)=2 imply that the */
713 /* > i-th eigenvalue W(i) is the 10-th eigenvalue in the second block. */
716 /* > \param[in] GERS */
718 /* > GERS is DOUBLE PRECISION array, dimension (2*N) */
719 /* > The N Gerschgorin intervals (the i-th Gerschgorin interval */
720 /* > is (GERS(2*i-1), GERS(2*i)). The Gerschgorin intervals should */
721 /* > be computed from the original UNshifted matrix. */
724 /* > \param[out] Z */
726 /* > Z is DOUBLE PRECISION array, dimension (LDZ, f2cmax(1,M) ) */
727 /* > If INFO = 0, the first M columns of Z contain the */
728 /* > orthonormal eigenvectors of the matrix T */
729 /* > corresponding to the input eigenvalues, with the i-th */
730 /* > column of Z holding the eigenvector associated with W(i). */
731 /* > Note: the user must ensure that at least f2cmax(1,M) columns are */
732 /* > supplied in the array Z. */
735 /* > \param[in] LDZ */
737 /* > LDZ is INTEGER */
738 /* > The leading dimension of the array Z. LDZ >= 1, and if */
739 /* > JOBZ = 'V', LDZ >= f2cmax(1,N). */
742 /* > \param[out] ISUPPZ */
744 /* > ISUPPZ is INTEGER array, dimension ( 2*f2cmax(1,M) ) */
745 /* > The support of the eigenvectors in Z, i.e., the indices */
746 /* > indicating the nonzero elements in Z. The I-th eigenvector */
747 /* > is nonzero only in elements ISUPPZ( 2*I-1 ) through */
748 /* > ISUPPZ( 2*I ). */
751 /* > \param[out] WORK */
753 /* > WORK is DOUBLE PRECISION array, dimension (12*N) */
756 /* > \param[out] IWORK */
758 /* > IWORK is INTEGER array, dimension (7*N) */
761 /* > \param[out] INFO */
763 /* > INFO is INTEGER */
764 /* > = 0: successful exit */
766 /* > > 0: A problem occurred in DLARRV. */
767 /* > < 0: One of the called subroutines signaled an internal problem. */
768 /* > Needs inspection of the corresponding parameter IINFO */
769 /* > for further information. */
771 /* > =-1: Problem in DLARRB when refining a child's eigenvalues. */
772 /* > =-2: Problem in DLARRF when computing the RRR of a child. */
773 /* > When a child is inside a tight cluster, it can be difficult */
774 /* > to find an RRR. A partial remedy from the user's point of */
775 /* > view is to make the parameter MINRGP smaller and recompile. */
776 /* > However, as the orthogonality of the computed vectors is */
777 /* > proportional to 1/MINRGP, the user should be aware that */
778 /* > he might be trading in precision when he decreases MINRGP. */
779 /* > =-3: Problem in DLARRB when refining a single eigenvalue */
780 /* > after the Rayleigh correction was rejected. */
781 /* > = 5: The Rayleigh Quotient Iteration failed to converge to */
782 /* > full accuracy in MAXITR steps. */
788 /* > \author Univ. of Tennessee */
789 /* > \author Univ. of California Berkeley */
790 /* > \author Univ. of Colorado Denver */
791 /* > \author NAG Ltd. */
793 /* > \date June 2016 */
795 /* > \ingroup doubleOTHERauxiliary */
797 /* > \par Contributors: */
798 /* ================== */
800 /* > Beresford Parlett, University of California, Berkeley, USA \n */
801 /* > Jim Demmel, University of California, Berkeley, USA \n */
802 /* > Inderjit Dhillon, University of Texas, Austin, USA \n */
803 /* > Osni Marques, LBNL/NERSC, USA \n */
804 /* > Christof Voemel, University of California, Berkeley, USA */
806 /* ===================================================================== */
807 /* Subroutine */ int dlarrv_(integer *n, doublereal *vl, doublereal *vu,
808 doublereal *d__, doublereal *l, doublereal *pivmin, integer *isplit,
809 integer *m, integer *dol, integer *dou, doublereal *minrgp,
810 doublereal *rtol1, doublereal *rtol2, doublereal *w, doublereal *werr,
811 doublereal *wgap, integer *iblock, integer *indexw, doublereal *gers,
812 doublereal *z__, integer *ldz, integer *isuppz, doublereal *work,
813 integer *iwork, integer *info)
815 /* System generated locals */
816 integer z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5;
817 doublereal d__1, d__2;
820 /* Local variables */
824 doublereal rgap, left;
827 integer minwsize, itmp1, i__, j, k, p, q;
828 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
834 integer iinfo, iindr;
838 extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *,
839 doublereal *, integer *);
840 integer nclus, zfrom;
842 integer iindc1, iindc2;
843 extern /* Subroutine */ int dlar1v_(integer *, integer *, integer *,
844 doublereal *, doublereal *, doublereal *, doublereal *,
845 doublereal *, doublereal *, doublereal *, doublereal *, logical *,
846 integer *, doublereal *, doublereal *, integer *, integer *,
847 doublereal *, doublereal *, doublereal *, doublereal *);
854 extern doublereal dlamch_(char *);
856 integer ibegin, indeig;
859 doublereal sgndef, mingma;
860 extern /* Subroutine */ int dlarrb_(integer *, doublereal *, doublereal *,
861 integer *, integer *, doublereal *, doublereal *, integer *,
862 doublereal *, doublereal *, doublereal *, doublereal *, integer *,
863 doublereal *, doublereal *, integer *, integer *);
864 integer oldien, oldncl, wbegin, negcnt;
870 extern /* Subroutine */ int dlarrf_(integer *, doublereal *, doublereal *,
871 doublereal *, integer *, integer *, doublereal *, doublereal *,
872 doublereal *, doublereal *, doublereal *, doublereal *,
873 doublereal *, doublereal *, doublereal *, doublereal *,
874 doublereal *, integer *);
876 integer iindwk, offset;
878 extern /* Subroutine */ int dlaset_(char *, integer *, integer *,
879 doublereal *, doublereal *, doublereal *, integer *);
880 integer newcls, oldfst, indwrk, windex, oldlst;
882 integer newfst, newftt, parity, windmn, windpl, isupmn, newlst, zusedl;
884 integer newsiz, zusedu, zusedw;
885 doublereal nrminv, rqcorr;
888 doublereal gap, eps, tau, tol, tmp;
893 /* -- LAPACK auxiliary routine (version 3.8.0) -- */
894 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
895 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
899 /* ===================================================================== */
901 /* Parameter adjustments */
912 z_offset = 1 + z_dim1 * 1;
921 /* Quick return if possible */
923 if (*n <= 0 || *m <= 0) {
927 /* The first N entries of WORK are reserved for the eigenvalues */
929 indlld = (*n << 1) + 1;
933 for (i__ = 1; i__ <= i__1; ++i__) {
937 /* IWORK(IINDR+1:IINDR+N) hold the twist indices R for the */
938 /* factorization used to compute the FP vector */
940 /* IWORK(IINDC1+1:IINC2+N) are used to store the clusters of the current */
941 /* layer and the one above. */
947 for (i__ = 1; i__ <= i__1; ++i__) {
953 /* Set lower bound for use of Z */
958 /* Set lower bound for use of Z */
961 /* The width of the part of Z that is used */
962 zusedw = zusedu - zusedl + 1;
963 dlaset_("Full", n, &zusedw, &c_b5, &c_b5, &z__[zusedl * z_dim1 + 1], ldz);
964 eps = dlamch_("Precision");
967 /* Set expert flags for standard code. */
969 if (*dol == 1 && *dou == *m) {
971 /* Only selected eigenpairs are computed. Since the other evalues */
972 /* are not refined by RQ iteration, bisection has to compute to full */
977 /* The entries WBEGIN:WEND in W, WERR, WGAP correspond to the */
978 /* desired eigenvalues. The support of the nonzero eigenvector */
979 /* entries is contained in the interval IBEGIN:IEND. */
980 /* Remark that if k eigenpairs are desired, then the eigenvectors */
981 /* are stored in k contiguous columns of Z. */
982 /* DONE is the number of eigenvectors already computed */
987 for (jblk = 1; jblk <= i__1; ++jblk) {
990 /* Find the eigenvectors of the submatrix indexed IBEGIN */
995 if (iblock[wend + 1] == jblk) {
1000 if (wend < wbegin) {
1003 } else if (wend < *dol || wbegin > *dou) {
1008 /* Find local spectral diameter of the block */
1009 gl = gers[(ibegin << 1) - 1];
1010 gu = gers[ibegin * 2];
1012 for (i__ = ibegin + 1; i__ <= i__2; ++i__) {
1014 d__1 = gers[(i__ << 1) - 1];
1015 gl = f2cmin(d__1,gl);
1017 d__1 = gers[i__ * 2];
1018 gu = f2cmax(d__1,gu);
1022 /* OLDIEN is the last index of the previous block */
1023 oldien = ibegin - 1;
1024 /* Calculate the size of the current block */
1025 in = iend - ibegin + 1;
1026 /* The number of eigenvalues in the current block */
1027 im = wend - wbegin + 1;
1028 /* This is for a 1x1 block */
1029 if (ibegin == iend) {
1031 z__[ibegin + wbegin * z_dim1] = 1.;
1032 isuppz[(wbegin << 1) - 1] = ibegin;
1033 isuppz[wbegin * 2] = ibegin;
1035 work[wbegin] = w[wbegin];
1040 /* The desired (shifted) eigenvalues are stored in W(WBEGIN:WEND) */
1041 /* Note that these can be approximations, in this case, the corresp. */
1042 /* entries of WERR give the size of the uncertainty interval. */
1043 /* The eigenvalue approximations will be refined when necessary as */
1044 /* high relative accuracy is required for the computation of the */
1045 /* corresponding eigenvectors. */
1046 dcopy_(&im, &w[wbegin], &c__1, &work[wbegin], &c__1);
1047 /* We store in W the eigenvalue approximations w.r.t. the original */
1050 for (i__ = 1; i__ <= i__2; ++i__) {
1051 w[wbegin + i__ - 1] += sigma;
1054 /* NDEPTH is the current depth of the representation tree */
1056 /* PARITY is either 1 or 0 */
1058 /* NCLUS is the number of clusters for the next level of the */
1059 /* representation tree, we start with NCLUS = 1 for the root */
1061 iwork[iindc1 + 1] = 1;
1062 iwork[iindc1 + 2] = im;
1063 /* IDONE is the number of eigenvectors already computed in the current */
1066 /* loop while( IDONE.LT.IM ) */
1067 /* generate the representation tree for the current block and */
1068 /* compute the eigenvectors */
1071 /* This is a crude protection against infinitely deep trees */
1076 /* breadth first processing of the current level of the representation */
1077 /* tree: OLDNCL = number of clusters on current level */
1079 /* reset NCLUS to count the number of child clusters */
1082 parity = 1 - parity;
1090 /* Process the clusters on the current level */
1092 for (i__ = 1; i__ <= i__2; ++i__) {
1093 j = oldcls + (i__ << 1);
1094 /* OLDFST, OLDLST = first, last index of current cluster. */
1095 /* cluster indices start with 1 and are relative */
1096 /* to WBEGIN when accessing W, WGAP, WERR, Z */
1097 oldfst = iwork[j - 1];
1100 /* Retrieve relatively robust representation (RRR) of cluster */
1101 /* that has been computed at the previous level */
1102 /* The RRR is stored in Z and overwritten once the eigenvectors */
1103 /* have been computed or when the cluster is refined */
1104 if (*dol == 1 && *dou == *m) {
1105 /* Get representation from location of the leftmost evalue */
1106 /* of the cluster */
1107 j = wbegin + oldfst - 1;
1109 if (wbegin + oldfst - 1 < *dol) {
1110 /* Get representation from the left end of Z array */
1112 } else if (wbegin + oldfst - 1 > *dou) {
1113 /* Get representation from the right end of Z array */
1116 j = wbegin + oldfst - 1;
1119 dcopy_(&in, &z__[ibegin + j * z_dim1], &c__1, &d__[ibegin]
1122 dcopy_(&i__3, &z__[ibegin + (j + 1) * z_dim1], &c__1, &l[
1124 sigma = z__[iend + (j + 1) * z_dim1];
1125 /* Set the corresponding entries in Z to zero */
1126 dlaset_("Full", &in, &c__2, &c_b5, &c_b5, &z__[ibegin + j
1129 /* Compute DL and DLL of current RRR */
1131 for (j = ibegin; j <= i__3; ++j) {
1132 tmp = d__[j] * l[j];
1133 work[indld - 1 + j] = tmp;
1134 work[indlld - 1 + j] = tmp * l[j];
1138 /* P and Q are index of the first and last eigenvalue to compute */
1139 /* within the current block */
1140 p = indexw[wbegin - 1 + oldfst];
1141 q = indexw[wbegin - 1 + oldlst];
1142 /* Offset for the arrays WORK, WGAP and WERR, i.e., the P-OFFSET */
1143 /* through the Q-OFFSET elements of these arrays are to be used. */
1144 /* OFFSET = P-OLDFST */
1145 offset = indexw[wbegin] - 1;
1146 /* perform limited bisection (if necessary) to get approximate */
1147 /* eigenvalues to the precision needed. */
1148 dlarrb_(&in, &d__[ibegin], &work[indlld + ibegin - 1], &p,
1149 &q, rtol1, rtol2, &offset, &work[wbegin], &wgap[
1150 wbegin], &werr[wbegin], &work[indwrk], &iwork[
1151 iindwk], pivmin, &spdiam, &in, &iinfo);
1156 /* We also recompute the extremal gaps. W holds all eigenvalues */
1157 /* of the unshifted matrix and must be used for computation */
1158 /* of WGAP, the entries of WORK might stem from RRRs with */
1159 /* different shifts. The gaps from WBEGIN-1+OLDFST to */
1160 /* WBEGIN-1+OLDLST are correctly computed in DLARRB. */
1161 /* However, we only allow the gaps to become greater since */
1162 /* this is what should happen when we decrease WERR */
1165 d__1 = wgap[wbegin + oldfst - 2], d__2 = w[wbegin +
1166 oldfst - 1] - werr[wbegin + oldfst - 1] - w[
1167 wbegin + oldfst - 2] - werr[wbegin + oldfst -
1169 wgap[wbegin + oldfst - 2] = f2cmax(d__1,d__2);
1171 if (wbegin + oldlst - 1 < wend) {
1173 d__1 = wgap[wbegin + oldlst - 1], d__2 = w[wbegin +
1174 oldlst] - werr[wbegin + oldlst] - w[wbegin +
1175 oldlst - 1] - werr[wbegin + oldlst - 1];
1176 wgap[wbegin + oldlst - 1] = f2cmax(d__1,d__2);
1178 /* Each time the eigenvalues in WORK get refined, we store */
1179 /* the newly found approximation with all shifts applied in W */
1181 for (j = oldfst; j <= i__3; ++j) {
1182 w[wbegin + j - 1] = work[wbegin + j - 1] + sigma;
1186 /* Process the current node. */
1189 for (j = oldfst; j <= i__3; ++j) {
1191 /* we are at the right end of the cluster, this is also the */
1192 /* boundary of the child cluster */
1194 } else if (wgap[wbegin + j - 1] >= *minrgp * (d__1 = work[
1195 wbegin + j - 1], abs(d__1))) {
1196 /* the right relative gap is big enough, the child cluster */
1197 /* (NEWFST,..,NEWLST) is well separated from the following */
1200 /* inside a child cluster, the relative gap is not */
1204 /* Compute size of child cluster found */
1205 newsiz = newlst - newfst + 1;
1206 /* NEWFTT is the place in Z where the new RRR or the computed */
1207 /* eigenvector is to be stored */
1208 if (*dol == 1 && *dou == *m) {
1209 /* Store representation at location of the leftmost evalue */
1210 /* of the cluster */
1211 newftt = wbegin + newfst - 1;
1213 if (wbegin + newfst - 1 < *dol) {
1214 /* Store representation at the left end of Z array */
1216 } else if (wbegin + newfst - 1 > *dou) {
1217 /* Store representation at the right end of Z array */
1220 newftt = wbegin + newfst - 1;
1225 /* Current child is not a singleton but a cluster. */
1226 /* Compute and store new representation of child. */
1229 /* Compute left and right cluster gap. */
1231 /* LGAP and RGAP are not computed from WORK because */
1232 /* the eigenvalue approximations may stem from RRRs */
1233 /* different shifts. However, W hold all eigenvalues */
1234 /* of the unshifted matrix. Still, the entries in WGAP */
1235 /* have to be computed from WORK since the entries */
1236 /* in W might be of the same order so that gaps are not */
1237 /* exhibited correctly for very close eigenvalues. */
1240 d__1 = 0., d__2 = w[wbegin] - werr[wbegin] - *vl;
1241 lgap = f2cmax(d__1,d__2);
1243 lgap = wgap[wbegin + newfst - 2];
1245 rgap = wgap[wbegin + newlst - 1];
1247 /* Compute left- and rightmost eigenvalue of child */
1248 /* to high precision in order to shift as close */
1249 /* as possible and obtain as large relative gaps */
1252 for (k = 1; k <= 2; ++k) {
1254 p = indexw[wbegin - 1 + newfst];
1256 p = indexw[wbegin - 1 + newlst];
1258 offset = indexw[wbegin] - 1;
1259 dlarrb_(&in, &d__[ibegin], &work[indlld + ibegin
1260 - 1], &p, &p, &rqtol, &rqtol, &offset, &
1261 work[wbegin], &wgap[wbegin], &werr[wbegin]
1262 , &work[indwrk], &iwork[iindwk], pivmin, &
1263 spdiam, &in, &iinfo);
1267 if (wbegin + newlst - 1 < *dol || wbegin + newfst - 1
1269 /* if the cluster contains no desired eigenvalues */
1270 /* skip the computation of that branch of the rep. tree */
1272 /* We could skip before the refinement of the extremal */
1273 /* eigenvalues of the child, but then the representation */
1274 /* tree could be different from the one when nothing is */
1275 /* skipped. For this reason we skip at this place. */
1276 idone = idone + newlst - newfst + 1;
1280 /* Compute RRR of child cluster. */
1281 /* Note that the new RRR is stored in Z */
1283 /* DLARRF needs LWORK = 2*N */
1284 dlarrf_(&in, &d__[ibegin], &l[ibegin], &work[indld +
1285 ibegin - 1], &newfst, &newlst, &work[wbegin],
1286 &wgap[wbegin], &werr[wbegin], &spdiam, &lgap,
1287 &rgap, pivmin, &tau, &z__[ibegin + newftt *
1288 z_dim1], &z__[ibegin + (newftt + 1) * z_dim1],
1289 &work[indwrk], &iinfo);
1291 /* a new RRR for the cluster was found by DLARRF */
1292 /* update shift and store it */
1293 ssigma = sigma + tau;
1294 z__[iend + (newftt + 1) * z_dim1] = ssigma;
1295 /* WORK() are the midpoints and WERR() the semi-width */
1296 /* Note that the entries in W are unchanged. */
1298 for (k = newfst; k <= i__4; ++k) {
1299 fudge = eps * 3. * (d__1 = work[wbegin + k -
1301 work[wbegin + k - 1] -= tau;
1302 fudge += eps * 4. * (d__1 = work[wbegin + k -
1305 werr[wbegin + k - 1] += fudge;
1306 /* Gaps are not fudged. Provided that WERR is small */
1307 /* when eigenvalues are close, a zero gap indicates */
1308 /* that a new representation is needed for resolving */
1309 /* the cluster. A fudge could lead to a wrong decision */
1310 /* of judging eigenvalues 'separated' which in */
1311 /* reality are not. This could have a negative impact */
1312 /* on the orthogonality of the computed eigenvectors. */
1316 k = newcls + (nclus << 1);
1317 iwork[k - 1] = newfst;
1325 /* Compute eigenvector of singleton */
1329 tol = log((doublereal) in) * 4. * eps;
1332 windex = wbegin + k - 1;
1335 windmn = f2cmax(i__4,1);
1338 windpl = f2cmin(i__4,*m);
1339 lambda = work[windex];
1341 /* Check if eigenvector computation is to be skipped */
1342 if (windex < *dol || windex > *dou) {
1348 left = work[windex] - werr[windex];
1349 right = work[windex] + werr[windex];
1350 indeig = indexw[windex];
1351 /* Note that since we compute the eigenpairs for a child, */
1352 /* all eigenvalue approximations are w.r.t the same shift. */
1353 /* In this case, the entries in WORK should be used for */
1354 /* computing the gaps since they exhibit even very small */
1355 /* differences in the eigenvalues, as opposed to the */
1356 /* entries in W which might "look" the same. */
1358 /* In the case RANGE='I' and with not much initial */
1359 /* accuracy in LAMBDA and VL, the formula */
1360 /* LGAP = MAX( ZERO, (SIGMA - VL) + LAMBDA ) */
1361 /* can lead to an overestimation of the left gap and */
1362 /* thus to inadequately early RQI 'convergence'. */
1363 /* Prevent this by forcing a small left gap. */
1365 d__1 = abs(left), d__2 = abs(right);
1366 lgap = eps * f2cmax(d__1,d__2);
1368 lgap = wgap[windmn];
1371 /* In the case RANGE='I' and with not much initial */
1372 /* accuracy in LAMBDA and VU, the formula */
1373 /* can lead to an overestimation of the right gap and */
1374 /* thus to inadequately early RQI 'convergence'. */
1375 /* Prevent this by forcing a small right gap. */
1377 d__1 = abs(left), d__2 = abs(right);
1378 rgap = eps * f2cmax(d__1,d__2);
1380 rgap = wgap[windex];
1382 gap = f2cmin(lgap,rgap);
1383 if (k == 1 || k == im) {
1384 /* The eigenvector support can become wrong */
1385 /* because significant entries could be cut off due to a */
1386 /* large GAPTOL parameter in LAR1V. Prevent this. */
1393 /* Update WGAP so that it holds the minimum gap */
1394 /* to the left or the right. This is crucial in the */
1395 /* case where bisection is used to ensure that the */
1396 /* eigenvalue is refined up to the required precision. */
1397 /* The correct value is restored afterwards. */
1398 savgap = wgap[windex];
1400 /* We want to use the Rayleigh Quotient Correction */
1401 /* as often as possible since it converges quadratically */
1402 /* when we are close enough to the desired eigenvalue. */
1403 /* However, the Rayleigh Quotient can have the wrong sign */
1404 /* and lead us away from the desired eigenvalue. In this */
1405 /* case, the best we can do is to use bisection. */
1408 /* Bisection is initially turned off unless it is forced */
1411 /* Check if bisection should be used to refine eigenvalue */
1413 /* Take the bisection as new iterate */
1415 itmp1 = iwork[iindr + windex];
1416 offset = indexw[wbegin] - 1;
1418 dlarrb_(&in, &d__[ibegin], &work[indlld + ibegin
1419 - 1], &indeig, &indeig, &c_b5, &d__1, &
1420 offset, &work[wbegin], &wgap[wbegin], &
1421 werr[wbegin], &work[indwrk], &iwork[
1422 iindwk], pivmin, &spdiam, &itmp1, &iinfo);
1427 lambda = work[windex];
1428 /* Reset twist index from inaccurate LAMBDA to */
1429 /* force computation of true MINGMA */
1430 iwork[iindr + windex] = 0;
1432 /* Given LAMBDA, compute the eigenvector. */
1434 dlar1v_(&in, &c__1, &in, &lambda, &d__[ibegin], &l[
1435 ibegin], &work[indld + ibegin - 1], &work[
1436 indlld + ibegin - 1], pivmin, &gaptol, &z__[
1437 ibegin + windex * z_dim1], &L__1, &negcnt, &
1438 ztz, &mingma, &iwork[iindr + windex], &isuppz[
1439 (windex << 1) - 1], &nrminv, &resid, &rqcorr,
1444 } else if (resid < bstres) {
1449 i__4 = isupmn, i__5 = isuppz[(windex << 1) - 1];
1450 isupmn = f2cmin(i__4,i__5);
1452 i__4 = isupmx, i__5 = isuppz[windex * 2];
1453 isupmx = f2cmax(i__4,i__5);
1455 /* sin alpha <= |resid|/gap */
1456 /* Note that both the residual and the gap are */
1457 /* proportional to the matrix, so ||T|| doesn't play */
1458 /* a role in the quotient */
1460 /* Convergence test for Rayleigh-Quotient iteration */
1461 /* (omitted when Bisection has been used) */
1463 if (resid > tol * gap && abs(rqcorr) > rqtol * abs(
1464 lambda) && ! usedbs) {
1465 /* We need to check that the RQCORR update doesn't */
1466 /* move the eigenvalue away from the desired one and */
1467 /* towards a neighbor. -> protection with bisection */
1468 if (indeig <= negcnt) {
1469 /* The wanted eigenvalue lies to the left */
1472 /* The wanted eigenvalue lies to the right */
1475 /* We only use the RQCORR if it improves the */
1476 /* the iterate reasonably. */
1477 if (rqcorr * sgndef >= 0. && lambda + rqcorr <=
1478 right && lambda + rqcorr >= left) {
1480 /* Store new midpoint of bisection interval in WORK */
1482 /* The current LAMBDA is on the left of the true */
1485 /* We prefer to assume that the error estimate */
1486 /* is correct. We could make the interval not */
1487 /* as a bracket but to be modified if the RQCORR */
1488 /* chooses to. In this case, the RIGHT side should */
1489 /* be modified as follows: */
1490 /* RIGHT = MAX(RIGHT, LAMBDA + RQCORR) */
1492 /* The current LAMBDA is on the right of the true */
1495 /* See comment about assuming the error estimate is */
1496 /* correct above. */
1497 /* LEFT = MIN(LEFT, LAMBDA + RQCORR) */
1499 work[windex] = (right + left) * .5;
1500 /* Take RQCORR since it has the correct sign and */
1501 /* improves the iterate reasonably */
1503 /* Update width of error interval */
1504 werr[windex] = (right - left) * .5;
1508 if (right - left < rqtol * abs(lambda)) {
1509 /* The eigenvalue is computed to bisection accuracy */
1510 /* compute eigenvector and stop */
1513 } else if (iter < 10) {
1515 } else if (iter == 10) {
1524 if (usedrq && usedbs && bstres <= resid) {
1529 /* improve error angle by second step */
1531 dlar1v_(&in, &c__1, &in, &lambda, &d__[ibegin]
1532 , &l[ibegin], &work[indld + ibegin -
1533 1], &work[indlld + ibegin - 1],
1534 pivmin, &gaptol, &z__[ibegin + windex
1535 * z_dim1], &L__1, &negcnt, &ztz, &
1536 mingma, &iwork[iindr + windex], &
1537 isuppz[(windex << 1) - 1], &nrminv, &
1538 resid, &rqcorr, &work[indwrk]);
1540 work[windex] = lambda;
1543 /* Compute FP-vector support w.r.t. whole matrix */
1545 isuppz[(windex << 1) - 1] += oldien;
1546 isuppz[windex * 2] += oldien;
1547 zfrom = isuppz[(windex << 1) - 1];
1548 zto = isuppz[windex * 2];
1551 /* Ensure vector is ok if support in the RQI has changed */
1552 if (isupmn < zfrom) {
1554 for (ii = isupmn; ii <= i__4; ++ii) {
1555 z__[ii + windex * z_dim1] = 0.;
1561 for (ii = zto + 1; ii <= i__4; ++ii) {
1562 z__[ii + windex * z_dim1] = 0.;
1566 i__4 = zto - zfrom + 1;
1567 dscal_(&i__4, &nrminv, &z__[zfrom + windex * z_dim1],
1571 w[windex] = lambda + sigma;
1572 /* Recompute the gaps on the left and right */
1573 /* But only allow them to become larger and not */
1574 /* smaller (which can only happen through "bad" */
1575 /* cancellation and doesn't reflect the theory */
1576 /* where the initial gaps are underestimated due */
1577 /* to WERR being too crude.) */
1581 d__1 = wgap[windmn], d__2 = w[windex] - werr[
1582 windex] - w[windmn] - werr[windmn];
1583 wgap[windmn] = f2cmax(d__1,d__2);
1585 if (windex < wend) {
1587 d__1 = savgap, d__2 = w[windpl] - werr[windpl]
1588 - w[windex] - werr[windex];
1589 wgap[windex] = f2cmax(d__1,d__2);
1594 /* here ends the code for the current child */
1597 /* Proceed to any remaining child nodes */