LAPACK 3.3.0
|
00001 SUBROUTINE CTRT03( 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 REAL RESID, SCALE, TSCAL 00012 * .. 00013 * .. Array Arguments .. 00014 REAL CNORM( * ) 00015 COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ), 00016 $ X( LDX, * ) 00017 * .. 00018 * 00019 * Purpose 00020 * ======= 00021 * 00022 * CTRT03 computes the residual for the solution to a scaled triangular 00023 * system of equations A*x = s*b, A**T *x = s*b, or A**H *x = s*b. 00024 * Here A is a triangular matrix, A**T denotes the transpose of A, A**H 00025 * denotes the conjugate transpose of A, s is a scalar, and x and b are 00026 * N by NRHS matrices. The test ratio is the maximum over the number of 00027 * right hand sides of 00028 * norm(s*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 = s*b (No transpose) 00042 * = 'T': A**T *x = s*b (Transpose) 00043 * = 'C': A**H *x = s*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 * NRHS (input) INTEGER 00054 * The number of right hand sides, i.e., the number of columns 00055 * of the matrices X and B. NRHS >= 0. 00056 * 00057 * A (input) COMPLEX array, dimension (LDA,N) 00058 * The triangular matrix A. If UPLO = 'U', the leading n by n 00059 * upper triangular part of the array A contains the upper 00060 * triangular matrix, and the strictly lower triangular part of 00061 * A is not referenced. If UPLO = 'L', the leading n by n lower 00062 * triangular part of the array A contains the lower triangular 00063 * matrix, and the strictly upper triangular part of A is not 00064 * referenced. If DIAG = 'U', the diagonal elements of A are 00065 * also not referenced and are assumed to be 1. 00066 * 00067 * LDA (input) INTEGER 00068 * The leading dimension of the array A. LDA >= max(1,N). 00069 * 00070 * SCALE (input) REAL 00071 * The scaling factor s used in solving the triangular system. 00072 * 00073 * CNORM (input) REAL array, dimension (N) 00074 * The 1-norms of the columns of A, not counting the diagonal. 00075 * 00076 * TSCAL (input) REAL 00077 * The scaling factor used in computing the 1-norms in CNORM. 00078 * CNORM actually contains the column norms of TSCAL*A. 00079 * 00080 * X (input) COMPLEX array, dimension (LDX,NRHS) 00081 * The computed solution vectors for the system of linear 00082 * equations. 00083 * 00084 * LDX (input) INTEGER 00085 * The leading dimension of the array X. LDX >= max(1,N). 00086 * 00087 * B (input) COMPLEX array, dimension (LDB,NRHS) 00088 * The right hand side vectors for the system of linear 00089 * equations. 00090 * 00091 * LDB (input) INTEGER 00092 * The leading dimension of the array B. LDB >= max(1,N). 00093 * 00094 * WORK (workspace) COMPLEX array, dimension (N) 00095 * 00096 * RESID (output) REAL 00097 * The maximum over the number of right hand sides of 00098 * norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). 00099 * 00100 * ===================================================================== 00101 * 00102 * .. Parameters .. 00103 REAL ONE, ZERO 00104 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) 00105 * .. 00106 * .. Local Scalars .. 00107 INTEGER IX, J 00108 REAL EPS, ERR, SMLNUM, TNORM, XNORM, XSCAL 00109 * .. 00110 * .. External Functions .. 00111 LOGICAL LSAME 00112 INTEGER ICAMAX 00113 REAL SLAMCH 00114 EXTERNAL LSAME, ICAMAX, SLAMCH 00115 * .. 00116 * .. External Subroutines .. 00117 EXTERNAL CAXPY, CCOPY, CSSCAL, CTRMV 00118 * .. 00119 * .. Intrinsic Functions .. 00120 INTRINSIC ABS, CMPLX, MAX, REAL 00121 * .. 00122 * .. Executable Statements .. 00123 * 00124 * Quick exit if N = 0 00125 * 00126 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 00127 RESID = ZERO 00128 RETURN 00129 END IF 00130 EPS = SLAMCH( 'Epsilon' ) 00131 SMLNUM = SLAMCH( 'Safe minimum' ) 00132 * 00133 * Compute the norm of the triangular matrix A using the column 00134 * norms already computed by CLATRS. 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 CCOPY( N, X( 1, J ), 1, WORK, 1 ) 00153 IX = ICAMAX( N, WORK, 1 ) 00154 XNORM = MAX( ONE, ABS( X( IX, J ) ) ) 00155 XSCAL = ( ONE / XNORM ) / REAL( N ) 00156 CALL CSSCAL( N, XSCAL, WORK, 1 ) 00157 CALL CTRMV( UPLO, TRANS, DIAG, N, A, LDA, WORK, 1 ) 00158 CALL CAXPY( N, CMPLX( -SCALE*XSCAL ), B( 1, J ), 1, WORK, 1 ) 00159 IX = ICAMAX( N, WORK, 1 ) 00160 ERR = TSCAL*ABS( WORK( IX ) ) 00161 IX = ICAMAX( 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 CTRT03 00183 * 00184 END