LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE DTRT03( UPLO, TRANS, DIAG, N, NRHS, A, LDA, SCALE, 00002 $ CNORM, TSCAL, X, LDX, B, LDB, WORK, 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 LDA, LDB, LDX, N, NRHS 00011 DOUBLE PRECISION RESID, SCALE, TSCAL 00012 * .. 00013 * .. Array Arguments .. 00014 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), CNORM( * ), 00015 $ WORK( * ), X( LDX, * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * DTRT03 computes the residual for the solution to a scaled triangular 00022 * system of equations A*x = s*b or A'*x = s*b. 00023 * Here A is a triangular matrix, A' is the transpose of A, s is a 00024 * scalar, and x and b are N by NRHS matrices. The test ratio is the 00025 * maximum over the number of right hand sides of 00026 * norm(s*b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), 00027 * where op(A) denotes A or A' and EPS is the machine epsilon. 00028 * 00029 * Arguments 00030 * ========= 00031 * 00032 * UPLO (input) CHARACTER*1 00033 * Specifies whether the matrix A is upper or lower triangular. 00034 * = 'U': Upper triangular 00035 * = 'L': Lower triangular 00036 * 00037 * TRANS (input) CHARACTER*1 00038 * Specifies the operation applied to A. 00039 * = 'N': A *x = s*b (No transpose) 00040 * = 'T': A'*x = s*b (Transpose) 00041 * = 'C': A'*x = s*b (Conjugate transpose = Transpose) 00042 * 00043 * DIAG (input) CHARACTER*1 00044 * Specifies whether or not the matrix A is unit triangular. 00045 * = 'N': Non-unit triangular 00046 * = 'U': Unit triangular 00047 * 00048 * N (input) INTEGER 00049 * The order of the matrix A. N >= 0. 00050 * 00051 * NRHS (input) INTEGER 00052 * The number of right hand sides, i.e., the number of columns 00053 * of the matrices X and B. NRHS >= 0. 00054 * 00055 * A (input) DOUBLE PRECISION array, dimension (LDA,N) 00056 * The triangular matrix A. If UPLO = 'U', the leading n by n 00057 * upper triangular part of the array A contains the upper 00058 * triangular matrix, and the strictly lower triangular part of 00059 * A is not referenced. If UPLO = 'L', the leading n by n lower 00060 * triangular part of the array A contains the lower triangular 00061 * matrix, and the strictly upper triangular part of A is not 00062 * referenced. If DIAG = 'U', the diagonal elements of A are 00063 * also not referenced and are assumed to be 1. 00064 * 00065 * LDA (input) INTEGER 00066 * The leading dimension of the array A. LDA >= max(1,N). 00067 * 00068 * SCALE (input) DOUBLE PRECISION 00069 * The scaling factor s used in solving the triangular system. 00070 * 00071 * CNORM (input) DOUBLE PRECISION array, dimension (N) 00072 * The 1-norms of the columns of A, not counting the diagonal. 00073 * 00074 * TSCAL (input) DOUBLE PRECISION 00075 * The scaling factor used in computing the 1-norms in CNORM. 00076 * CNORM actually contains the column norms of TSCAL*A. 00077 * 00078 * X (input) DOUBLE PRECISION array, dimension (LDX,NRHS) 00079 * The computed solution vectors for the system of linear 00080 * equations. 00081 * 00082 * LDX (input) INTEGER 00083 * The leading dimension of the array X. LDX >= max(1,N). 00084 * 00085 * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) 00086 * The right hand side vectors for the system of linear 00087 * equations. 00088 * 00089 * LDB (input) INTEGER 00090 * The leading dimension of the array B. LDB >= max(1,N). 00091 * 00092 * WORK (workspace) DOUBLE PRECISION array, dimension (N) 00093 * 00094 * RESID (output) DOUBLE PRECISION 00095 * The maximum over the number of right hand sides of 00096 * norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). 00097 * 00098 * ===================================================================== 00099 * 00100 * .. Parameters .. 00101 DOUBLE PRECISION ONE, ZERO 00102 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 ) 00103 * .. 00104 * .. Local Scalars .. 00105 INTEGER IX, J 00106 DOUBLE PRECISION BIGNUM, EPS, ERR, SMLNUM, TNORM, XNORM, XSCAL 00107 * .. 00108 * .. External Functions .. 00109 LOGICAL LSAME 00110 INTEGER IDAMAX 00111 DOUBLE PRECISION DLAMCH 00112 EXTERNAL LSAME, IDAMAX, DLAMCH 00113 * .. 00114 * .. External Subroutines .. 00115 EXTERNAL DAXPY, DCOPY, DLABAD, DSCAL, DTRMV 00116 * .. 00117 * .. Intrinsic Functions .. 00118 INTRINSIC ABS, DBLE, MAX 00119 * .. 00120 * .. Executable Statements .. 00121 * 00122 * Quick exit if N = 0 00123 * 00124 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 00125 RESID = ZERO 00126 RETURN 00127 END IF 00128 EPS = DLAMCH( 'Epsilon' ) 00129 SMLNUM = DLAMCH( 'Safe minimum' ) 00130 BIGNUM = ONE / SMLNUM 00131 CALL DLABAD( SMLNUM, BIGNUM ) 00132 * 00133 * Compute the norm of the triangular matrix A using the column 00134 * norms already computed by DLATRS. 00135 * 00136 TNORM = ZERO 00137 IF( LSAME( DIAG, 'N' ) ) THEN 00138 DO 10 J = 1, N 00139 TNORM = MAX( TNORM, TSCAL*ABS( A( J, J ) )+CNORM( J ) ) 00140 10 CONTINUE 00141 ELSE 00142 DO 20 J = 1, N 00143 TNORM = MAX( TNORM, TSCAL+CNORM( J ) ) 00144 20 CONTINUE 00145 END IF 00146 * 00147 * Compute the maximum over the number of right hand sides of 00148 * norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). 00149 * 00150 RESID = ZERO 00151 DO 30 J = 1, NRHS 00152 CALL DCOPY( N, X( 1, J ), 1, WORK, 1 ) 00153 IX = IDAMAX( N, WORK, 1 ) 00154 XNORM = MAX( ONE, ABS( X( IX, J ) ) ) 00155 XSCAL = ( ONE / XNORM ) / DBLE( N ) 00156 CALL DSCAL( N, XSCAL, WORK, 1 ) 00157 CALL DTRMV( UPLO, TRANS, DIAG, N, A, LDA, WORK, 1 ) 00158 CALL DAXPY( N, -SCALE*XSCAL, B( 1, J ), 1, WORK, 1 ) 00159 IX = IDAMAX( N, WORK, 1 ) 00160 ERR = TSCAL*ABS( WORK( IX ) ) 00161 IX = IDAMAX( N, X( 1, J ), 1 ) 00162 XNORM = ABS( X( IX, J ) ) 00163 IF( ERR*SMLNUM.LE.XNORM ) THEN 00164 IF( XNORM.GT.ZERO ) 00165 $ ERR = ERR / XNORM 00166 ELSE 00167 IF( ERR.GT.ZERO ) 00168 $ ERR = ONE / EPS 00169 END IF 00170 IF( ERR*SMLNUM.LE.TNORM ) THEN 00171 IF( TNORM.GT.ZERO ) 00172 $ ERR = ERR / TNORM 00173 ELSE 00174 IF( ERR.GT.ZERO ) 00175 $ ERR = ONE / EPS 00176 END IF 00177 RESID = MAX( RESID, ERR ) 00178 30 CONTINUE 00179 * 00180 RETURN 00181 * 00182 * End of DTRT03 00183 * 00184 END