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