00001 /* ztpt03.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 ztpt03_(char *uplo, char *trans, char *diag, integer *n, 00021 integer *nrhs, doublecomplex *ap, doublereal *scale, doublereal * 00022 cnorm, doublereal *tscal, doublecomplex *x, integer *ldx, 00023 doublecomplex *b, integer *ldb, doublecomplex *work, doublereal * 00024 resid) 00025 { 00026 /* System generated locals */ 00027 integer b_dim1, b_offset, x_dim1, x_offset, i__1; 00028 doublereal d__1, d__2; 00029 doublecomplex z__1; 00030 00031 /* Builtin functions */ 00032 double z_abs(doublecomplex *); 00033 00034 /* Local variables */ 00035 integer j, jj, ix; 00036 doublereal eps, err; 00037 extern logical lsame_(char *, char *); 00038 doublereal xscal, tnorm, xnorm; 00039 extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, 00040 doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *, 00041 doublecomplex *, integer *, doublecomplex *, integer *), ztpmv_( 00042 char *, char *, char *, integer *, doublecomplex *, doublecomplex 00043 *, integer *); 00044 extern doublereal dlamch_(char *); 00045 extern /* Subroutine */ int zdscal_(integer *, doublereal *, 00046 doublecomplex *, integer *); 00047 extern integer izamax_(integer *, doublecomplex *, integer *); 00048 doublereal smlnum; 00049 00050 00051 /* -- LAPACK test routine (version 3.1) -- */ 00052 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00053 /* November 2006 */ 00054 00055 /* .. Scalar Arguments .. */ 00056 /* .. */ 00057 /* .. Array Arguments .. */ 00058 /* .. */ 00059 00060 /* Purpose */ 00061 /* ======= */ 00062 00063 /* ZTPT03 computes the residual for the solution to a scaled triangular */ 00064 /* system of equations A*x = s*b, A**T *x = s*b, or A**H *x = s*b, */ 00065 /* when the triangular matrix A is stored in packed format. Here A**T */ 00066 /* denotes the transpose of A, A**H denotes the conjugate transpose of */ 00067 /* A, s is a scalar, and x and b are N by NRHS matrices. The test ratio */ 00068 /* is the maximum over the number of right hand sides of */ 00069 /* norm(s*b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), */ 00070 /* where op(A) denotes A, A**T, or A**H, and EPS is the machine epsilon. */ 00071 00072 /* Arguments */ 00073 /* ========= */ 00074 00075 /* UPLO (input) CHARACTER*1 */ 00076 /* Specifies whether the matrix A is upper or lower triangular. */ 00077 /* = 'U': Upper triangular */ 00078 /* = 'L': Lower triangular */ 00079 00080 /* TRANS (input) CHARACTER*1 */ 00081 /* Specifies the operation applied to A. */ 00082 /* = 'N': A *x = s*b (No transpose) */ 00083 /* = 'T': A**T *x = s*b (Transpose) */ 00084 /* = 'C': A**H *x = s*b (Conjugate transpose) */ 00085 00086 /* DIAG (input) CHARACTER*1 */ 00087 /* Specifies whether or not the matrix A is unit triangular. */ 00088 /* = 'N': Non-unit triangular */ 00089 /* = 'U': Unit triangular */ 00090 00091 /* N (input) INTEGER */ 00092 /* The order of the matrix A. N >= 0. */ 00093 00094 /* NRHS (input) INTEGER */ 00095 /* The number of right hand sides, i.e., the number of columns */ 00096 /* of the matrices X and B. NRHS >= 0. */ 00097 00098 /* AP (input) COMPLEX*16 array, dimension (N*(N+1)/2) */ 00099 /* The upper or lower triangular matrix A, packed columnwise in */ 00100 /* a linear array. The j-th column of A is stored in the array */ 00101 /* AP as follows: */ 00102 /* if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j; */ 00103 /* if UPLO = 'L', */ 00104 /* AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n. */ 00105 00106 /* SCALE (input) DOUBLE PRECISION */ 00107 /* The scaling factor s used in solving the triangular system. */ 00108 00109 /* CNORM (input) DOUBLE PRECISION array, dimension (N) */ 00110 /* The 1-norms of the columns of A, not counting the diagonal. */ 00111 00112 /* TSCAL (input) DOUBLE PRECISION */ 00113 /* The scaling factor used in computing the 1-norms in CNORM. */ 00114 /* CNORM actually contains the column norms of TSCAL*A. */ 00115 00116 /* X (input) COMPLEX*16 array, dimension (LDX,NRHS) */ 00117 /* The computed solution vectors for the system of linear */ 00118 /* equations. */ 00119 00120 /* LDX (input) INTEGER */ 00121 /* The leading dimension of the array X. LDX >= max(1,N). */ 00122 00123 /* B (input) COMPLEX*16 array, dimension (LDB,NRHS) */ 00124 /* The right hand side vectors for the system of linear */ 00125 /* equations. */ 00126 00127 /* LDB (input) INTEGER */ 00128 /* The leading dimension of the array B. LDB >= max(1,N). */ 00129 00130 /* WORK (workspace) COMPLEX*16 array, dimension (N) */ 00131 00132 /* RESID (output) DOUBLE PRECISION */ 00133 /* The maximum over the number of right hand sides of */ 00134 /* norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). */ 00135 00136 /* ===================================================================== */ 00137 00138 /* .. Parameters .. */ 00139 /* .. */ 00140 /* .. Local Scalars .. */ 00141 /* .. */ 00142 /* .. External Functions .. */ 00143 /* .. */ 00144 /* .. External Subroutines .. */ 00145 /* .. */ 00146 /* .. Intrinsic Functions .. */ 00147 /* .. */ 00148 /* .. Executable Statements .. */ 00149 00150 /* Quick exit if N = 0. */ 00151 00152 /* Parameter adjustments */ 00153 --ap; 00154 --cnorm; 00155 x_dim1 = *ldx; 00156 x_offset = 1 + x_dim1; 00157 x -= x_offset; 00158 b_dim1 = *ldb; 00159 b_offset = 1 + b_dim1; 00160 b -= b_offset; 00161 --work; 00162 00163 /* Function Body */ 00164 if (*n <= 0 || *nrhs <= 0) { 00165 *resid = 0.; 00166 return 0; 00167 } 00168 eps = dlamch_("Epsilon"); 00169 smlnum = dlamch_("Safe minimum"); 00170 00171 /* Compute the norm of the triangular matrix A using the column */ 00172 /* norms already computed by ZLATPS. */ 00173 00174 tnorm = 0.; 00175 if (lsame_(diag, "N")) { 00176 if (lsame_(uplo, "U")) { 00177 jj = 1; 00178 i__1 = *n; 00179 for (j = 1; j <= i__1; ++j) { 00180 /* Computing MAX */ 00181 d__1 = tnorm, d__2 = *tscal * z_abs(&ap[jj]) + cnorm[j]; 00182 tnorm = max(d__1,d__2); 00183 jj += j; 00184 /* L10: */ 00185 } 00186 } else { 00187 jj = 1; 00188 i__1 = *n; 00189 for (j = 1; j <= i__1; ++j) { 00190 /* Computing MAX */ 00191 d__1 = tnorm, d__2 = *tscal * z_abs(&ap[jj]) + cnorm[j]; 00192 tnorm = max(d__1,d__2); 00193 jj = jj + *n - j + 1; 00194 /* L20: */ 00195 } 00196 } 00197 } else { 00198 i__1 = *n; 00199 for (j = 1; j <= i__1; ++j) { 00200 /* Computing MAX */ 00201 d__1 = tnorm, d__2 = *tscal + cnorm[j]; 00202 tnorm = max(d__1,d__2); 00203 /* L30: */ 00204 } 00205 } 00206 00207 /* Compute the maximum over the number of right hand sides of */ 00208 /* norm(op(A)*x - s*b) / ( norm(A) * norm(x) * EPS ). */ 00209 00210 *resid = 0.; 00211 i__1 = *nrhs; 00212 for (j = 1; j <= i__1; ++j) { 00213 zcopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1); 00214 ix = izamax_(n, &work[1], &c__1); 00215 /* Computing MAX */ 00216 d__1 = 1., d__2 = z_abs(&x[ix + j * x_dim1]); 00217 xnorm = max(d__1,d__2); 00218 xscal = 1. / xnorm / (doublereal) (*n); 00219 zdscal_(n, &xscal, &work[1], &c__1); 00220 ztpmv_(uplo, trans, diag, n, &ap[1], &work[1], &c__1); 00221 d__1 = -(*scale) * xscal; 00222 z__1.r = d__1, z__1.i = 0.; 00223 zaxpy_(n, &z__1, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1); 00224 ix = izamax_(n, &work[1], &c__1); 00225 err = *tscal * z_abs(&work[ix]); 00226 ix = izamax_(n, &x[j * x_dim1 + 1], &c__1); 00227 xnorm = z_abs(&x[ix + j * x_dim1]); 00228 if (err * smlnum <= xnorm) { 00229 if (xnorm > 0.) { 00230 err /= xnorm; 00231 } 00232 } else { 00233 if (err > 0.) { 00234 err = 1. / eps; 00235 } 00236 } 00237 if (err * smlnum <= tnorm) { 00238 if (tnorm > 0.) { 00239 err /= tnorm; 00240 } 00241 } else { 00242 if (err > 0.) { 00243 err = 1. / eps; 00244 } 00245 } 00246 *resid = max(*resid,err); 00247 /* L40: */ 00248 } 00249 00250 return 0; 00251 00252 /* End of ZTPT03 */ 00253 00254 } /* ztpt03_ */