00001 /* dtbt02.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 static doublereal c_b10 = -1.; 00020 00021 /* Subroutine */ int dtbt02_(char *uplo, char *trans, char *diag, integer *n, 00022 integer *kd, integer *nrhs, doublereal *ab, integer *ldab, doublereal 00023 *x, integer *ldx, doublereal *b, integer *ldb, doublereal *work, 00024 doublereal *resid) 00025 { 00026 /* System generated locals */ 00027 integer ab_dim1, ab_offset, b_dim1, b_offset, x_dim1, x_offset, i__1; 00028 doublereal d__1, d__2; 00029 00030 /* Local variables */ 00031 integer j; 00032 doublereal eps; 00033 extern logical lsame_(char *, char *); 00034 extern doublereal dasum_(integer *, doublereal *, integer *); 00035 doublereal anorm, bnorm; 00036 extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, 00037 doublereal *, integer *), dtbmv_(char *, char *, char *, integer * 00038 , integer *, doublereal *, integer *, doublereal *, integer *), daxpy_(integer *, doublereal *, 00039 doublereal *, integer *, doublereal *, integer *); 00040 doublereal xnorm; 00041 extern doublereal dlamch_(char *), dlantb_(char *, char *, char *, 00042 integer *, integer *, doublereal *, integer *, doublereal *); 00043 00044 00045 /* -- LAPACK test routine (version 3.1) -- */ 00046 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00047 /* November 2006 */ 00048 00049 /* .. Scalar Arguments .. */ 00050 /* .. */ 00051 /* .. Array Arguments .. */ 00052 /* .. */ 00053 00054 /* Purpose */ 00055 /* ======= */ 00056 00057 /* DTBT02 computes the residual for the computed solution to a */ 00058 /* triangular system of linear equations A*x = b or A' *x = b when */ 00059 /* A is a triangular band matrix. Here A' is the transpose of A and */ 00060 /* x and b are N by NRHS matrices. The test ratio is the maximum over */ 00061 /* the number of right hand sides of */ 00062 /* norm(b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), */ 00063 /* where op(A) denotes A or A' and EPS is the machine epsilon. */ 00064 00065 /* Arguments */ 00066 /* ========= */ 00067 00068 /* UPLO (input) CHARACTER*1 */ 00069 /* Specifies whether the matrix A is upper or lower triangular. */ 00070 /* = 'U': Upper triangular */ 00071 /* = 'L': Lower triangular */ 00072 00073 /* TRANS (input) CHARACTER*1 */ 00074 /* Specifies the operation applied to A. */ 00075 /* = 'N': A *x = b (No transpose) */ 00076 /* = 'T': A'*x = b (Transpose) */ 00077 /* = 'C': A'*x = b (Conjugate transpose = Transpose) */ 00078 00079 /* DIAG (input) CHARACTER*1 */ 00080 /* Specifies whether or not the matrix A is unit triangular. */ 00081 /* = 'N': Non-unit triangular */ 00082 /* = 'U': Unit triangular */ 00083 00084 /* N (input) INTEGER */ 00085 /* The order of the matrix A. N >= 0. */ 00086 00087 /* KD (input) INTEGER */ 00088 /* The number of superdiagonals or subdiagonals of the */ 00089 /* triangular band matrix A. KD >= 0. */ 00090 00091 /* NRHS (input) INTEGER */ 00092 /* The number of right hand sides, i.e., the number of columns */ 00093 /* of the matrices X and B. NRHS >= 0. */ 00094 00095 /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */ 00096 /* The upper or lower triangular band matrix A, stored in the */ 00097 /* first kd+1 rows of the array. The j-th column of A is stored */ 00098 /* in the j-th column of the array AB as follows: */ 00099 /* if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */ 00100 /* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). */ 00101 00102 /* LDAB (input) INTEGER */ 00103 /* The leading dimension of the array AB. LDAB >= KD+1. */ 00104 00105 /* X (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */ 00106 /* The computed solution vectors for the system of linear */ 00107 /* equations. */ 00108 00109 /* LDX (input) INTEGER */ 00110 /* The leading dimension of the array X. LDX >= max(1,N). */ 00111 00112 /* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */ 00113 /* The right hand side vectors for the system of linear */ 00114 /* equations. */ 00115 00116 /* LDB (input) INTEGER */ 00117 /* The leading dimension of the array B. LDB >= max(1,N). */ 00118 00119 /* WORK (workspace) DOUBLE PRECISION array, dimension (N) */ 00120 00121 /* RESID (output) DOUBLE PRECISION */ 00122 /* The maximum over the number of right hand sides of */ 00123 /* norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */ 00124 00125 /* ===================================================================== */ 00126 00127 /* .. Parameters .. */ 00128 /* .. */ 00129 /* .. Local Scalars .. */ 00130 /* .. */ 00131 /* .. External Functions .. */ 00132 /* .. */ 00133 /* .. External Subroutines .. */ 00134 /* .. */ 00135 /* .. Intrinsic Functions .. */ 00136 /* .. */ 00137 /* .. Executable Statements .. */ 00138 00139 /* Quick exit if N = 0 or NRHS = 0 */ 00140 00141 /* Parameter adjustments */ 00142 ab_dim1 = *ldab; 00143 ab_offset = 1 + ab_dim1; 00144 ab -= ab_offset; 00145 x_dim1 = *ldx; 00146 x_offset = 1 + x_dim1; 00147 x -= x_offset; 00148 b_dim1 = *ldb; 00149 b_offset = 1 + b_dim1; 00150 b -= b_offset; 00151 --work; 00152 00153 /* Function Body */ 00154 if (*n <= 0 || *nrhs <= 0) { 00155 *resid = 0.; 00156 return 0; 00157 } 00158 00159 /* Compute the 1-norm of A or A'. */ 00160 00161 if (lsame_(trans, "N")) { 00162 anorm = dlantb_("1", uplo, diag, n, kd, &ab[ab_offset], ldab, &work[1] 00163 ); 00164 } else { 00165 anorm = dlantb_("I", uplo, diag, n, kd, &ab[ab_offset], ldab, &work[1] 00166 ); 00167 } 00168 00169 /* Exit with RESID = 1/EPS if ANORM = 0. */ 00170 00171 eps = dlamch_("Epsilon"); 00172 if (anorm <= 0.) { 00173 *resid = 1. / eps; 00174 return 0; 00175 } 00176 00177 /* Compute the maximum over the number of right hand sides of */ 00178 /* norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */ 00179 00180 *resid = 0.; 00181 i__1 = *nrhs; 00182 for (j = 1; j <= i__1; ++j) { 00183 dcopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1); 00184 dtbmv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &work[1], & 00185 c__1); 00186 daxpy_(n, &c_b10, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1); 00187 bnorm = dasum_(n, &work[1], &c__1); 00188 xnorm = dasum_(n, &x[j * x_dim1 + 1], &c__1); 00189 if (xnorm <= 0.) { 00190 *resid = 1. / eps; 00191 } else { 00192 /* Computing MAX */ 00193 d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps; 00194 *resid = max(d__1,d__2); 00195 } 00196 /* L10: */ 00197 } 00198 00199 return 0; 00200 00201 /* End of DTBT02 */ 00202 00203 } /* dtbt02_ */