00001 /* dlagtf.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Subroutine */ int dlagtf_(integer *n, doublereal *a, doublereal *lambda, 00017 doublereal *b, doublereal *c__, doublereal *tol, doublereal *d__, 00018 integer *in, integer *info) 00019 { 00020 /* System generated locals */ 00021 integer i__1; 00022 doublereal d__1, d__2; 00023 00024 /* Local variables */ 00025 integer k; 00026 doublereal tl, eps, piv1, piv2, temp, mult, scale1, scale2; 00027 extern doublereal dlamch_(char *); 00028 extern /* Subroutine */ int xerbla_(char *, integer *); 00029 00030 00031 /* -- LAPACK routine (version 3.2) -- */ 00032 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00033 /* November 2006 */ 00034 00035 /* .. Scalar Arguments .. */ 00036 /* .. */ 00037 /* .. Array Arguments .. */ 00038 /* .. */ 00039 00040 /* Purpose */ 00041 /* ======= */ 00042 00043 /* DLAGTF factorizes the matrix (T - lambda*I), where T is an n by n */ 00044 /* tridiagonal matrix and lambda is a scalar, as */ 00045 00046 /* T - lambda*I = PLU, */ 00047 00048 /* where P is a permutation matrix, L is a unit lower tridiagonal matrix */ 00049 /* with at most one non-zero sub-diagonal elements per column and U is */ 00050 /* an upper triangular matrix with at most two non-zero super-diagonal */ 00051 /* elements per column. */ 00052 00053 /* The factorization is obtained by Gaussian elimination with partial */ 00054 /* pivoting and implicit row scaling. */ 00055 00056 /* The parameter LAMBDA is included in the routine so that DLAGTF may */ 00057 /* be used, in conjunction with DLAGTS, to obtain eigenvectors of T by */ 00058 /* inverse iteration. */ 00059 00060 /* Arguments */ 00061 /* ========= */ 00062 00063 /* N (input) INTEGER */ 00064 /* The order of the matrix T. */ 00065 00066 /* A (input/output) DOUBLE PRECISION array, dimension (N) */ 00067 /* On entry, A must contain the diagonal elements of T. */ 00068 00069 /* On exit, A is overwritten by the n diagonal elements of the */ 00070 /* upper triangular matrix U of the factorization of T. */ 00071 00072 /* LAMBDA (input) DOUBLE PRECISION */ 00073 /* On entry, the scalar lambda. */ 00074 00075 /* B (input/output) DOUBLE PRECISION array, dimension (N-1) */ 00076 /* On entry, B must contain the (n-1) super-diagonal elements of */ 00077 /* T. */ 00078 00079 /* On exit, B is overwritten by the (n-1) super-diagonal */ 00080 /* elements of the matrix U of the factorization of T. */ 00081 00082 /* C (input/output) DOUBLE PRECISION array, dimension (N-1) */ 00083 /* On entry, C must contain the (n-1) sub-diagonal elements of */ 00084 /* T. */ 00085 00086 /* On exit, C is overwritten by the (n-1) sub-diagonal elements */ 00087 /* of the matrix L of the factorization of T. */ 00088 00089 /* TOL (input) DOUBLE PRECISION */ 00090 /* On entry, a relative tolerance used to indicate whether or */ 00091 /* not the matrix (T - lambda*I) is nearly singular. TOL should */ 00092 /* normally be chose as approximately the largest relative error */ 00093 /* in the elements of T. For example, if the elements of T are */ 00094 /* correct to about 4 significant figures, then TOL should be */ 00095 /* set to about 5*10**(-4). If TOL is supplied as less than eps, */ 00096 /* where eps is the relative machine precision, then the value */ 00097 /* eps is used in place of TOL. */ 00098 00099 /* D (output) DOUBLE PRECISION array, dimension (N-2) */ 00100 /* On exit, D is overwritten by the (n-2) second super-diagonal */ 00101 /* elements of the matrix U of the factorization of T. */ 00102 00103 /* IN (output) INTEGER array, dimension (N) */ 00104 /* On exit, IN contains details of the permutation matrix P. If */ 00105 /* an interchange occurred at the kth step of the elimination, */ 00106 /* then IN(k) = 1, otherwise IN(k) = 0. The element IN(n) */ 00107 /* returns the smallest positive integer j such that */ 00108 00109 /* abs( u(j,j) ).le. norm( (T - lambda*I)(j) )*TOL, */ 00110 00111 /* where norm( A(j) ) denotes the sum of the absolute values of */ 00112 /* the jth row of the matrix A. If no such j exists then IN(n) */ 00113 /* is returned as zero. If IN(n) is returned as positive, then a */ 00114 /* diagonal element of U is small, indicating that */ 00115 /* (T - lambda*I) is singular or nearly singular, */ 00116 00117 /* INFO (output) INTEGER */ 00118 /* = 0 : successful exit */ 00119 /* .lt. 0: if INFO = -k, the kth argument had an illegal value */ 00120 00121 /* ===================================================================== */ 00122 00123 /* .. Parameters .. */ 00124 /* .. */ 00125 /* .. Local Scalars .. */ 00126 /* .. */ 00127 /* .. Intrinsic Functions .. */ 00128 /* .. */ 00129 /* .. External Functions .. */ 00130 /* .. */ 00131 /* .. External Subroutines .. */ 00132 /* .. */ 00133 /* .. Executable Statements .. */ 00134 00135 /* Parameter adjustments */ 00136 --in; 00137 --d__; 00138 --c__; 00139 --b; 00140 --a; 00141 00142 /* Function Body */ 00143 *info = 0; 00144 if (*n < 0) { 00145 *info = -1; 00146 i__1 = -(*info); 00147 xerbla_("DLAGTF", &i__1); 00148 return 0; 00149 } 00150 00151 if (*n == 0) { 00152 return 0; 00153 } 00154 00155 a[1] -= *lambda; 00156 in[*n] = 0; 00157 if (*n == 1) { 00158 if (a[1] == 0.) { 00159 in[1] = 1; 00160 } 00161 return 0; 00162 } 00163 00164 eps = dlamch_("Epsilon"); 00165 00166 tl = max(*tol,eps); 00167 scale1 = abs(a[1]) + abs(b[1]); 00168 i__1 = *n - 1; 00169 for (k = 1; k <= i__1; ++k) { 00170 a[k + 1] -= *lambda; 00171 scale2 = (d__1 = c__[k], abs(d__1)) + (d__2 = a[k + 1], abs(d__2)); 00172 if (k < *n - 1) { 00173 scale2 += (d__1 = b[k + 1], abs(d__1)); 00174 } 00175 if (a[k] == 0.) { 00176 piv1 = 0.; 00177 } else { 00178 piv1 = (d__1 = a[k], abs(d__1)) / scale1; 00179 } 00180 if (c__[k] == 0.) { 00181 in[k] = 0; 00182 piv2 = 0.; 00183 scale1 = scale2; 00184 if (k < *n - 1) { 00185 d__[k] = 0.; 00186 } 00187 } else { 00188 piv2 = (d__1 = c__[k], abs(d__1)) / scale2; 00189 if (piv2 <= piv1) { 00190 in[k] = 0; 00191 scale1 = scale2; 00192 c__[k] /= a[k]; 00193 a[k + 1] -= c__[k] * b[k]; 00194 if (k < *n - 1) { 00195 d__[k] = 0.; 00196 } 00197 } else { 00198 in[k] = 1; 00199 mult = a[k] / c__[k]; 00200 a[k] = c__[k]; 00201 temp = a[k + 1]; 00202 a[k + 1] = b[k] - mult * temp; 00203 if (k < *n - 1) { 00204 d__[k] = b[k + 1]; 00205 b[k + 1] = -mult * d__[k]; 00206 } 00207 b[k] = temp; 00208 c__[k] = mult; 00209 } 00210 } 00211 if (max(piv1,piv2) <= tl && in[*n] == 0) { 00212 in[*n] = k; 00213 } 00214 /* L10: */ 00215 } 00216 if ((d__1 = a[*n], abs(d__1)) <= scale1 * tl && in[*n] == 0) { 00217 in[*n] = *n; 00218 } 00219 00220 return 0; 00221 00222 /* End of DLAGTF */ 00223 00224 } /* dlagtf_ */