3 /* Subroutine */ int slagts_(integer *job, integer *n, real *a, real *b, real
4 *c__, real *d__, integer *in, real *y, real *tol, integer *info)
6 /* System generated locals */
8 real r__1, r__2, r__3, r__4, r__5;
10 /* Builtin functions */
11 double r_sign(real *, real *);
15 real ak, eps, temp, pert, absak, sfmin;
16 extern doublereal slamch_(char *);
17 extern /* Subroutine */ int xerbla_(char *, integer *);
21 /* -- LAPACK auxiliary routine (version 3.1) -- */
22 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
25 /* .. Scalar Arguments .. */
27 /* .. Array Arguments .. */
33 /* SLAGTS may be used to solve one of the systems of equations */
35 /* (T - lambda*I)*x = y or (T - lambda*I)'*x = y, */
37 /* where T is an n by n tridiagonal matrix, for x, following the */
38 /* factorization of (T - lambda*I) as */
40 /* (T - lambda*I) = P*L*U , */
42 /* by routine SLAGTF. The choice of equation to be solved is */
43 /* controlled by the argument JOB, and in each case there is an option */
44 /* to perturb zero or very small diagonal elements of U, this option */
45 /* being intended for use in applications such as inverse iteration. */
50 /* JOB (input) INTEGER */
51 /* Specifies the job to be performed by SLAGTS as follows: */
52 /* = 1: The equations (T - lambda*I)x = y are to be solved, */
53 /* but diagonal elements of U are not to be perturbed. */
54 /* = -1: The equations (T - lambda*I)x = y are to be solved */
55 /* and, if overflow would otherwise occur, the diagonal */
56 /* elements of U are to be perturbed. See argument TOL */
58 /* = 2: The equations (T - lambda*I)'x = y are to be solved, */
59 /* but diagonal elements of U are not to be perturbed. */
60 /* = -2: The equations (T - lambda*I)'x = y are to be solved */
61 /* and, if overflow would otherwise occur, the diagonal */
62 /* elements of U are to be perturbed. See argument TOL */
65 /* N (input) INTEGER */
66 /* The order of the matrix T. */
68 /* A (input) REAL array, dimension (N) */
69 /* On entry, A must contain the diagonal elements of U as */
70 /* returned from SLAGTF. */
72 /* B (input) REAL array, dimension (N-1) */
73 /* On entry, B must contain the first super-diagonal elements of */
74 /* U as returned from SLAGTF. */
76 /* C (input) REAL array, dimension (N-1) */
77 /* On entry, C must contain the sub-diagonal elements of L as */
78 /* returned from SLAGTF. */
80 /* D (input) REAL array, dimension (N-2) */
81 /* On entry, D must contain the second super-diagonal elements */
82 /* of U as returned from SLAGTF. */
84 /* IN (input) INTEGER array, dimension (N) */
85 /* On entry, IN must contain details of the matrix P as returned */
88 /* Y (input/output) REAL array, dimension (N) */
89 /* On entry, the right hand side vector y. */
90 /* On exit, Y is overwritten by the solution vector x. */
92 /* TOL (input/output) REAL */
93 /* On entry, with JOB .lt. 0, TOL should be the minimum */
94 /* perturbation to be made to very small diagonal elements of U. */
95 /* TOL should normally be chosen as about eps*norm(U), where eps */
96 /* is the relative machine precision, but if TOL is supplied as */
97 /* non-positive, then it is reset to eps*max( abs( u(i,j) ) ). */
98 /* If JOB .gt. 0 then TOL is not referenced. */
100 /* On exit, TOL is changed as described above, only if TOL is */
101 /* non-positive on entry. Otherwise TOL is unchanged. */
103 /* INFO (output) INTEGER */
104 /* = 0 : successful exit */
105 /* .lt. 0: if INFO = -i, the i-th argument had an illegal value */
106 /* .gt. 0: overflow would occur when computing the INFO(th) */
107 /* element of the solution vector x. This can only occur */
108 /* when JOB is supplied as positive and either means */
109 /* that a diagonal element of U is very small, or that */
110 /* the elements of the right-hand side vector y are very */
113 /* ===================================================================== */
115 /* .. Parameters .. */
117 /* .. Local Scalars .. */
119 /* .. Intrinsic Functions .. */
121 /* .. External Functions .. */
123 /* .. External Subroutines .. */
125 /* .. Executable Statements .. */
127 /* Parameter adjustments */
137 if (abs(*job) > 2 || *job == 0) {
144 xerbla_("SLAGTS", &i__1);
152 eps = slamch_("Epsilon");
153 sfmin = slamch_("Safe minimum");
154 bignum = 1.f / sfmin;
161 r__1 = *tol, r__2 = dabs(a[2]), r__1 = max(r__1,r__2), r__2 =
163 *tol = dmax(r__1,r__2);
166 for (k = 3; k <= i__1; ++k) {
168 r__4 = *tol, r__5 = (r__1 = a[k], dabs(r__1)), r__4 = max(
169 r__4,r__5), r__5 = (r__2 = b[k - 1], dabs(r__2)),
170 r__4 = max(r__4,r__5), r__5 = (r__3 = d__[k - 2],
172 *tol = dmax(r__4,r__5);
182 if (abs(*job) == 1) {
184 for (k = 2; k <= i__1; ++k) {
185 if (in[k - 1] == 0) {
186 y[k] -= c__[k - 1] * y[k - 1];
190 y[k] = temp - c__[k - 1] * y[k];
195 for (k = *n; k >= 1; --k) {
197 temp = y[k] - b[k] * y[k + 1] - d__[k] * y[k + 2];
198 } else if (k == *n - 1) {
199 temp = y[k] - b[k] * y[k + 1];
207 if (absak == 0.f || dabs(temp) * sfmin > absak) {
214 } else if (dabs(temp) > absak * bignum) {
223 for (k = *n; k >= 1; --k) {
225 temp = y[k] - b[k] * y[k + 1] - d__[k] * y[k + 2];
226 } else if (k == *n - 1) {
227 temp = y[k] - b[k] * y[k + 1];
232 pert = r_sign(tol, &ak);
237 if (absak == 0.f || dabs(temp) * sfmin > absak) {
245 } else if (dabs(temp) > absak * bignum) {
257 /* Come to here if JOB = 2 or -2 */
261 for (k = 1; k <= i__1; ++k) {
263 temp = y[k] - b[k - 1] * y[k - 1] - d__[k - 2] * y[k - 2];
265 temp = y[k] - b[k - 1] * y[k - 1];
273 if (absak == 0.f || dabs(temp) * sfmin > absak) {
280 } else if (dabs(temp) > absak * bignum) {
290 for (k = 1; k <= i__1; ++k) {
292 temp = y[k] - b[k - 1] * y[k - 1] - d__[k - 2] * y[k - 2];
294 temp = y[k] - b[k - 1] * y[k - 1];
299 pert = r_sign(tol, &ak);
304 if (absak == 0.f || dabs(temp) * sfmin > absak) {
312 } else if (dabs(temp) > absak * bignum) {
323 for (k = *n; k >= 2; --k) {
324 if (in[k - 1] == 0) {
325 y[k - 1] -= c__[k - 1] * y[k];
329 y[k] = temp - c__[k - 1] * y[k];