00001 /* dpbt02.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 doublereal c_b5 = -1.; 00019 static integer c__1 = 1; 00020 static doublereal c_b7 = 1.; 00021 00022 /* Subroutine */ int dpbt02_(char *uplo, integer *n, integer *kd, integer * 00023 nrhs, doublereal *a, integer *lda, doublereal *x, integer *ldx, 00024 doublereal *b, integer *ldb, doublereal *rwork, doublereal *resid) 00025 { 00026 /* System generated locals */ 00027 integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, i__1; 00028 doublereal d__1, d__2; 00029 00030 /* Local variables */ 00031 integer j; 00032 doublereal eps; 00033 extern doublereal dasum_(integer *, doublereal *, integer *); 00034 extern /* Subroutine */ int dsbmv_(char *, integer *, integer *, 00035 doublereal *, doublereal *, integer *, doublereal *, integer *, 00036 doublereal *, doublereal *, integer *); 00037 doublereal anorm, bnorm, xnorm; 00038 extern doublereal dlamch_(char *), dlansb_(char *, char *, 00039 integer *, integer *, doublereal *, integer *, doublereal *); 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 /* DPBT02 computes the residual for a solution of a symmetric banded */ 00055 /* system of equations A*x = b: */ 00056 /* RESID = norm( B - A*X ) / ( norm(A) * norm(X) * EPS) */ 00057 /* where EPS is the machine precision. */ 00058 00059 /* Arguments */ 00060 /* ========= */ 00061 00062 /* UPLO (input) CHARACTER*1 */ 00063 /* Specifies whether the upper or lower triangular part of the */ 00064 /* symmetric matrix A is stored: */ 00065 /* = 'U': Upper triangular */ 00066 /* = 'L': Lower triangular */ 00067 00068 /* N (input) INTEGER */ 00069 /* The number of rows and columns of the matrix A. N >= 0. */ 00070 00071 /* KD (input) INTEGER */ 00072 /* The number of super-diagonals of the matrix A if UPLO = 'U', */ 00073 /* or the number of sub-diagonals if UPLO = 'L'. KD >= 0. */ 00074 00075 /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */ 00076 /* The original symmetric band matrix A. If UPLO = 'U', the */ 00077 /* upper triangular part of A is stored as a band matrix; if */ 00078 /* UPLO = 'L', the lower triangular part of A is stored. The */ 00079 /* columns of the appropriate triangle are stored in the columns */ 00080 /* of A and the diagonals of the triangle are stored in the rows */ 00081 /* of A. See DPBTRF for further details. */ 00082 00083 /* LDA (input) INTEGER. */ 00084 /* The leading dimension of the array A. LDA >= max(1,KD+1). */ 00085 00086 /* X (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */ 00087 /* The computed solution vectors for the system of linear */ 00088 /* equations. */ 00089 00090 /* LDX (input) INTEGER */ 00091 /* The leading dimension of the array X. LDX >= max(1,N). */ 00092 00093 /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */ 00094 /* On entry, the right hand side vectors for the system of */ 00095 /* linear equations. */ 00096 /* On exit, B is overwritten with the difference B - A*X. */ 00097 00098 /* LDB (input) INTEGER */ 00099 /* The leading dimension of the array B. LDB >= max(1,N). */ 00100 00101 /* RWORK (workspace) DOUBLE PRECISION array, dimension (N) */ 00102 00103 /* RESID (output) DOUBLE PRECISION */ 00104 /* The maximum over the number of right hand sides of */ 00105 /* norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */ 00106 00107 /* ===================================================================== */ 00108 00109 /* .. Parameters .. */ 00110 /* .. */ 00111 /* .. Local Scalars .. */ 00112 /* .. */ 00113 /* .. External Functions .. */ 00114 /* .. */ 00115 /* .. External Subroutines .. */ 00116 /* .. */ 00117 /* .. Intrinsic Functions .. */ 00118 /* .. */ 00119 /* .. Executable Statements .. */ 00120 00121 /* Quick exit if N = 0 or NRHS = 0. */ 00122 00123 /* Parameter adjustments */ 00124 a_dim1 = *lda; 00125 a_offset = 1 + a_dim1; 00126 a -= a_offset; 00127 x_dim1 = *ldx; 00128 x_offset = 1 + x_dim1; 00129 x -= x_offset; 00130 b_dim1 = *ldb; 00131 b_offset = 1 + b_dim1; 00132 b -= b_offset; 00133 --rwork; 00134 00135 /* Function Body */ 00136 if (*n <= 0 || *nrhs <= 0) { 00137 *resid = 0.; 00138 return 0; 00139 } 00140 00141 /* Exit with RESID = 1/EPS if ANORM = 0. */ 00142 00143 eps = dlamch_("Epsilon"); 00144 anorm = dlansb_("1", uplo, n, kd, &a[a_offset], lda, &rwork[1]); 00145 if (anorm <= 0.) { 00146 *resid = 1. / eps; 00147 return 0; 00148 } 00149 00150 /* Compute B - A*X */ 00151 00152 i__1 = *nrhs; 00153 for (j = 1; j <= i__1; ++j) { 00154 dsbmv_(uplo, n, kd, &c_b5, &a[a_offset], lda, &x[j * x_dim1 + 1], & 00155 c__1, &c_b7, &b[j * b_dim1 + 1], &c__1); 00156 /* L10: */ 00157 } 00158 00159 /* Compute the maximum over the number of right hand sides of */ 00160 /* norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) */ 00161 00162 *resid = 0.; 00163 i__1 = *nrhs; 00164 for (j = 1; j <= i__1; ++j) { 00165 bnorm = dasum_(n, &b[j * b_dim1 + 1], &c__1); 00166 xnorm = dasum_(n, &x[j * x_dim1 + 1], &c__1); 00167 if (xnorm <= 0.) { 00168 *resid = 1. / eps; 00169 } else { 00170 /* Computing MAX */ 00171 d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps; 00172 *resid = max(d__1,d__2); 00173 } 00174 /* L20: */ 00175 } 00176 00177 return 0; 00178 00179 /* End of DPBT02 */ 00180 00181 } /* dpbt02_ */