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