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