00001 /* dget08.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 doublereal c_b7 = -1.; 00019 static doublereal c_b8 = 1.; 00020 static integer c__1 = 1; 00021 00022 /* Subroutine */ int dget08_(char *trans, integer *m, integer *n, integer * 00023 nrhs, doublereal *a, integer *lda, doublereal *x, integer *ldx, 00024 doublereal *b, integer *ldb, doublereal *rwork, doublereal *resid) 00025 { 00026 /* System generated locals */ 00027 integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, i__1; 00028 doublereal d__1, d__2; 00029 00030 /* Local variables */ 00031 integer j, n1, n2; 00032 doublereal eps; 00033 extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, 00034 integer *, doublereal *, doublereal *, integer *, doublereal *, 00035 integer *, doublereal *, doublereal *, integer *); 00036 extern logical lsame_(char *, char *); 00037 doublereal anorm, bnorm, xnorm; 00038 extern doublereal dlamch_(char *), dlange_(char *, integer *, 00039 integer *, doublereal *, integer *, doublereal *); 00040 extern integer idamax_(integer *, doublereal *, integer *); 00041 00042 00043 /* -- LAPACK test routine (version 3.1) -- */ 00044 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00045 /* November 2006 */ 00046 00047 /* .. Scalar Arguments .. */ 00048 /* .. */ 00049 /* .. Array Arguments .. */ 00050 /* .. */ 00051 00052 /* Purpose */ 00053 /* ======= */ 00054 00055 /* DGET02 computes the residual for a solution of a system of linear */ 00056 /* equations A*x = b or A'*x = b: */ 00057 /* RESID = norm(B - A*X,inf) / ( norm(A,inf) * norm(X,inf) * EPS ), */ 00058 /* where EPS is the machine epsilon. */ 00059 00060 /* Arguments */ 00061 /* ========= */ 00062 00063 /* TRANS (input) CHARACTER*1 */ 00064 /* Specifies the form of the system of equations: */ 00065 /* = 'N': A *x = b */ 00066 /* = 'T': A'*x = b, where A' is the transpose of A */ 00067 /* = 'C': A'*x = b, where A' is the transpose of A */ 00068 00069 /* M (input) INTEGER */ 00070 /* The number of rows of the matrix A. M >= 0. */ 00071 00072 /* N (input) INTEGER */ 00073 /* The number of columns of the matrix A. N >= 0. */ 00074 00075 /* NRHS (input) INTEGER */ 00076 /* The number of columns of B, the matrix of right hand sides. */ 00077 /* NRHS >= 0. */ 00078 00079 /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ 00080 /* The original M x N matrix A. */ 00081 00082 /* LDA (input) INTEGER */ 00083 /* The leading dimension of the array A. LDA >= max(1,M). */ 00084 00085 /* X (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */ 00086 /* The computed solution vectors for the system of linear */ 00087 /* equations. */ 00088 00089 /* LDX (input) INTEGER */ 00090 /* The leading dimension of the array X. If TRANS = 'N', */ 00091 /* LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M). */ 00092 00093 /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ 00094 /* On entry, the right hand side vectors for the system of */ 00095 /* linear equations. */ 00096 /* On exit, B is overwritten with the difference B - A*X. */ 00097 00098 /* LDB (input) INTEGER */ 00099 /* The leading dimension of the array B. IF TRANS = 'N', */ 00100 /* LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N). */ 00101 00102 /* RWORK (workspace) DOUBLE PRECISION array, dimension (M) */ 00103 00104 /* RESID (output) DOUBLE PRECISION */ 00105 /* The maximum over the number of right hand sides of */ 00106 /* norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */ 00107 00108 /* ===================================================================== */ 00109 00110 /* .. Parameters .. */ 00111 /* .. */ 00112 /* .. Local Scalars .. */ 00113 /* .. */ 00114 /* .. External Functions .. */ 00115 /* .. */ 00116 /* .. External Subroutines .. */ 00117 /* .. */ 00118 /* .. Intrinsic Functions .. */ 00119 /* .. */ 00120 /* .. Executable Statements .. */ 00121 00122 /* Quick exit if M = 0 or N = 0 or NRHS = 0 */ 00123 00124 /* Parameter adjustments */ 00125 a_dim1 = *lda; 00126 a_offset = 1 + a_dim1; 00127 a -= a_offset; 00128 x_dim1 = *ldx; 00129 x_offset = 1 + x_dim1; 00130 x -= x_offset; 00131 b_dim1 = *ldb; 00132 b_offset = 1 + b_dim1; 00133 b -= b_offset; 00134 --rwork; 00135 00136 /* Function Body */ 00137 if (*m <= 0 || *n <= 0 || *nrhs == 0) { 00138 *resid = 0.; 00139 return 0; 00140 } 00141 00142 if (lsame_(trans, "T") || lsame_(trans, "C")) { 00143 n1 = *n; 00144 n2 = *m; 00145 } else { 00146 n1 = *m; 00147 n2 = *n; 00148 } 00149 00150 /* Exit with RESID = 1/EPS if ANORM = 0. */ 00151 00152 eps = dlamch_("Epsilon"); 00153 anorm = dlange_("I", &n1, &n2, &a[a_offset], lda, &rwork[1]); 00154 if (anorm <= 0.) { 00155 *resid = 1. / eps; 00156 return 0; 00157 } 00158 00159 /* Compute B - A*X (or B - A'*X ) and store in B. */ 00160 00161 dgemm_(trans, "No transpose", &n1, nrhs, &n2, &c_b7, &a[a_offset], lda, & 00162 x[x_offset], ldx, &c_b8, &b[b_offset], ldb) 00163 ; 00164 00165 /* Compute the maximum over the number of right hand sides of */ 00166 /* norm(B - A*X) / ( norm(A) * norm(X) * EPS ) . */ 00167 00168 *resid = 0.; 00169 i__1 = *nrhs; 00170 for (j = 1; j <= i__1; ++j) { 00171 bnorm = (d__1 = b[idamax_(&n1, &b[j * b_dim1 + 1], &c__1) + j * 00172 b_dim1], abs(d__1)); 00173 xnorm = (d__1 = x[idamax_(&n2, &x[j * x_dim1 + 1], &c__1) + j * 00174 x_dim1], abs(d__1)); 00175 if (xnorm <= 0.) { 00176 *resid = 1. / eps; 00177 } else { 00178 /* Computing MAX */ 00179 d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps; 00180 *resid = max(d__1,d__2); 00181 } 00182 /* L10: */ 00183 } 00184 00185 return 0; 00186 00187 /* End of DGET02 */ 00188 00189 } /* dget08_ */