00001 /* cpot02.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 complex c_b1 = {1.f,0.f}; 00019 static integer c__1 = 1; 00020 00021 /* Subroutine */ int cpot02_(char *uplo, integer *n, integer *nrhs, complex * 00022 a, integer *lda, complex *x, integer *ldx, complex *b, integer *ldb, 00023 real *rwork, real *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; 00028 complex q__1; 00029 00030 /* Local variables */ 00031 integer j; 00032 real eps; 00033 extern /* Subroutine */ int chemm_(char *, char *, integer *, integer *, 00034 complex *, complex *, integer *, complex *, integer *, complex *, 00035 complex *, integer *); 00036 real anorm, bnorm, xnorm; 00037 extern doublereal clanhe_(char *, char *, integer *, complex *, integer *, 00038 real *), slamch_(char *), scasum_( 00039 integer *, complex *, integer *); 00040 00041 00042 /* -- LAPACK test routine (version 3.1) -- */ 00043 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00044 /* November 2006 */ 00045 00046 /* .. Scalar Arguments .. */ 00047 /* .. */ 00048 /* .. Array Arguments .. */ 00049 /* .. */ 00050 00051 /* Purpose */ 00052 /* ======= */ 00053 00054 /* CPOT02 computes the residual for the solution of a Hermitian system */ 00055 /* of linear equations A*x = b: */ 00056 00057 /* RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS ), */ 00058 00059 /* where EPS is the machine epsilon. */ 00060 00061 /* Arguments */ 00062 /* ========= */ 00063 00064 /* UPLO (input) CHARACTER*1 */ 00065 /* Specifies whether the upper or lower triangular part of the */ 00066 /* Hermitian matrix A is stored: */ 00067 /* = 'U': Upper triangular */ 00068 /* = 'L': Lower triangular */ 00069 00070 /* N (input) INTEGER */ 00071 /* The number of rows and columns of the matrix A. N >= 0. */ 00072 00073 /* NRHS (input) INTEGER */ 00074 /* The number of columns of B, the matrix of right hand sides. */ 00075 /* NRHS >= 0. */ 00076 00077 /* A (input) COMPLEX array, dimension (LDA,N) */ 00078 /* The original Hermitian matrix A. */ 00079 00080 /* LDA (input) INTEGER */ 00081 /* The leading dimension of the array A. LDA >= max(1,N) */ 00082 00083 /* X (input) COMPLEX array, dimension (LDX,NRHS) */ 00084 /* The computed solution vectors for the system of linear */ 00085 /* equations. */ 00086 00087 /* LDX (input) INTEGER */ 00088 /* The leading dimension of the array X. LDX >= max(1,N). */ 00089 00090 /* B (input/output) COMPLEX array, dimension (LDB,NRHS) */ 00091 /* On entry, the right hand side vectors for the system of */ 00092 /* linear equations. */ 00093 /* On exit, B is overwritten with the difference B - A*X. */ 00094 00095 /* LDB (input) INTEGER */ 00096 /* The leading dimension of the array B. LDB >= max(1,N). */ 00097 00098 /* RWORK (workspace) REAL array, dimension (N) */ 00099 00100 /* RESID (output) REAL */ 00101 /* The maximum over the number of right hand sides of */ 00102 /* norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */ 00103 00104 /* ===================================================================== */ 00105 00106 /* .. Parameters .. */ 00107 /* .. */ 00108 /* .. Local Scalars .. */ 00109 /* .. */ 00110 /* .. External Functions .. */ 00111 /* .. */ 00112 /* .. External Subroutines .. */ 00113 /* .. */ 00114 /* .. Intrinsic Functions .. */ 00115 /* .. */ 00116 /* .. Executable Statements .. */ 00117 00118 /* Quick exit if N = 0 or NRHS = 0. */ 00119 00120 /* Parameter adjustments */ 00121 a_dim1 = *lda; 00122 a_offset = 1 + a_dim1; 00123 a -= a_offset; 00124 x_dim1 = *ldx; 00125 x_offset = 1 + x_dim1; 00126 x -= x_offset; 00127 b_dim1 = *ldb; 00128 b_offset = 1 + b_dim1; 00129 b -= b_offset; 00130 --rwork; 00131 00132 /* Function Body */ 00133 if (*n <= 0 || *nrhs <= 0) { 00134 *resid = 0.f; 00135 return 0; 00136 } 00137 00138 /* Exit with RESID = 1/EPS if ANORM = 0. */ 00139 00140 eps = slamch_("Epsilon"); 00141 anorm = clanhe_("1", uplo, n, &a[a_offset], lda, &rwork[1]); 00142 if (anorm <= 0.f) { 00143 *resid = 1.f / eps; 00144 return 0; 00145 } 00146 00147 /* Compute B - A*X */ 00148 00149 q__1.r = -1.f, q__1.i = -0.f; 00150 chemm_("Left", uplo, n, nrhs, &q__1, &a[a_offset], lda, &x[x_offset], ldx, 00151 &c_b1, &b[b_offset], ldb); 00152 00153 /* Compute the maximum over the number of right hand sides of */ 00154 /* norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) . */ 00155 00156 *resid = 0.f; 00157 i__1 = *nrhs; 00158 for (j = 1; j <= i__1; ++j) { 00159 bnorm = scasum_(n, &b[j * b_dim1 + 1], &c__1); 00160 xnorm = scasum_(n, &x[j * x_dim1 + 1], &c__1); 00161 if (xnorm <= 0.f) { 00162 *resid = 1.f / eps; 00163 } else { 00164 /* Computing MAX */ 00165 r__1 = *resid, r__2 = bnorm / anorm / xnorm / eps; 00166 *resid = dmax(r__1,r__2); 00167 } 00168 /* L10: */ 00169 } 00170 00171 return 0; 00172 00173 /* End of CPOT02 */ 00174 00175 } /* cpot02_ */