00001 /* strt03.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 strt03_(char *uplo, char *trans, char *diag, integer *n, 00021 integer *nrhs, real *a, integer *lda, real *scale, real *cnorm, real * 00022 tscal, real *x, integer *ldx, real *b, integer *ldb, real *work, real 00023 *resid) 00024 { 00025 /* System generated locals */ 00026 integer a_dim1, a_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 scopy_(integer *, real *, integer *, real *, 00036 integer *); 00037 real tnorm, xnorm; 00038 extern /* Subroutine */ int saxpy_(integer *, real *, real *, integer *, 00039 real *, integer *), strmv_(char *, char *, char *, integer *, 00040 real *, integer *, real *, integer *), 00041 slabad_(real *, real *); 00042 extern doublereal slamch_(char *); 00043 real bignum; 00044 extern integer isamax_(integer *, real *, integer *); 00045 real smlnum; 00046 00047 00048 /* -- LAPACK test routine (version 3.1) -- */ 00049 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00050 /* November 2006 */ 00051 00052 /* .. Scalar Arguments .. */ 00053 /* .. */ 00054 /* .. Array Arguments .. */ 00055 /* .. */ 00056 00057 /* Purpose */ 00058 /* ======= */ 00059 00060 /* STRT03 computes the residual for the solution to a scaled triangular */ 00061 /* system of equations A*x = s*b or A'*x = s*b. */ 00062 /* Here A is a triangular matrix, A' is the transpose of A, s is a */ 00063 /* scalar, and x and b are N by NRHS matrices. The test ratio is the */ 00064 /* maximum over the number of right hand sides of */ 00065 /* norm(s*b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), */ 00066 /* where op(A) denotes A or A' and EPS is the machine epsilon. */ 00067 00068 /* Arguments */ 00069 /* ========= */ 00070 00071 /* UPLO (input) CHARACTER*1 */ 00072 /* Specifies whether the matrix A is upper or lower triangular. */ 00073 /* = 'U': Upper triangular */ 00074 /* = 'L': Lower triangular */ 00075 00076 /* TRANS (input) CHARACTER*1 */ 00077 /* Specifies the operation applied to A. */ 00078 /* = 'N': A *x = s*b (No transpose) */ 00079 /* = 'T': A'*x = s*b (Transpose) */ 00080 /* = 'C': A'*x = s*b (Conjugate transpose = Transpose) */ 00081 00082 /* DIAG (input) CHARACTER*1 */ 00083 /* Specifies whether or not the matrix A is unit triangular. */ 00084 /* = 'N': Non-unit triangular */ 00085 /* = 'U': Unit triangular */ 00086 00087 /* N (input) INTEGER */ 00088 /* The order of the matrix A. N >= 0. */ 00089 00090 /* NRHS (input) INTEGER */ 00091 /* The number of right hand sides, i.e., the number of columns */ 00092 /* of the matrices X and B. NRHS >= 0. */ 00093 00094 /* A (input) REAL array, dimension (LDA,N) */ 00095 /* The triangular matrix A. If UPLO = 'U', the leading n by n */ 00096 /* upper triangular part of the array A contains the upper */ 00097 /* triangular matrix, and the strictly lower triangular part of */ 00098 /* A is not referenced. If UPLO = 'L', the leading n by n lower */ 00099 /* triangular part of the array A contains the lower triangular */ 00100 /* matrix, and the strictly upper triangular part of A is not */ 00101 /* referenced. If DIAG = 'U', the diagonal elements of A are */ 00102 /* also not referenced and are assumed to be 1. */ 00103 00104 /* LDA (input) INTEGER */ 00105 /* The leading dimension of the array A. LDA >= max(1,N). */ 00106 00107 /* SCALE (input) REAL */ 00108 /* The scaling factor s used in solving the triangular system. */ 00109 00110 /* CNORM (input) REAL array, dimension (N) */ 00111 /* The 1-norms of the columns of A, not counting the diagonal. */ 00112 00113 /* TSCAL (input) REAL */ 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) REAL 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) REAL 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) REAL array, dimension (N) */ 00132 00133 /* RESID (output) REAL */ 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 a_dim1 = *lda; 00155 a_offset = 1 + a_dim1; 00156 a -= a_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.f; 00169 return 0; 00170 } 00171 eps = slamch_("Epsilon"); 00172 smlnum = slamch_("Safe minimum"); 00173 bignum = 1.f / smlnum; 00174 slabad_(&smlnum, &bignum); 00175 00176 /* Compute the norm of the triangular matrix A using the column */ 00177 /* norms already computed by SLATRS. */ 00178 00179 tnorm = 0.f; 00180 if (lsame_(diag, "N")) { 00181 i__1 = *n; 00182 for (j = 1; j <= i__1; ++j) { 00183 /* Computing MAX */ 00184 r__2 = tnorm, r__3 = *tscal * (r__1 = a[j + j * a_dim1], dabs( 00185 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__1 = tnorm, r__2 = *tscal + cnorm[j]; 00194 tnorm = dmax(r__1,r__2); 00195 /* L20: */ 00196 } 00197 } 00198 00199 /* Compute the maximum over the number of right hand sides of */ 00200 /* norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). */ 00201 00202 *resid = 0.f; 00203 i__1 = *nrhs; 00204 for (j = 1; j <= i__1; ++j) { 00205 scopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1); 00206 ix = isamax_(n, &work[1], &c__1); 00207 /* Computing MAX */ 00208 r__2 = 1.f, r__3 = (r__1 = x[ix + j * x_dim1], dabs(r__1)); 00209 xnorm = dmax(r__2,r__3); 00210 xscal = 1.f / xnorm / (real) (*n); 00211 sscal_(n, &xscal, &work[1], &c__1); 00212 strmv_(uplo, trans, diag, n, &a[a_offset], lda, &work[1], &c__1); 00213 r__1 = -(*scale) * xscal; 00214 saxpy_(n, &r__1, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1); 00215 ix = isamax_(n, &work[1], &c__1); 00216 err = *tscal * (r__1 = work[ix], dabs(r__1)); 00217 ix = isamax_(n, &x[j * x_dim1 + 1], &c__1); 00218 xnorm = (r__1 = x[ix + j * x_dim1], dabs(r__1)); 00219 if (err * smlnum <= xnorm) { 00220 if (xnorm > 0.f) { 00221 err /= xnorm; 00222 } 00223 } else { 00224 if (err > 0.f) { 00225 err = 1.f / eps; 00226 } 00227 } 00228 if (err * smlnum <= tnorm) { 00229 if (tnorm > 0.f) { 00230 err /= tnorm; 00231 } 00232 } else { 00233 if (err > 0.f) { 00234 err = 1.f / eps; 00235 } 00236 } 00237 *resid = dmax(*resid,err); 00238 /* L30: */ 00239 } 00240 00241 return 0; 00242 00243 /* End of STRT03 */ 00244 00245 } /* strt03_ */