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