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