![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b STBT03 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 * Definition: 00009 * =========== 00010 * 00011 * SUBROUTINE STBT03( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, 00012 * SCALE, CNORM, TSCAL, X, LDX, B, LDB, WORK, 00013 * RESID ) 00014 * 00015 * .. Scalar Arguments .. 00016 * CHARACTER DIAG, TRANS, UPLO 00017 * INTEGER KD, LDAB, LDB, LDX, N, NRHS 00018 * REAL RESID, SCALE, TSCAL 00019 * .. 00020 * .. Array Arguments .. 00021 * REAL AB( LDAB, * ), B( LDB, * ), CNORM( * ), 00022 * $ WORK( * ), X( LDX, * ) 00023 * .. 00024 * 00025 * 00026 *> \par Purpose: 00027 * ============= 00028 *> 00029 *> \verbatim 00030 *> 00031 *> STBT03 computes the residual for the solution to a scaled triangular 00032 *> system of equations A*x = s*b or A'*x = s*b when A is a 00033 *> triangular band matrix. Here A' is the transpose of A, s is a scalar, 00034 *> and x and b are N by NRHS matrices. The test ratio is the maximum 00035 *> over the number of right hand sides of 00036 *> norm(s*b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), 00037 *> where op(A) denotes A or A' and EPS is the machine epsilon. 00038 *> \endverbatim 00039 * 00040 * Arguments: 00041 * ========== 00042 * 00043 *> \param[in] UPLO 00044 *> \verbatim 00045 *> UPLO is CHARACTER*1 00046 *> Specifies whether the matrix A is upper or lower triangular. 00047 *> = 'U': Upper triangular 00048 *> = 'L': Lower triangular 00049 *> \endverbatim 00050 *> 00051 *> \param[in] TRANS 00052 *> \verbatim 00053 *> TRANS is CHARACTER*1 00054 *> Specifies the operation applied to A. 00055 *> = 'N': A *x = b (No transpose) 00056 *> = 'T': A'*x = b (Transpose) 00057 *> = 'C': A'*x = b (Conjugate transpose = Transpose) 00058 *> \endverbatim 00059 *> 00060 *> \param[in] DIAG 00061 *> \verbatim 00062 *> DIAG is CHARACTER*1 00063 *> Specifies whether or not the matrix A is unit triangular. 00064 *> = 'N': Non-unit triangular 00065 *> = 'U': Unit triangular 00066 *> \endverbatim 00067 *> 00068 *> \param[in] N 00069 *> \verbatim 00070 *> N is INTEGER 00071 *> The order of the matrix A. N >= 0. 00072 *> \endverbatim 00073 *> 00074 *> \param[in] KD 00075 *> \verbatim 00076 *> KD is INTEGER 00077 *> The number of superdiagonals or subdiagonals of the 00078 *> triangular band matrix A. KD >= 0. 00079 *> \endverbatim 00080 *> 00081 *> \param[in] NRHS 00082 *> \verbatim 00083 *> NRHS is INTEGER 00084 *> The number of right hand sides, i.e., the number of columns 00085 *> of the matrices X and B. NRHS >= 0. 00086 *> \endverbatim 00087 *> 00088 *> \param[in] AB 00089 *> \verbatim 00090 *> AB is REAL array, dimension (LDAB,N) 00091 *> The upper or lower triangular band matrix A, stored in the 00092 *> first kd+1 rows of the array. The j-th column of A is stored 00093 *> in the j-th column of the array AB as follows: 00094 *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; 00095 *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). 00096 *> \endverbatim 00097 *> 00098 *> \param[in] LDAB 00099 *> \verbatim 00100 *> LDAB is INTEGER 00101 *> The leading dimension of the array AB. LDAB >= KD+1. 00102 *> \endverbatim 00103 *> 00104 *> \param[in] SCALE 00105 *> \verbatim 00106 *> SCALE is REAL 00107 *> The scaling factor s used in solving the triangular system. 00108 *> \endverbatim 00109 *> 00110 *> \param[in] CNORM 00111 *> \verbatim 00112 *> CNORM is REAL array, dimension (N) 00113 *> The 1-norms of the columns of A, not counting the diagonal. 00114 *> \endverbatim 00115 *> 00116 *> \param[in] TSCAL 00117 *> \verbatim 00118 *> TSCAL is REAL 00119 *> The scaling factor used in computing the 1-norms in CNORM. 00120 *> CNORM actually contains the column norms of TSCAL*A. 00121 *> \endverbatim 00122 *> 00123 *> \param[in] X 00124 *> \verbatim 00125 *> X is REAL array, dimension (LDX,NRHS) 00126 *> The computed solution vectors for the system of linear 00127 *> equations. 00128 *> \endverbatim 00129 *> 00130 *> \param[in] LDX 00131 *> \verbatim 00132 *> LDX is INTEGER 00133 *> The leading dimension of the array X. LDX >= max(1,N). 00134 *> \endverbatim 00135 *> 00136 *> \param[in] B 00137 *> \verbatim 00138 *> B is REAL array, dimension (LDB,NRHS) 00139 *> The right hand side vectors for the system of linear 00140 *> equations. 00141 *> \endverbatim 00142 *> 00143 *> \param[in] LDB 00144 *> \verbatim 00145 *> LDB is INTEGER 00146 *> The leading dimension of the array B. LDB >= max(1,N). 00147 *> \endverbatim 00148 *> 00149 *> \param[out] WORK 00150 *> \verbatim 00151 *> WORK is REAL array, dimension (N) 00152 *> \endverbatim 00153 *> 00154 *> \param[out] RESID 00155 *> \verbatim 00156 *> RESID is REAL 00157 *> The maximum over the number of right hand sides of 00158 *> norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). 00159 *> \endverbatim 00160 * 00161 * Authors: 00162 * ======== 00163 * 00164 *> \author Univ. of Tennessee 00165 *> \author Univ. of California Berkeley 00166 *> \author Univ. of Colorado Denver 00167 *> \author NAG Ltd. 00168 * 00169 *> \date November 2011 00170 * 00171 *> \ingroup single_lin 00172 * 00173 * ===================================================================== 00174 SUBROUTINE STBT03( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, 00175 $ SCALE, CNORM, TSCAL, X, LDX, B, LDB, WORK, 00176 $ RESID ) 00177 * 00178 * -- LAPACK test routine (version 3.4.0) -- 00179 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00180 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00181 * November 2011 00182 * 00183 * .. Scalar Arguments .. 00184 CHARACTER DIAG, TRANS, UPLO 00185 INTEGER KD, LDAB, LDB, LDX, N, NRHS 00186 REAL RESID, SCALE, TSCAL 00187 * .. 00188 * .. Array Arguments .. 00189 REAL AB( LDAB, * ), B( LDB, * ), CNORM( * ), 00190 $ WORK( * ), X( LDX, * ) 00191 * .. 00192 * 00193 * ===================================================================== 00194 * 00195 * .. Parameters .. 00196 REAL ONE, ZERO 00197 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) 00198 * .. 00199 * .. Local Scalars .. 00200 INTEGER IX, J 00201 REAL BIGNUM, EPS, ERR, SMLNUM, TNORM, XNORM, XSCAL 00202 * .. 00203 * .. External Functions .. 00204 LOGICAL LSAME 00205 INTEGER ISAMAX 00206 REAL SLAMCH 00207 EXTERNAL LSAME, ISAMAX, SLAMCH 00208 * .. 00209 * .. External Subroutines .. 00210 EXTERNAL SAXPY, SCOPY, SLABAD, SSCAL, STBMV 00211 * .. 00212 * .. Intrinsic Functions .. 00213 INTRINSIC ABS, MAX, REAL 00214 * .. 00215 * .. Executable Statements .. 00216 * 00217 * Quick exit if N = 0 00218 * 00219 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 00220 RESID = ZERO 00221 RETURN 00222 END IF 00223 EPS = SLAMCH( 'Epsilon' ) 00224 SMLNUM = SLAMCH( 'Safe minimum' ) 00225 BIGNUM = ONE / SMLNUM 00226 CALL SLABAD( SMLNUM, BIGNUM ) 00227 * 00228 * Compute the norm of the triangular matrix A using the column 00229 * norms already computed by SLATBS. 00230 * 00231 TNORM = ZERO 00232 IF( LSAME( DIAG, 'N' ) ) THEN 00233 IF( LSAME( UPLO, 'U' ) ) THEN 00234 DO 10 J = 1, N 00235 TNORM = MAX( TNORM, TSCAL*ABS( AB( KD+1, J ) )+ 00236 $ CNORM( J ) ) 00237 10 CONTINUE 00238 ELSE 00239 DO 20 J = 1, N 00240 TNORM = MAX( TNORM, TSCAL*ABS( AB( 1, J ) )+CNORM( J ) ) 00241 20 CONTINUE 00242 END IF 00243 ELSE 00244 DO 30 J = 1, N 00245 TNORM = MAX( TNORM, TSCAL+CNORM( J ) ) 00246 30 CONTINUE 00247 END IF 00248 * 00249 * Compute the maximum over the number of right hand sides of 00250 * norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). 00251 * 00252 RESID = ZERO 00253 DO 40 J = 1, NRHS 00254 CALL SCOPY( N, X( 1, J ), 1, WORK, 1 ) 00255 IX = ISAMAX( N, WORK, 1 ) 00256 XNORM = MAX( ONE, ABS( X( IX, J ) ) ) 00257 XSCAL = ( ONE / XNORM ) / REAL( KD+1 ) 00258 CALL SSCAL( N, XSCAL, WORK, 1 ) 00259 CALL STBMV( UPLO, TRANS, DIAG, N, KD, AB, LDAB, WORK, 1 ) 00260 CALL SAXPY( N, -SCALE*XSCAL, B( 1, J ), 1, WORK, 1 ) 00261 IX = ISAMAX( N, WORK, 1 ) 00262 ERR = TSCAL*ABS( WORK( IX ) ) 00263 IX = ISAMAX( N, X( 1, J ), 1 ) 00264 XNORM = ABS( X( IX, J ) ) 00265 IF( ERR*SMLNUM.LE.XNORM ) THEN 00266 IF( XNORM.GT.ZERO ) 00267 $ ERR = ERR / XNORM 00268 ELSE 00269 IF( ERR.GT.ZERO ) 00270 $ ERR = ONE / EPS 00271 END IF 00272 IF( ERR*SMLNUM.LE.TNORM ) THEN 00273 IF( TNORM.GT.ZERO ) 00274 $ ERR = ERR / TNORM 00275 ELSE 00276 IF( ERR.GT.ZERO ) 00277 $ ERR = ONE / EPS 00278 END IF 00279 RESID = MAX( RESID, ERR ) 00280 40 CONTINUE 00281 * 00282 RETURN 00283 * 00284 * End of STBT03 00285 * 00286 END