1*> \brief \b STBT02 2* 3* =========== DOCUMENTATION =========== 4* 5* Online html documentation available at 6* http://www.netlib.org/lapack/explore-html/ 7* 8* Definition: 9* =========== 10* 11* SUBROUTINE STBT02( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, X, 12* LDX, B, LDB, WORK, RESID ) 13* 14* .. Scalar Arguments .. 15* CHARACTER DIAG, TRANS, UPLO 16* INTEGER KD, LDAB, LDB, LDX, N, NRHS 17* REAL RESID 18* .. 19* .. Array Arguments .. 20* REAL AB( LDAB, * ), B( LDB, * ), WORK( * ), 21* $ X( LDX, * ) 22* .. 23* 24* 25*> \par Purpose: 26* ============= 27*> 28*> \verbatim 29*> 30*> STBT02 computes the residual for the computed solution to a 31*> triangular system of linear equations op(A)*X = B when A is a 32*> triangular band matrix. The test ratio is the maximum over the 33*> number of right hand sides of 34*> norm(b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), 35*> where op(A) denotes A or A' and EPS is the machine epsilon. 36*> The norm used is the 1-norm. 37*> \endverbatim 38* 39* Arguments: 40* ========== 41* 42*> \param[in] UPLO 43*> \verbatim 44*> UPLO is CHARACTER*1 45*> Specifies whether the matrix A is upper or lower triangular. 46*> = 'U': Upper triangular 47*> = 'L': Lower triangular 48*> \endverbatim 49*> 50*> \param[in] TRANS 51*> \verbatim 52*> TRANS is CHARACTER*1 53*> Specifies the operation applied to A. 54*> = 'N': A * X = B (No transpose) 55*> = 'T': A**T * X = B (Transpose) 56*> = 'C': A**H * X = B (Conjugate transpose = Transpose) 57*> \endverbatim 58*> 59*> \param[in] DIAG 60*> \verbatim 61*> DIAG is CHARACTER*1 62*> Specifies whether or not the matrix A is unit triangular. 63*> = 'N': Non-unit triangular 64*> = 'U': Unit triangular 65*> \endverbatim 66*> 67*> \param[in] N 68*> \verbatim 69*> N is INTEGER 70*> The order of the matrix A. N >= 0. 71*> \endverbatim 72*> 73*> \param[in] KD 74*> \verbatim 75*> KD is INTEGER 76*> The number of superdiagonals or subdiagonals of the 77*> triangular band matrix A. KD >= 0. 78*> \endverbatim 79*> 80*> \param[in] NRHS 81*> \verbatim 82*> NRHS is INTEGER 83*> The number of right hand sides, i.e., the number of columns 84*> of the matrices X and B. NRHS >= 0. 85*> \endverbatim 86*> 87*> \param[in] AB 88*> \verbatim 89*> AB is REAL array, dimension (LDAB,N) 90*> The upper or lower triangular band matrix A, stored in the 91*> first kd+1 rows of the array. The j-th column of A is stored 92*> in the j-th column of the array AB as follows: 93*> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; 94*> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). 95*> \endverbatim 96*> 97*> \param[in] LDAB 98*> \verbatim 99*> LDAB is INTEGER 100*> The leading dimension of the array AB. LDAB >= KD+1. 101*> \endverbatim 102*> 103*> \param[in] X 104*> \verbatim 105*> X is REAL array, dimension (LDX,NRHS) 106*> The computed solution vectors for the system of linear 107*> equations. 108*> \endverbatim 109*> 110*> \param[in] LDX 111*> \verbatim 112*> LDX is INTEGER 113*> The leading dimension of the array X. LDX >= max(1,N). 114*> \endverbatim 115*> 116*> \param[in] B 117*> \verbatim 118*> B is REAL array, dimension (LDB,NRHS) 119*> The right hand side vectors for the system of linear 120*> equations. 121*> \endverbatim 122*> 123*> \param[in] LDB 124*> \verbatim 125*> LDB is INTEGER 126*> The leading dimension of the array B. LDB >= max(1,N). 127*> \endverbatim 128*> 129*> \param[out] WORK 130*> \verbatim 131*> WORK is REAL array, dimension (N) 132*> \endverbatim 133*> 134*> \param[out] RESID 135*> \verbatim 136*> RESID is REAL 137*> The maximum over the number of right hand sides of 138*> norm(B - op(A)*X) / ( norm(op(A)) * norm(X) * EPS ). 139*> \endverbatim 140* 141* Authors: 142* ======== 143* 144*> \author Univ. of Tennessee 145*> \author Univ. of California Berkeley 146*> \author Univ. of Colorado Denver 147*> \author NAG Ltd. 148* 149*> \ingroup single_lin 150* 151* ===================================================================== 152 SUBROUTINE STBT02( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, X, 153 $ LDX, B, LDB, WORK, RESID ) 154* 155* -- LAPACK test routine -- 156* -- LAPACK is a software package provided by Univ. of Tennessee, -- 157* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 158* 159* .. Scalar Arguments .. 160 CHARACTER DIAG, TRANS, UPLO 161 INTEGER KD, LDAB, LDB, LDX, N, NRHS 162 REAL RESID 163* .. 164* .. Array Arguments .. 165 REAL AB( LDAB, * ), B( LDB, * ), WORK( * ), 166 $ X( LDX, * ) 167* .. 168* 169* ===================================================================== 170* 171* .. Parameters .. 172 REAL ZERO, ONE 173 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 174* .. 175* .. Local Scalars .. 176 INTEGER J 177 REAL ANORM, BNORM, EPS, XNORM 178* .. 179* .. External Functions .. 180 LOGICAL LSAME 181 REAL SASUM, SLAMCH, SLANTB 182 EXTERNAL LSAME, SASUM, SLAMCH, SLANTB 183* .. 184* .. External Subroutines .. 185 EXTERNAL SAXPY, SCOPY, STBMV 186* .. 187* .. Intrinsic Functions .. 188 INTRINSIC MAX 189* .. 190* .. Executable Statements .. 191* 192* Quick exit if N = 0 or NRHS = 0 193* 194 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 195 RESID = ZERO 196 RETURN 197 END IF 198* 199* Compute the 1-norm of op(A). 200* 201 IF( LSAME( TRANS, 'N' ) ) THEN 202 ANORM = SLANTB( '1', UPLO, DIAG, N, KD, AB, LDAB, WORK ) 203 ELSE 204 ANORM = SLANTB( 'I', UPLO, DIAG, N, KD, AB, LDAB, WORK ) 205 END IF 206* 207* Exit with RESID = 1/EPS if ANORM = 0. 208* 209 EPS = SLAMCH( 'Epsilon' ) 210 IF( ANORM.LE.ZERO ) THEN 211 RESID = ONE / EPS 212 RETURN 213 END IF 214* 215* Compute the maximum over the number of right hand sides of 216* norm(B - op(A)*X) / ( norm(op(A)) * norm(X) * EPS ). 217* 218 RESID = ZERO 219 DO 10 J = 1, NRHS 220 CALL SCOPY( N, X( 1, J ), 1, WORK, 1 ) 221 CALL STBMV( UPLO, TRANS, DIAG, N, KD, AB, LDAB, WORK, 1 ) 222 CALL SAXPY( N, -ONE, B( 1, J ), 1, WORK, 1 ) 223 BNORM = SASUM( N, WORK, 1 ) 224 XNORM = SASUM( N, X( 1, J ), 1 ) 225 IF( XNORM.LE.ZERO ) THEN 226 RESID = ONE / EPS 227 ELSE 228 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS ) 229 END IF 230 10 CONTINUE 231* 232 RETURN 233* 234* End of STBT02 235* 236 END 237