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 integer c__1 = 1;
516 static integer c_n1 = -1;
517 static integer c__3 = 3;
518 static integer c__2 = 2;
519 static integer c__0 = 0;
521 /* > \brief \b DLARRD computes the eigenvalues of a symmetric tridiagonal matrix to suitable accuracy. */
523 /* =========== DOCUMENTATION =========== */
525 /* Online html documentation available at */
526 /* http://www.netlib.org/lapack/explore-html/ */
529 /* > Download DLARRD + dependencies */
530 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarrd.
533 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarrd.
536 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarrd.
544 /* SUBROUTINE DLARRD( RANGE, ORDER, N, VL, VU, IL, IU, GERS, */
545 /* RELTOL, D, E, E2, PIVMIN, NSPLIT, ISPLIT, */
546 /* M, W, WERR, WL, WU, IBLOCK, INDEXW, */
547 /* WORK, IWORK, INFO ) */
549 /* CHARACTER ORDER, RANGE */
550 /* INTEGER IL, INFO, IU, M, N, NSPLIT */
551 /* DOUBLE PRECISION PIVMIN, RELTOL, VL, VU, WL, WU */
552 /* INTEGER IBLOCK( * ), INDEXW( * ), */
553 /* $ ISPLIT( * ), IWORK( * ) */
554 /* DOUBLE PRECISION D( * ), E( * ), E2( * ), */
555 /* $ GERS( * ), W( * ), WERR( * ), WORK( * ) */
558 /* > \par Purpose: */
563 /* > DLARRD computes the eigenvalues of a symmetric tridiagonal */
564 /* > matrix T to suitable accuracy. This is an auxiliary code to be */
565 /* > called from DSTEMR. */
566 /* > The user may ask for all eigenvalues, all eigenvalues */
567 /* > in the half-open interval (VL, VU], or the IL-th through IU-th */
570 /* > To avoid overflow, the matrix must be scaled so that its */
571 /* > largest element is no greater than overflow**(1/2) * underflow**(1/4) in absolute value, and for greatest
573 /* > accuracy, it should not be much smaller than that. */
575 /* > See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal */
576 /* > Matrix", Report CS41, Computer Science Dept., Stanford */
577 /* > University, July 21, 1966. */
583 /* > \param[in] RANGE */
585 /* > RANGE is CHARACTER*1 */
586 /* > = 'A': ("All") all eigenvalues will be found. */
587 /* > = 'V': ("Value") all eigenvalues in the half-open interval */
588 /* > (VL, VU] will be found. */
589 /* > = 'I': ("Index") the IL-th through IU-th eigenvalues (of the */
590 /* > entire matrix) will be found. */
593 /* > \param[in] ORDER */
595 /* > ORDER is CHARACTER*1 */
596 /* > = 'B': ("By Block") the eigenvalues will be grouped by */
597 /* > split-off block (see IBLOCK, ISPLIT) and */
598 /* > ordered from smallest to largest within */
600 /* > = 'E': ("Entire matrix") */
601 /* > the eigenvalues for the entire matrix */
602 /* > will be ordered from smallest to */
609 /* > The order of the tridiagonal matrix T. N >= 0. */
612 /* > \param[in] VL */
614 /* > VL is DOUBLE PRECISION */
615 /* > If RANGE='V', the lower bound of the interval to */
616 /* > be searched for eigenvalues. Eigenvalues less than or equal */
617 /* > to VL, or greater than VU, will not be returned. VL < VU. */
618 /* > Not referenced if RANGE = 'A' or 'I'. */
621 /* > \param[in] VU */
623 /* > VU is DOUBLE PRECISION */
624 /* > If RANGE='V', the upper bound of the interval to */
625 /* > be searched for eigenvalues. Eigenvalues less than or equal */
626 /* > to VL, or greater than VU, will not be returned. VL < VU. */
627 /* > Not referenced if RANGE = 'A' or 'I'. */
630 /* > \param[in] IL */
632 /* > IL is INTEGER */
633 /* > If RANGE='I', the index of the */
634 /* > smallest eigenvalue to be returned. */
635 /* > 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */
636 /* > Not referenced if RANGE = 'A' or 'V'. */
639 /* > \param[in] IU */
641 /* > IU is INTEGER */
642 /* > If RANGE='I', the index of the */
643 /* > largest eigenvalue to be returned. */
644 /* > 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */
645 /* > Not referenced if RANGE = 'A' or 'V'. */
648 /* > \param[in] GERS */
650 /* > GERS is DOUBLE PRECISION array, dimension (2*N) */
651 /* > The N Gerschgorin intervals (the i-th Gerschgorin interval */
652 /* > is (GERS(2*i-1), GERS(2*i)). */
655 /* > \param[in] RELTOL */
657 /* > RELTOL is DOUBLE PRECISION */
658 /* > The minimum relative width of an interval. When an interval */
659 /* > is narrower than RELTOL times the larger (in */
660 /* > magnitude) endpoint, then it is considered to be */
661 /* > sufficiently small, i.e., converged. Note: this should */
662 /* > always be at least radix*machine epsilon. */
667 /* > D is DOUBLE PRECISION array, dimension (N) */
668 /* > The n diagonal elements of the tridiagonal matrix T. */
673 /* > E is DOUBLE PRECISION array, dimension (N-1) */
674 /* > The (n-1) off-diagonal elements of the tridiagonal matrix T. */
677 /* > \param[in] E2 */
679 /* > E2 is DOUBLE PRECISION array, dimension (N-1) */
680 /* > The (n-1) squared off-diagonal elements of the tridiagonal matrix T. */
683 /* > \param[in] PIVMIN */
685 /* > PIVMIN is DOUBLE PRECISION */
686 /* > The minimum pivot allowed in the Sturm sequence for T. */
689 /* > \param[in] NSPLIT */
691 /* > NSPLIT is INTEGER */
692 /* > The number of diagonal blocks in the matrix T. */
693 /* > 1 <= NSPLIT <= N. */
696 /* > \param[in] ISPLIT */
698 /* > ISPLIT is INTEGER array, dimension (N) */
699 /* > The splitting points, at which T breaks up into submatrices. */
700 /* > The first submatrix consists of rows/columns 1 to ISPLIT(1), */
701 /* > the second of rows/columns ISPLIT(1)+1 through ISPLIT(2), */
702 /* > etc., and the NSPLIT-th consists of rows/columns */
703 /* > ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N. */
704 /* > (Only the first NSPLIT elements will actually be used, but */
705 /* > since the user cannot know a priori what value NSPLIT will */
706 /* > have, N words must be reserved for ISPLIT.) */
709 /* > \param[out] M */
712 /* > The actual number of eigenvalues found. 0 <= M <= N. */
713 /* > (See also the description of INFO=2,3.) */
716 /* > \param[out] W */
718 /* > W is DOUBLE PRECISION array, dimension (N) */
719 /* > On exit, the first M elements of W will contain the */
720 /* > eigenvalue approximations. DLARRD computes an interval */
721 /* > I_j = (a_j, b_j] that includes eigenvalue j. The eigenvalue */
722 /* > approximation is given as the interval midpoint */
723 /* > W(j)= ( a_j + b_j)/2. The corresponding error is bounded by */
724 /* > WERR(j) = abs( a_j - b_j)/2 */
727 /* > \param[out] WERR */
729 /* > WERR is DOUBLE PRECISION array, dimension (N) */
730 /* > The error bound on the corresponding eigenvalue approximation */
734 /* > \param[out] WL */
736 /* > WL is DOUBLE PRECISION */
739 /* > \param[out] WU */
741 /* > WU is DOUBLE PRECISION */
742 /* > The interval (WL, WU] contains all the wanted eigenvalues. */
743 /* > If RANGE='V', then WL=VL and WU=VU. */
744 /* > If RANGE='A', then WL and WU are the global Gerschgorin bounds */
745 /* > on the spectrum. */
746 /* > If RANGE='I', then WL and WU are computed by DLAEBZ from the */
747 /* > index range specified. */
750 /* > \param[out] IBLOCK */
752 /* > IBLOCK is INTEGER array, dimension (N) */
753 /* > At each row/column j where E(j) is zero or small, the */
754 /* > matrix T is considered to split into a block diagonal */
755 /* > matrix. On exit, if INFO = 0, IBLOCK(i) specifies to which */
756 /* > block (from 1 to the number of blocks) the eigenvalue W(i) */
757 /* > belongs. (DLARRD may use the remaining N-M elements as */
761 /* > \param[out] INDEXW */
763 /* > INDEXW is INTEGER array, dimension (N) */
764 /* > The indices of the eigenvalues within each block (submatrix); */
765 /* > for example, INDEXW(i)= j and IBLOCK(i)=k imply that the */
766 /* > i-th eigenvalue W(i) is the j-th eigenvalue in block k. */
769 /* > \param[out] WORK */
771 /* > WORK is DOUBLE PRECISION array, dimension (4*N) */
774 /* > \param[out] IWORK */
776 /* > IWORK is INTEGER array, dimension (3*N) */
779 /* > \param[out] INFO */
781 /* > INFO is INTEGER */
782 /* > = 0: successful exit */
783 /* > < 0: if INFO = -i, the i-th argument had an illegal value */
784 /* > > 0: some or all of the eigenvalues failed to converge or */
785 /* > were not computed: */
786 /* > =1 or 3: Bisection failed to converge for some */
787 /* > eigenvalues; these eigenvalues are flagged by a */
788 /* > negative block number. The effect is that the */
789 /* > eigenvalues may not be as accurate as the */
790 /* > absolute and relative tolerances. This is */
791 /* > generally caused by unexpectedly inaccurate */
793 /* > =2 or 3: RANGE='I' only: Not all of the eigenvalues */
794 /* > IL:IU were found. */
795 /* > Effect: M < IU+1-IL */
796 /* > Cause: non-monotonic arithmetic, causing the */
797 /* > Sturm sequence to be non-monotonic. */
798 /* > Cure: recalculate, using RANGE='A', and pick */
799 /* > out eigenvalues IL:IU. In some cases, */
800 /* > increasing the PARAMETER "FUDGE" may */
801 /* > make things work. */
802 /* > = 4: RANGE='I', and the Gershgorin interval */
803 /* > initially used was too small. No eigenvalues */
804 /* > were computed. */
805 /* > Probable cause: your machine has sloppy */
806 /* > floating-point arithmetic. */
807 /* > Cure: Increase the PARAMETER "FUDGE", */
808 /* > recompile, and try again. */
811 /* > \par Internal Parameters: */
812 /* ========================= */
815 /* > FUDGE DOUBLE PRECISION, default = 2 */
816 /* > A "fudge factor" to widen the Gershgorin intervals. Ideally, */
817 /* > a value of 1 should work, but on machines with sloppy */
818 /* > arithmetic, this needs to be larger. The default for */
819 /* > publicly released versions should be large enough to handle */
820 /* > the worst machine around. Note that this has no effect */
821 /* > on accuracy of the solution. */
824 /* > \par Contributors: */
825 /* ================== */
827 /* > W. Kahan, University of California, Berkeley, USA \n */
828 /* > Beresford Parlett, University of California, Berkeley, USA \n */
829 /* > Jim Demmel, University of California, Berkeley, USA \n */
830 /* > Inderjit Dhillon, University of Texas, Austin, USA \n */
831 /* > Osni Marques, LBNL/NERSC, USA \n */
832 /* > Christof Voemel, University of California, Berkeley, USA \n */
837 /* > \author Univ. of Tennessee */
838 /* > \author Univ. of California Berkeley */
839 /* > \author Univ. of Colorado Denver */
840 /* > \author NAG Ltd. */
842 /* > \date June 2016 */
844 /* > \ingroup OTHERauxiliary */
846 /* ===================================================================== */
847 /* Subroutine */ int dlarrd_(char *range, char *order, integer *n, doublereal
848 *vl, doublereal *vu, integer *il, integer *iu, doublereal *gers,
849 doublereal *reltol, doublereal *d__, doublereal *e, doublereal *e2,
850 doublereal *pivmin, integer *nsplit, integer *isplit, integer *m,
851 doublereal *w, doublereal *werr, doublereal *wl, doublereal *wu,
852 integer *iblock, integer *indexw, doublereal *work, integer *iwork,
855 /* System generated locals */
856 integer i__1, i__2, i__3;
857 doublereal d__1, d__2;
859 /* Local variables */
860 integer iend, jblk, ioff, iout, itmp1, itmp2, i__, j, jdisc;
861 extern logical lsame_(char *, char *);
864 integer iwoff, itmax;
865 doublereal wkill, rtoli, uflow, tnorm;
866 integer ib, ie, je, nb;
869 extern doublereal dlamch_(char *);
872 extern /* Subroutine */ int dlaebz_(integer *, integer *, integer *,
873 integer *, integer *, integer *, doublereal *, doublereal *,
874 doublereal *, doublereal *, doublereal *, doublereal *, integer *,
875 doublereal *, doublereal *, integer *, integer *, doublereal *,
876 integer *, integer *);
877 integer irange, idiscl, idumma[1];
878 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
879 integer *, integer *, ftnlen, ftnlen);
881 logical ncnvrg, toofew;
887 doublereal tmp1, tmp2;
890 /* -- LAPACK auxiliary routine (version 3.7.1) -- */
891 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
892 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
896 /* ===================================================================== */
899 /* Parameter adjustments */
915 /* Quick return if possible */
923 if (lsame_(range, "A")) {
925 } else if (lsame_(range, "V")) {
927 } else if (lsame_(range, "I")) {
933 /* Check for Errors */
937 } else if (! (lsame_(order, "B") || lsame_(order,
942 } else if (irange == 2) {
946 } else if (irange == 3 && (*il < 1 || *il > f2cmax(1,*n))) {
948 } else if (irange == 3 && (*iu < f2cmin(*n,*il) || *iu > *n)) {
955 /* Initialize error flags */
959 /* Quick return if possible */
964 /* Simplification: */
965 if (irange == 3 && *il == 1 && *iu == *n) {
968 /* Get machine constants */
970 uflow = dlamch_("U");
971 /* Special Case when N=1 */
972 /* Treat case of 1x1 matrix for quick return */
974 if (irange == 1 || irange == 2 && d__[1] > *vl && d__[1] <= *vu ||
975 irange == 3 && *il == 1 && *iu == 1) {
978 /* The computation error of the eigenvalue is zero */
985 /* NB is the minimum vector length for vector bisection, or 0 */
986 /* if only scalar is to be done. */
987 nb = ilaenv_(&c__1, "DSTEBZ", " ", n, &c_n1, &c_n1, &c_n1, (ftnlen)6, (
992 /* Find global spectral radius */
996 for (i__ = 1; i__ <= i__1; ++i__) {
998 d__1 = gl, d__2 = gers[(i__ << 1) - 1];
999 gl = f2cmin(d__1,d__2);
1001 d__1 = gu, d__2 = gers[i__ * 2];
1002 gu = f2cmax(d__1,d__2);
1005 /* Compute global Gerschgorin bounds and spectral diameter */
1007 d__1 = abs(gl), d__2 = abs(gu);
1008 tnorm = f2cmax(d__1,d__2);
1009 gl = gl - tnorm * 2. * eps * *n - *pivmin * 4.;
1010 gu = gu + tnorm * 2. * eps * *n + *pivmin * 4.;
1011 /* [JAN/28/2009] remove the line below since SPDIAM variable not use */
1012 /* SPDIAM = GU - GL */
1013 /* Input arguments for DLAEBZ: */
1014 /* The relative tolerance. An interval (a,b] lies within */
1015 /* "relative tolerance" if b-a < RELTOL*f2cmax(|a|,|b|), */
1017 /* Set the absolute tolerance for interval convergence to zero to force */
1018 /* interval convergence based on relative size of the interval. */
1019 /* This is dangerous because intervals might not converge when RELTOL is */
1020 /* small. But at least a very small number should be selected so that for */
1021 /* strongly graded matrices, the code can get relatively accurate */
1023 atoli = uflow * 4. + *pivmin * 4.;
1025 /* RANGE='I': Compute an interval containing eigenvalues */
1026 /* IL through IU. The initial interval [GL,GU] from the global */
1027 /* Gerschgorin bounds GL and GU is refined by DLAEBZ. */
1028 itmax = (integer) ((log(tnorm + *pivmin) - log(*pivmin)) / log(2.)) +
1043 dlaebz_(&c__3, &itmax, n, &c__2, &c__2, &nb, &atoli, &rtoli, pivmin, &
1044 d__[1], &e[1], &e2[1], &iwork[5], &work[*n + 1], &work[*n + 5]
1045 , &iout, &iwork[1], &w[1], &iblock[1], &iinfo);
1050 /* On exit, output intervals may not be ordered by ascending negcount */
1051 if (iwork[6] == *iu) {
1066 /* On exit, the interval [WL, WLU] contains a value with negcount NWL, */
1067 /* and [WUL, WU] contains a value with negcount NWU. */
1068 if (nwl < 0 || nwl >= *n || nwu < 1 || nwu > *n) {
1072 } else if (irange == 2) {
1075 } else if (irange == 1) {
1079 /* Find Eigenvalues -- Loop Over blocks and recompute NWL and NWU. */
1080 /* NWL accumulates the number of eigenvalues .le. WL, */
1081 /* NWU accumulates the number of eigenvalues .le. WU */
1089 for (jblk = 1; jblk <= i__1; ++jblk) {
1092 iend = isplit[jblk];
1097 if (*wl >= d__[ibegin] - *pivmin) {
1100 if (*wu >= d__[ibegin] - *pivmin) {
1103 if (irange == 1 || *wl < d__[ibegin] - *pivmin && *wu >= d__[
1104 ibegin] - *pivmin) {
1106 w[*m] = d__[ibegin];
1108 /* The gap for a single block doesn't matter for the later */
1109 /* algorithm and is assigned an arbitrary large value */
1113 /* Disabled 2x2 case because of a failure on the following matrix */
1114 /* RANGE = 'I', IL = IU = 4 */
1115 /* Original Tridiagonal, d = [ */
1116 /* -0.150102010615740E+00 */
1117 /* -0.849897989384260E+00 */
1118 /* -0.128208148052635E-15 */
1119 /* 0.128257718286320E-15 */
1122 /* -0.357171383266986E+00 */
1123 /* -0.180411241501588E-15 */
1124 /* -0.175152352710251E-15 */
1127 /* ELSE IF( IN.EQ.2 ) THEN */
1129 /* DISC = SQRT( (HALF*(D(IBEGIN)-D(IEND)))**2 + E(IBEGIN)**2 ) */
1130 /* TMP1 = HALF*(D(IBEGIN)+D(IEND)) */
1131 /* L1 = TMP1 - DISC */
1132 /* IF( WL.GE. L1-PIVMIN ) */
1133 /* $ NWL = NWL + 1 */
1134 /* IF( WU.GE. L1-PIVMIN ) */
1135 /* $ NWU = NWU + 1 */
1136 /* IF( IRANGE.EQ.ALLRNG .OR. ( WL.LT.L1-PIVMIN .AND. WU.GE. */
1137 /* $ L1-PIVMIN ) ) THEN */
1140 /* * The uncertainty of eigenvalues of a 2x2 matrix is very small */
1141 /* WERR( M ) = EPS * ABS( W( M ) ) * TWO */
1142 /* IBLOCK( M ) = JBLK */
1143 /* INDEXW( M ) = 1 */
1145 /* L2 = TMP1 + DISC */
1146 /* IF( WL.GE. L2-PIVMIN ) */
1147 /* $ NWL = NWL + 1 */
1148 /* IF( WU.GE. L2-PIVMIN ) */
1149 /* $ NWU = NWU + 1 */
1150 /* IF( IRANGE.EQ.ALLRNG .OR. ( WL.LT.L2-PIVMIN .AND. WU.GE. */
1151 /* $ L2-PIVMIN ) ) THEN */
1154 /* * The uncertainty of eigenvalues of a 2x2 matrix is very small */
1155 /* WERR( M ) = EPS * ABS( W( M ) ) * TWO */
1156 /* IBLOCK( M ) = JBLK */
1157 /* INDEXW( M ) = 2 */
1160 /* General Case - block of size IN >= 2 */
1161 /* Compute local Gerschgorin interval and use it as the initial */
1162 /* interval for DLAEBZ */
1167 for (j = ibegin; j <= i__2; ++j) {
1169 d__1 = gl, d__2 = gers[(j << 1) - 1];
1170 gl = f2cmin(d__1,d__2);
1172 d__1 = gu, d__2 = gers[j * 2];
1173 gu = f2cmax(d__1,d__2);
1177 /* change SPDIAM by TNORM in lines 2 and 3 thereafter */
1178 /* line 1: remove computation of SPDIAM (not useful anymore) */
1179 /* SPDIAM = GU - GL */
1180 /* GL = GL - FUDGE*SPDIAM*EPS*IN - FUDGE*PIVMIN */
1181 /* GU = GU + FUDGE*SPDIAM*EPS*IN + FUDGE*PIVMIN */
1182 gl = gl - tnorm * 2. * eps * in - *pivmin * 2.;
1183 gu = gu + tnorm * 2. * eps * in + *pivmin * 2.;
1187 /* the local block contains none of the wanted eigenvalues */
1192 /* refine search interval if possible, only range (WL,WU] matters */
1193 gl = f2cmax(gl,*wl);
1194 gu = f2cmin(gu,*wu);
1199 /* Find negcount of initial interval boundaries GL and GU */
1201 work[*n + in + 1] = gu;
1202 dlaebz_(&c__1, &c__0, &in, &in, &c__1, &nb, &atoli, &rtoli,
1203 pivmin, &d__[ibegin], &e[ibegin], &e2[ibegin], idumma, &
1204 work[*n + 1], &work[*n + (in << 1) + 1], &im, &iwork[1], &
1205 w[*m + 1], &iblock[*m + 1], &iinfo);
1212 nwu += iwork[in + 1];
1213 iwoff = *m - iwork[1];
1214 /* Compute Eigenvalues */
1215 itmax = (integer) ((log(gu - gl + *pivmin) - log(*pivmin)) / log(
1217 dlaebz_(&c__2, &itmax, &in, &in, &c__1, &nb, &atoli, &rtoli,
1218 pivmin, &d__[ibegin], &e[ibegin], &e2[ibegin], idumma, &
1219 work[*n + 1], &work[*n + (in << 1) + 1], &iout, &iwork[1],
1220 &w[*m + 1], &iblock[*m + 1], &iinfo);
1226 /* Copy eigenvalues into W and IBLOCK */
1227 /* Use -JBLK for block number for unconverged eigenvalues. */
1228 /* Loop over the number of output intervals from DLAEBZ */
1230 for (j = 1; j <= i__2; ++j) {
1231 /* eigenvalue approximation is middle point of interval */
1232 tmp1 = (work[j + *n] + work[j + in + *n]) * .5;
1233 /* semi length of error interval */
1234 tmp2 = (d__1 = work[j + *n] - work[j + in + *n], abs(d__1)) *
1236 if (j > iout - iinfo) {
1237 /* Flag non-convergence. */
1243 i__3 = iwork[j + in] + iwoff;
1244 for (je = iwork[j] + 1 + iwoff; je <= i__3; ++je) {
1247 indexw[je] = je - iwoff;
1259 /* If RANGE='I', then (WL,WU) contains eigenvalues NWL+1,...,NWU */
1260 /* If NWL+1 < IL or NWU > IU, discard extra eigenvalues. */
1262 idiscl = *il - 1 - nwl;
1268 for (je = 1; je <= i__1; ++je) {
1269 /* Remove some of the smallest eigenvalues from the left so that */
1270 /* at the end IDISCL =0. Move all eigenvalues up to the left. */
1271 if (w[je] <= wlu && idiscl > 0) {
1276 werr[im] = werr[je];
1277 indexw[im] = indexw[je];
1278 iblock[im] = iblock[je];
1285 /* Remove some of the largest eigenvalues from the right so that */
1286 /* at the end IDISCU =0. Move all eigenvalues up to the left. */
1288 for (je = *m; je >= 1; --je) {
1289 if (w[je] >= wul && idiscu > 0) {
1294 werr[im] = werr[je];
1295 indexw[im] = indexw[je];
1296 iblock[im] = iblock[je];
1302 for (je = im; je <= i__1; ++je) {
1305 werr[jee] = werr[je];
1306 indexw[jee] = indexw[je];
1307 iblock[jee] = iblock[je];
1312 if (idiscl > 0 || idiscu > 0) {
1313 /* Code to deal with effects of bad arithmetic. (If N(w) is */
1314 /* monotone non-decreasing, this should never happen.) */
1315 /* Some low eigenvalues to be discarded are not in (WL,WLU], */
1316 /* or high eigenvalues to be discarded are not in (WUL,WU] */
1317 /* so just kill off the smallest IDISCL/largest IDISCU */
1318 /* eigenvalues, by marking the corresponding IBLOCK = 0 */
1322 for (jdisc = 1; jdisc <= i__1; ++jdisc) {
1325 for (je = 1; je <= i__2; ++je) {
1326 if (iblock[je] != 0 && (w[je] < wkill || iw == 0)) {
1339 for (jdisc = 1; jdisc <= i__1; ++jdisc) {
1342 for (je = 1; je <= i__2; ++je) {
1343 if (iblock[je] != 0 && (w[je] >= wkill || iw == 0)) {
1353 /* Now erase all eigenvalues with IBLOCK set to zero */
1356 for (je = 1; je <= i__1; ++je) {
1357 if (iblock[je] != 0) {
1360 werr[im] = werr[je];
1361 indexw[im] = indexw[je];
1362 iblock[im] = iblock[je];
1368 if (idiscl < 0 || idiscu < 0) {
1373 if (irange == 1 && *m != *n || irange == 3 && *m != *iu - *il + 1) {
1376 /* If ORDER='B', do nothing the eigenvalues are already sorted by */
1378 /* If ORDER='E', sort the eigenvalues from smallest to largest */
1379 if (lsame_(order, "E") && *nsplit > 1) {
1381 for (je = 1; je <= i__1; ++je) {
1385 for (j = je + 1; j <= i__2; ++j) {
1397 werr[ie] = werr[je];
1398 iblock[ie] = iblock[je];
1399 indexw[ie] = indexw[je];