LAPACK 3.3.0
|
00001 SUBROUTINE ZTBT02( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, X, 00002 $ LDX, B, LDB, WORK, RWORK, RESID ) 00003 * 00004 * -- LAPACK test routine (version 3.1) -- 00005 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 00006 * November 2006 00007 * 00008 * .. Scalar Arguments .. 00009 CHARACTER DIAG, TRANS, UPLO 00010 INTEGER KD, LDAB, LDB, LDX, N, NRHS 00011 DOUBLE PRECISION RESID 00012 * .. 00013 * .. Array Arguments .. 00014 DOUBLE PRECISION RWORK( * ) 00015 COMPLEX*16 AB( LDAB, * ), B( LDB, * ), WORK( * ), 00016 $ X( LDX, * ) 00017 * .. 00018 * 00019 * Purpose 00020 * ======= 00021 * 00022 * ZTBT02 computes the residual for the computed solution to a 00023 * triangular system of linear equations A*x = b, A**T *x = b, or 00024 * A**H *x = b when A is a triangular band matrix. Here A**T denotes 00025 * the transpose of A, A**H denotes the conjugate transpose of A, and 00026 * x and b are N by NRHS matrices. The test ratio is the maximum over 00027 * the number of right hand sides of 00028 * norm(b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), 00029 * where op(A) denotes A, A**T, or A**H, and EPS is the machine epsilon. 00030 * 00031 * Arguments 00032 * ========= 00033 * 00034 * UPLO (input) CHARACTER*1 00035 * Specifies whether the matrix A is upper or lower triangular. 00036 * = 'U': Upper triangular 00037 * = 'L': Lower triangular 00038 * 00039 * TRANS (input) CHARACTER*1 00040 * Specifies the operation applied to A. 00041 * = 'N': A *x = b (No transpose) 00042 * = 'T': A**T *x = b (Transpose) 00043 * = 'C': A**H *x = b (Conjugate transpose) 00044 * 00045 * DIAG (input) CHARACTER*1 00046 * Specifies whether or not the matrix A is unit triangular. 00047 * = 'N': Non-unit triangular 00048 * = 'U': Unit triangular 00049 * 00050 * N (input) INTEGER 00051 * The order of the matrix A. N >= 0. 00052 * 00053 * KD (input) INTEGER 00054 * The number of superdiagonals or subdiagonals of the 00055 * triangular band matrix A. KD >= 0. 00056 * 00057 * NRHS (input) INTEGER 00058 * The number of right hand sides, i.e., the number of columns 00059 * of the matrices X and B. NRHS >= 0. 00060 * 00061 * AB (input) COMPLEX*16 array, dimension (LDA,N) 00062 * The upper or lower triangular band matrix A, stored in the 00063 * first kd+1 rows of the array. The j-th column of A is stored 00064 * in the j-th column of the array AB as follows: 00065 * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; 00066 * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). 00067 * 00068 * LDAB (input) INTEGER 00069 * The leading dimension of the array AB. LDAB >= max(1,KD+1). 00070 * 00071 * X (input) COMPLEX*16 array, dimension (LDX,NRHS) 00072 * The computed solution vectors for the system of linear 00073 * equations. 00074 * 00075 * LDX (input) INTEGER 00076 * The leading dimension of the array X. LDX >= max(1,N). 00077 * 00078 * B (input) COMPLEX*16 array, dimension (LDB,NRHS) 00079 * The right hand side vectors for the system of linear 00080 * equations. 00081 * 00082 * LDB (input) INTEGER 00083 * The leading dimension of the array B. LDB >= max(1,N). 00084 * 00085 * WORK (workspace) COMPLEX*16 array, dimension (N) 00086 * 00087 * RWORK (workspace) DOUBLE PRECISION array, dimension (N) 00088 * 00089 * RESID (output) DOUBLE PRECISION 00090 * The maximum over the number of right hand sides of 00091 * norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). 00092 * 00093 * ===================================================================== 00094 * 00095 * .. Parameters .. 00096 DOUBLE PRECISION ZERO, ONE 00097 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) 00098 * .. 00099 * .. Local Scalars .. 00100 INTEGER J 00101 DOUBLE PRECISION ANORM, BNORM, EPS, XNORM 00102 * .. 00103 * .. External Functions .. 00104 LOGICAL LSAME 00105 DOUBLE PRECISION DLAMCH, DZASUM, ZLANTB 00106 EXTERNAL LSAME, DLAMCH, DZASUM, ZLANTB 00107 * .. 00108 * .. External Subroutines .. 00109 EXTERNAL ZAXPY, ZCOPY, ZTBMV 00110 * .. 00111 * .. Intrinsic Functions .. 00112 INTRINSIC DCMPLX, MAX 00113 * .. 00114 * .. Executable Statements .. 00115 * 00116 * Quick exit if N = 0 or NRHS = 0 00117 * 00118 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 00119 RESID = ZERO 00120 RETURN 00121 END IF 00122 * 00123 * Compute the 1-norm of A or A'. 00124 * 00125 IF( LSAME( TRANS, 'N' ) ) THEN 00126 ANORM = ZLANTB( '1', UPLO, DIAG, N, KD, AB, LDAB, RWORK ) 00127 ELSE 00128 ANORM = ZLANTB( 'I', UPLO, DIAG, N, KD, AB, LDAB, RWORK ) 00129 END IF 00130 * 00131 * Exit with RESID = 1/EPS if ANORM = 0. 00132 * 00133 EPS = DLAMCH( 'Epsilon' ) 00134 IF( ANORM.LE.ZERO ) THEN 00135 RESID = ONE / EPS 00136 RETURN 00137 END IF 00138 * 00139 * Compute the maximum over the number of right hand sides of 00140 * norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). 00141 * 00142 RESID = ZERO 00143 DO 10 J = 1, NRHS 00144 CALL ZCOPY( N, X( 1, J ), 1, WORK, 1 ) 00145 CALL ZTBMV( UPLO, TRANS, DIAG, N, KD, AB, LDAB, WORK, 1 ) 00146 CALL ZAXPY( N, DCMPLX( -ONE ), B( 1, J ), 1, WORK, 1 ) 00147 BNORM = DZASUM( N, WORK, 1 ) 00148 XNORM = DZASUM( N, X( 1, J ), 1 ) 00149 IF( XNORM.LE.ZERO ) THEN 00150 RESID = ONE / EPS 00151 ELSE 00152 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS ) 00153 END IF 00154 10 CONTINUE 00155 * 00156 RETURN 00157 * 00158 * End of ZTBT02 00159 * 00160 END