00001 /* sppt02.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_b5 = -1.f; 00019 static integer c__1 = 1; 00020 static real c_b7 = 1.f; 00021 00022 /* Subroutine */ int sppt02_(char *uplo, integer *n, integer *nrhs, real *a, 00023 real *x, integer *ldx, real *b, integer *ldb, real *rwork, 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; 00033 extern doublereal sasum_(integer *, real *, integer *); 00034 real xnorm; 00035 extern /* Subroutine */ int sspmv_(char *, integer *, real *, real *, 00036 real *, integer *, real *, real *, integer *); 00037 extern doublereal slamch_(char *), slansp_(char *, char *, 00038 integer *, real *, real *); 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 /* SPPT02 computes the residual in the solution of a symmetric system */ 00054 /* of linear equations A*x = b when packed storage is used for the */ 00055 /* coefficient matrix. The ratio computed is */ 00056 00057 /* RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS), */ 00058 00059 /* where EPS is the machine precision. */ 00060 00061 /* Arguments */ 00062 /* ========= */ 00063 00064 /* UPLO (input) CHARACTER*1 */ 00065 /* Specifies whether the upper or lower triangular part of the */ 00066 /* symmetric 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) REAL array, dimension (N*(N+1)/2) */ 00078 /* The original symmetric matrix A, stored as a packed */ 00079 /* triangular matrix. */ 00080 00081 /* X (input) REAL array, dimension (LDX,NRHS) */ 00082 /* The computed solution vectors for the system of linear */ 00083 /* equations. */ 00084 00085 /* LDX (input) INTEGER */ 00086 /* The leading dimension of the array X. LDX >= max(1,N). */ 00087 00088 /* B (input/output) REAL array, dimension (LDB,NRHS) */ 00089 /* On entry, the right hand side vectors for the system of */ 00090 /* linear equations. */ 00091 /* On exit, B is overwritten with the difference B - A*X. */ 00092 00093 /* LDB (input) INTEGER */ 00094 /* The leading dimension of the array B. LDB >= max(1,N). */ 00095 00096 /* RWORK (workspace) REAL array, dimension (N) */ 00097 00098 /* RESID (output) REAL */ 00099 /* The maximum over the number of right hand sides of */ 00100 /* norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */ 00101 00102 /* ===================================================================== */ 00103 00104 /* .. Parameters .. */ 00105 /* .. */ 00106 /* .. Local Scalars .. */ 00107 /* .. */ 00108 /* .. External Functions .. */ 00109 /* .. */ 00110 /* .. External Subroutines .. */ 00111 /* .. */ 00112 /* .. Intrinsic Functions .. */ 00113 /* .. */ 00114 /* .. Executable Statements .. */ 00115 00116 /* Quick exit if N = 0 or NRHS = 0. */ 00117 00118 /* Parameter adjustments */ 00119 --a; 00120 x_dim1 = *ldx; 00121 x_offset = 1 + x_dim1; 00122 x -= x_offset; 00123 b_dim1 = *ldb; 00124 b_offset = 1 + b_dim1; 00125 b -= b_offset; 00126 --rwork; 00127 00128 /* Function Body */ 00129 if (*n <= 0 || *nrhs <= 0) { 00130 *resid = 0.f; 00131 return 0; 00132 } 00133 00134 /* Exit with RESID = 1/EPS if ANORM = 0. */ 00135 00136 eps = slamch_("Epsilon"); 00137 anorm = slansp_("1", uplo, n, &a[1], &rwork[1]); 00138 if (anorm <= 0.f) { 00139 *resid = 1.f / eps; 00140 return 0; 00141 } 00142 00143 /* Compute B - A*X for the matrix of right hand sides B. */ 00144 00145 i__1 = *nrhs; 00146 for (j = 1; j <= i__1; ++j) { 00147 sspmv_(uplo, n, &c_b5, &a[1], &x[j * x_dim1 + 1], &c__1, &c_b7, &b[j * 00148 b_dim1 + 1], &c__1); 00149 /* L10: */ 00150 } 00151 00152 /* Compute the maximum over the number of right hand sides of */ 00153 /* norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) . */ 00154 00155 *resid = 0.f; 00156 i__1 = *nrhs; 00157 for (j = 1; j <= i__1; ++j) { 00158 bnorm = sasum_(n, &b[j * b_dim1 + 1], &c__1); 00159 xnorm = sasum_(n, &x[j * x_dim1 + 1], &c__1); 00160 if (xnorm <= 0.f) { 00161 *resid = 1.f / eps; 00162 } else { 00163 /* Computing MAX */ 00164 r__1 = *resid, r__2 = bnorm / anorm / xnorm / eps; 00165 *resid = dmax(r__1,r__2); 00166 } 00167 /* L20: */ 00168 } 00169 00170 return 0; 00171 00172 /* End of SPPT02 */ 00173 00174 } /* sppt02_ */