3 /* Subroutine */ int slagtf_(integer *n, real *a, real *lambda, real *b, real
4 *c__, real *tol, real *d__, integer *in, integer *info)
6 /* System generated locals */
12 real tl, eps, piv1, piv2, temp, mult, scale1, scale2;
13 extern doublereal slamch_(char *);
14 extern /* Subroutine */ int xerbla_(char *, integer *);
17 /* -- LAPACK routine (version 3.1) -- */
18 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
21 /* .. Scalar Arguments .. */
23 /* .. Array Arguments .. */
29 /* SLAGTF factorizes the matrix (T - lambda*I), where T is an n by n */
30 /* tridiagonal matrix and lambda is a scalar, as */
32 /* T - lambda*I = PLU, */
34 /* where P is a permutation matrix, L is a unit lower tridiagonal matrix */
35 /* with at most one non-zero sub-diagonal elements per column and U is */
36 /* an upper triangular matrix with at most two non-zero super-diagonal */
37 /* elements per column. */
39 /* The factorization is obtained by Gaussian elimination with partial */
40 /* pivoting and implicit row scaling. */
42 /* The parameter LAMBDA is included in the routine so that SLAGTF may */
43 /* be used, in conjunction with SLAGTS, to obtain eigenvectors of T by */
44 /* inverse iteration. */
49 /* N (input) INTEGER */
50 /* The order of the matrix T. */
52 /* A (input/output) REAL array, dimension (N) */
53 /* On entry, A must contain the diagonal elements of T. */
55 /* On exit, A is overwritten by the n diagonal elements of the */
56 /* upper triangular matrix U of the factorization of T. */
58 /* LAMBDA (input) REAL */
59 /* On entry, the scalar lambda. */
61 /* B (input/output) REAL array, dimension (N-1) */
62 /* On entry, B must contain the (n-1) super-diagonal elements of */
65 /* On exit, B is overwritten by the (n-1) super-diagonal */
66 /* elements of the matrix U of the factorization of T. */
68 /* C (input/output) REAL array, dimension (N-1) */
69 /* On entry, C must contain the (n-1) sub-diagonal elements of */
72 /* On exit, C is overwritten by the (n-1) sub-diagonal elements */
73 /* of the matrix L of the factorization of T. */
75 /* TOL (input) REAL */
76 /* On entry, a relative tolerance used to indicate whether or */
77 /* not the matrix (T - lambda*I) is nearly singular. TOL should */
78 /* normally be chose as approximately the largest relative error */
79 /* in the elements of T. For example, if the elements of T are */
80 /* correct to about 4 significant figures, then TOL should be */
81 /* set to about 5*10**(-4). If TOL is supplied as less than eps, */
82 /* where eps is the relative machine precision, then the value */
83 /* eps is used in place of TOL. */
85 /* D (output) REAL array, dimension (N-2) */
86 /* On exit, D is overwritten by the (n-2) second super-diagonal */
87 /* elements of the matrix U of the factorization of T. */
89 /* IN (output) INTEGER array, dimension (N) */
90 /* On exit, IN contains details of the permutation matrix P. If */
91 /* an interchange occurred at the kth step of the elimination, */
92 /* then IN(k) = 1, otherwise IN(k) = 0. The element IN(n) */
93 /* returns the smallest positive integer j such that */
95 /* abs( u(j,j) ).le. norm( (T - lambda*I)(j) )*TOL, */
97 /* where norm( A(j) ) denotes the sum of the absolute values of */
98 /* the jth row of the matrix A. If no such j exists then IN(n) */
99 /* is returned as zero. If IN(n) is returned as positive, then a */
100 /* diagonal element of U is small, indicating that */
101 /* (T - lambda*I) is singular or nearly singular, */
103 /* INFO (output) INTEGER */
104 /* = 0 : successful exit */
105 /* .lt. 0: if INFO = -k, the kth argument had an illegal value */
107 /* ===================================================================== */
109 /* .. Parameters .. */
111 /* .. Local Scalars .. */
113 /* .. Intrinsic Functions .. */
115 /* .. External Functions .. */
117 /* .. External Subroutines .. */
119 /* .. Executable Statements .. */
121 /* Parameter adjustments */
133 xerbla_("SLAGTF", &i__1);
150 eps = slamch_("Epsilon");
153 scale1 = dabs(a[1]) + dabs(b[1]);
155 for (k = 1; k <= i__1; ++k) {
157 scale2 = (r__1 = c__[k], dabs(r__1)) + (r__2 = a[k + 1], dabs(r__2));
159 scale2 += (r__1 = b[k + 1], dabs(r__1));
164 piv1 = (r__1 = a[k], dabs(r__1)) / scale1;
174 piv2 = (r__1 = c__[k], dabs(r__1)) / scale2;
179 a[k + 1] -= c__[k] * b[k];
185 mult = a[k] / c__[k];
188 a[k + 1] = b[k] - mult * temp;
191 b[k + 1] = -mult * d__[k];
197 if (dmax(piv1,piv2) <= tl && in[*n] == 0) {
202 if ((r__1 = a[*n], dabs(r__1)) <= scale1 * tl && in[*n] == 0) {