00001 /* stbt03.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 /* Table of constant values */ 00017 00018 static integer c__1 = 1; 00019 00020 /* Subroutine */ int stbt03_(char *uplo, char *trans, char *diag, integer *n, 00021 integer *kd, integer *nrhs, real *ab, integer *ldab, real *scale, 00022 real *cnorm, real *tscal, real *x, integer *ldx, real *b, integer * 00023 ldb, real *work, real *resid) 00024 { 00025 /* System generated locals */ 00026 integer ab_dim1, ab_offset, b_dim1, b_offset, x_dim1, x_offset, i__1; 00027 real r__1, r__2, r__3; 00028 00029 /* Local variables */ 00030 integer j, ix; 00031 real eps, err; 00032 extern logical lsame_(char *, char *); 00033 extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *); 00034 real xscal; 00035 extern /* Subroutine */ int stbmv_(char *, char *, char *, integer *, 00036 integer *, real *, integer *, real *, integer *), scopy_(integer *, real *, integer *, real *, integer *); 00037 real tnorm, xnorm; 00038 extern /* Subroutine */ int saxpy_(integer *, real *, real *, integer *, 00039 real *, integer *), slabad_(real *, real *); 00040 extern doublereal slamch_(char *); 00041 real bignum; 00042 extern integer isamax_(integer *, real *, integer *); 00043 real smlnum; 00044 00045 00046 /* -- LAPACK test routine (version 3.1) -- */ 00047 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00048 /* November 2006 */ 00049 00050 /* .. Scalar Arguments .. */ 00051 /* .. */ 00052 /* .. Array Arguments .. */ 00053 /* .. */ 00054 00055 /* Purpose */ 00056 /* ======= */ 00057 00058 /* STBT03 computes the residual for the solution to a scaled triangular */ 00059 /* system of equations A*x = s*b or A'*x = s*b when A is a */ 00060 /* triangular band matrix. Here A' is the transpose of A, s is a scalar, */ 00061 /* and x and b are N by NRHS matrices. The test ratio is the maximum */ 00062 /* over the number of right hand sides of */ 00063 /* norm(s*b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), */ 00064 /* where op(A) denotes A or A' and EPS is the machine epsilon. */ 00065 00066 /* Arguments */ 00067 /* ========= */ 00068 00069 /* UPLO (input) CHARACTER*1 */ 00070 /* Specifies whether the matrix A is upper or lower triangular. */ 00071 /* = 'U': Upper triangular */ 00072 /* = 'L': Lower triangular */ 00073 00074 /* TRANS (input) CHARACTER*1 */ 00075 /* Specifies the operation applied to A. */ 00076 /* = 'N': A *x = b (No transpose) */ 00077 /* = 'T': A'*x = b (Transpose) */ 00078 /* = 'C': A'*x = b (Conjugate transpose = Transpose) */ 00079 00080 /* DIAG (input) CHARACTER*1 */ 00081 /* Specifies whether or not the matrix A is unit triangular. */ 00082 /* = 'N': Non-unit triangular */ 00083 /* = 'U': Unit triangular */ 00084 00085 /* N (input) INTEGER */ 00086 /* The order of the matrix A. N >= 0. */ 00087 00088 /* KD (input) INTEGER */ 00089 /* The number of superdiagonals or subdiagonals of the */ 00090 /* triangular band matrix A. KD >= 0. */ 00091 00092 /* NRHS (input) INTEGER */ 00093 /* The number of right hand sides, i.e., the number of columns */ 00094 /* of the matrices X and B. NRHS >= 0. */ 00095 00096 /* AB (input) REAL array, dimension (LDAB,N) */ 00097 /* The upper or lower triangular band matrix A, stored in the */ 00098 /* first kd+1 rows of the array. The j-th column of A is stored */ 00099 /* in the j-th column of the array AB as follows: */ 00100 /* if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */ 00101 /* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). */ 00102 00103 /* LDAB (input) INTEGER */ 00104 /* The leading dimension of the array AB. LDAB >= KD+1. */ 00105 00106 /* SCALE (input) REAL */ 00107 /* The scaling factor s used in solving the triangular system. */ 00108 00109 /* CNORM (input) REAL array, dimension (N) */ 00110 /* The 1-norms of the columns of A, not counting the diagonal. */ 00111 00112 /* TSCAL (input) REAL */ 00113 /* The scaling factor used in computing the 1-norms in CNORM. */ 00114 /* CNORM actually contains the column norms of TSCAL*A. */ 00115 00116 /* X (input) REAL array, dimension (LDX,NRHS) */ 00117 /* The computed solution vectors for the system of linear */ 00118 /* equations. */ 00119 00120 /* LDX (input) INTEGER */ 00121 /* The leading dimension of the array X. LDX >= max(1,N). */ 00122 00123 /* B (input) REAL array, dimension (LDB,NRHS) */ 00124 /* The right hand side vectors for the system of linear */ 00125 /* equations. */ 00126 00127 /* LDB (input) INTEGER */ 00128 /* The leading dimension of the array B. LDB >= max(1,N). */ 00129 00130 /* WORK (workspace) REAL array, dimension (N) */ 00131 00132 /* RESID (output) REAL */ 00133 /* The maximum over the number of right hand sides of */ 00134 /* norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). */ 00135 00136 /* ===================================================================== */ 00137 00138 /* .. Parameters .. */ 00139 /* .. */ 00140 /* .. Local Scalars .. */ 00141 /* .. */ 00142 /* .. External Functions .. */ 00143 /* .. */ 00144 /* .. External Subroutines .. */ 00145 /* .. */ 00146 /* .. Intrinsic Functions .. */ 00147 /* .. */ 00148 /* .. Executable Statements .. */ 00149 00150 /* Quick exit if N = 0 */ 00151 00152 /* Parameter adjustments */ 00153 ab_dim1 = *ldab; 00154 ab_offset = 1 + ab_dim1; 00155 ab -= ab_offset; 00156 --cnorm; 00157 x_dim1 = *ldx; 00158 x_offset = 1 + x_dim1; 00159 x -= x_offset; 00160 b_dim1 = *ldb; 00161 b_offset = 1 + b_dim1; 00162 b -= b_offset; 00163 --work; 00164 00165 /* Function Body */ 00166 if (*n <= 0 || *nrhs <= 0) { 00167 *resid = 0.f; 00168 return 0; 00169 } 00170 eps = slamch_("Epsilon"); 00171 smlnum = slamch_("Safe minimum"); 00172 bignum = 1.f / smlnum; 00173 slabad_(&smlnum, &bignum); 00174 00175 /* Compute the norm of the triangular matrix A using the column */ 00176 /* norms already computed by SLATBS. */ 00177 00178 tnorm = 0.f; 00179 if (lsame_(diag, "N")) { 00180 if (lsame_(uplo, "U")) { 00181 i__1 = *n; 00182 for (j = 1; j <= i__1; ++j) { 00183 /* Computing MAX */ 00184 r__2 = tnorm, r__3 = *tscal * (r__1 = ab[*kd + 1 + j * 00185 ab_dim1], dabs(r__1)) + cnorm[j]; 00186 tnorm = dmax(r__2,r__3); 00187 /* L10: */ 00188 } 00189 } else { 00190 i__1 = *n; 00191 for (j = 1; j <= i__1; ++j) { 00192 /* Computing MAX */ 00193 r__2 = tnorm, r__3 = *tscal * (r__1 = ab[j * ab_dim1 + 1], 00194 dabs(r__1)) + cnorm[j]; 00195 tnorm = dmax(r__2,r__3); 00196 /* L20: */ 00197 } 00198 } 00199 } else { 00200 i__1 = *n; 00201 for (j = 1; j <= i__1; ++j) { 00202 /* Computing MAX */ 00203 r__1 = tnorm, r__2 = *tscal + cnorm[j]; 00204 tnorm = dmax(r__1,r__2); 00205 /* L30: */ 00206 } 00207 } 00208 00209 /* Compute the maximum over the number of right hand sides of */ 00210 /* norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). */ 00211 00212 *resid = 0.f; 00213 i__1 = *nrhs; 00214 for (j = 1; j <= i__1; ++j) { 00215 scopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1); 00216 ix = isamax_(n, &work[1], &c__1); 00217 /* Computing MAX */ 00218 r__2 = 1.f, r__3 = (r__1 = x[ix + j * x_dim1], dabs(r__1)); 00219 xnorm = dmax(r__2,r__3); 00220 xscal = 1.f / xnorm / (real) (*kd + 1); 00221 sscal_(n, &xscal, &work[1], &c__1); 00222 stbmv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &work[1], & 00223 c__1); 00224 r__1 = -(*scale) * xscal; 00225 saxpy_(n, &r__1, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1); 00226 ix = isamax_(n, &work[1], &c__1); 00227 err = *tscal * (r__1 = work[ix], dabs(r__1)); 00228 ix = isamax_(n, &x[j * x_dim1 + 1], &c__1); 00229 xnorm = (r__1 = x[ix + j * x_dim1], dabs(r__1)); 00230 if (err * smlnum <= xnorm) { 00231 if (xnorm > 0.f) { 00232 err /= xnorm; 00233 } 00234 } else { 00235 if (err > 0.f) { 00236 err = 1.f / eps; 00237 } 00238 } 00239 if (err * smlnum <= tnorm) { 00240 if (tnorm > 0.f) { 00241 err /= tnorm; 00242 } 00243 } else { 00244 if (err > 0.f) { 00245 err = 1.f / eps; 00246 } 00247 } 00248 *resid = dmax(*resid,err); 00249 /* L40: */ 00250 } 00251 00252 return 0; 00253 00254 /* End of STBT03 */ 00255 00256 } /* stbt03_ */