3 /* Subroutine */ int dlagtf_(integer *n, doublereal *a, doublereal *lambda,
4 doublereal *b, doublereal *c__, doublereal *tol, doublereal *d__,
5 integer *in, integer *info)
7 /* System generated locals */
13 doublereal tl, eps, piv1, piv2, temp, mult, scale1, scale2;
14 extern doublereal dlamch_(char *);
15 extern /* Subroutine */ int xerbla_(char *, integer *);
18 /* -- LAPACK routine (version 3.1) -- */
19 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
22 /* .. Scalar Arguments .. */
24 /* .. Array Arguments .. */
30 /* DLAGTF factorizes the matrix (T - lambda*I), where T is an n by n */
31 /* tridiagonal matrix and lambda is a scalar, as */
33 /* T - lambda*I = PLU, */
35 /* where P is a permutation matrix, L is a unit lower tridiagonal matrix */
36 /* with at most one non-zero sub-diagonal elements per column and U is */
37 /* an upper triangular matrix with at most two non-zero super-diagonal */
38 /* elements per column. */
40 /* The factorization is obtained by Gaussian elimination with partial */
41 /* pivoting and implicit row scaling. */
43 /* The parameter LAMBDA is included in the routine so that DLAGTF may */
44 /* be used, in conjunction with DLAGTS, to obtain eigenvectors of T by */
45 /* inverse iteration. */
50 /* N (input) INTEGER */
51 /* The order of the matrix T. */
53 /* A (input/output) DOUBLE PRECISION array, dimension (N) */
54 /* On entry, A must contain the diagonal elements of T. */
56 /* On exit, A is overwritten by the n diagonal elements of the */
57 /* upper triangular matrix U of the factorization of T. */
59 /* LAMBDA (input) DOUBLE PRECISION */
60 /* On entry, the scalar lambda. */
62 /* B (input/output) DOUBLE PRECISION array, dimension (N-1) */
63 /* On entry, B must contain the (n-1) super-diagonal elements of */
66 /* On exit, B is overwritten by the (n-1) super-diagonal */
67 /* elements of the matrix U of the factorization of T. */
69 /* C (input/output) DOUBLE PRECISION array, dimension (N-1) */
70 /* On entry, C must contain the (n-1) sub-diagonal elements of */
73 /* On exit, C is overwritten by the (n-1) sub-diagonal elements */
74 /* of the matrix L of the factorization of T. */
76 /* TOL (input) DOUBLE PRECISION */
77 /* On entry, a relative tolerance used to indicate whether or */
78 /* not the matrix (T - lambda*I) is nearly singular. TOL should */
79 /* normally be chose as approximately the largest relative error */
80 /* in the elements of T. For example, if the elements of T are */
81 /* correct to about 4 significant figures, then TOL should be */
82 /* set to about 5*10**(-4). If TOL is supplied as less than eps, */
83 /* where eps is the relative machine precision, then the value */
84 /* eps is used in place of TOL. */
86 /* D (output) DOUBLE PRECISION array, dimension (N-2) */
87 /* On exit, D is overwritten by the (n-2) second super-diagonal */
88 /* elements of the matrix U of the factorization of T. */
90 /* IN (output) INTEGER array, dimension (N) */
91 /* On exit, IN contains details of the permutation matrix P. If */
92 /* an interchange occurred at the kth step of the elimination, */
93 /* then IN(k) = 1, otherwise IN(k) = 0. The element IN(n) */
94 /* returns the smallest positive integer j such that */
96 /* abs( u(j,j) ).le. norm( (T - lambda*I)(j) )*TOL, */
98 /* where norm( A(j) ) denotes the sum of the absolute values of */
99 /* the jth row of the matrix A. If no such j exists then IN(n) */
100 /* is returned as zero. If IN(n) is returned as positive, then a */
101 /* diagonal element of U is small, indicating that */
102 /* (T - lambda*I) is singular or nearly singular, */
104 /* INFO (output) INTEGER */
105 /* = 0 : successful exit */
106 /* .lt. 0: if INFO = -k, the kth argument had an illegal value */
108 /* ===================================================================== */
110 /* .. Parameters .. */
112 /* .. Local Scalars .. */
114 /* .. Intrinsic Functions .. */
116 /* .. External Functions .. */
118 /* .. External Subroutines .. */
120 /* .. Executable Statements .. */
122 /* Parameter adjustments */
134 xerbla_("DLAGTF", &i__1);
151 eps = dlamch_("Epsilon");
154 scale1 = abs(a[1]) + abs(b[1]);
156 for (k = 1; k <= i__1; ++k) {
158 scale2 = (d__1 = c__[k], abs(d__1)) + (d__2 = a[k + 1], abs(d__2));
160 scale2 += (d__1 = b[k + 1], abs(d__1));
165 piv1 = (d__1 = a[k], abs(d__1)) / scale1;
175 piv2 = (d__1 = c__[k], abs(d__1)) / scale2;
180 a[k + 1] -= c__[k] * b[k];
186 mult = a[k] / c__[k];
189 a[k + 1] = b[k] - mult * temp;
192 b[k + 1] = -mult * d__[k];
198 if (max(piv1,piv2) <= tl && in[*n] == 0) {
203 if ((d__1 = a[*n], abs(d__1)) <= scale1 * tl && in[*n] == 0) {