LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE STPT03( 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 AP( * ), B( LDB, * ), CNORM( * ), WORK( * ), 00015 $ X( LDX, * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * STPT03 computes the residual for the solution to a scaled triangular 00022 * system of equations A*x = s*b or A'*x = s*b when the triangular 00023 * matrix A is stored in packed format. Here A' is the transpose of A, 00024 * s is a scalar, and x and b are N by NRHS matrices. The test ratio is 00025 * the 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 * AP (input) REAL array, dimension (N*(N+1)/2) 00056 * The upper or lower triangular matrix A, packed columnwise in 00057 * a linear array. The j-th column of A is stored in the array 00058 * AP as follows: 00059 * if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j; 00060 * if UPLO = 'L', 00061 * AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n. 00062 * 00063 * SCALE (input) REAL 00064 * The scaling factor s used in solving the triangular system. 00065 * 00066 * CNORM (input) REAL array, dimension (N) 00067 * The 1-norms of the columns of A, not counting the diagonal. 00068 * 00069 * TSCAL (input) REAL 00070 * The scaling factor used in computing the 1-norms in CNORM. 00071 * CNORM actually contains the column norms of TSCAL*A. 00072 * 00073 * X (input) REAL array, dimension (LDX,NRHS) 00074 * The computed solution vectors for the system of linear 00075 * equations. 00076 * 00077 * LDX (input) INTEGER 00078 * The leading dimension of the array X. LDX >= max(1,N). 00079 * 00080 * B (input) REAL array, dimension (LDB,NRHS) 00081 * The right hand side vectors for the system of linear 00082 * equations. 00083 * 00084 * LDB (input) INTEGER 00085 * The leading dimension of the array B. LDB >= max(1,N). 00086 * 00087 * WORK (workspace) REAL array, dimension (N) 00088 * 00089 * RESID (output) REAL 00090 * The maximum over the number of right hand sides of 00091 * norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). 00092 * 00093 * ===================================================================== 00094 * 00095 * .. Parameters .. 00096 REAL ONE, ZERO 00097 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) 00098 * .. 00099 * .. Local Scalars .. 00100 INTEGER IX, J, JJ 00101 REAL BIGNUM, EPS, ERR, SMLNUM, TNORM, XNORM, XSCAL 00102 * .. 00103 * .. External Functions .. 00104 LOGICAL LSAME 00105 INTEGER ISAMAX 00106 REAL SLAMCH 00107 EXTERNAL LSAME, ISAMAX, SLAMCH 00108 * .. 00109 * .. External Subroutines .. 00110 EXTERNAL SAXPY, SCOPY, SLABAD, SSCAL, STPMV 00111 * .. 00112 * .. Intrinsic Functions .. 00113 INTRINSIC ABS, MAX, REAL 00114 * .. 00115 * .. Executable Statements .. 00116 * 00117 * Quick exit if N = 0. 00118 * 00119 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 00120 RESID = ZERO 00121 RETURN 00122 END IF 00123 EPS = SLAMCH( 'Epsilon' ) 00124 SMLNUM = SLAMCH( 'Safe minimum' ) 00125 BIGNUM = ONE / SMLNUM 00126 CALL SLABAD( SMLNUM, BIGNUM ) 00127 * 00128 * Compute the norm of the triangular matrix A using the column 00129 * norms already computed by SLATPS. 00130 * 00131 TNORM = ZERO 00132 IF( LSAME( DIAG, 'N' ) ) THEN 00133 IF( LSAME( UPLO, 'U' ) ) THEN 00134 JJ = 1 00135 DO 10 J = 1, N 00136 TNORM = MAX( TNORM, TSCAL*ABS( AP( JJ ) )+CNORM( J ) ) 00137 JJ = JJ + J + 1 00138 10 CONTINUE 00139 ELSE 00140 JJ = 1 00141 DO 20 J = 1, N 00142 TNORM = MAX( TNORM, TSCAL*ABS( AP( JJ ) )+CNORM( J ) ) 00143 JJ = JJ + N - J + 1 00144 20 CONTINUE 00145 END IF 00146 ELSE 00147 DO 30 J = 1, N 00148 TNORM = MAX( TNORM, TSCAL+CNORM( J ) ) 00149 30 CONTINUE 00150 END IF 00151 * 00152 * Compute the maximum over the number of right hand sides of 00153 * norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ). 00154 * 00155 RESID = ZERO 00156 DO 40 J = 1, NRHS 00157 CALL SCOPY( N, X( 1, J ), 1, WORK, 1 ) 00158 IX = ISAMAX( N, WORK, 1 ) 00159 XNORM = MAX( ONE, ABS( X( IX, J ) ) ) 00160 XSCAL = ( ONE / XNORM ) / REAL( N ) 00161 CALL SSCAL( N, XSCAL, WORK, 1 ) 00162 CALL STPMV( UPLO, TRANS, DIAG, N, AP, WORK, 1 ) 00163 CALL SAXPY( N, -SCALE*XSCAL, B( 1, J ), 1, WORK, 1 ) 00164 IX = ISAMAX( N, WORK, 1 ) 00165 ERR = TSCAL*ABS( WORK( IX ) ) 00166 IX = ISAMAX( N, X( 1, J ), 1 ) 00167 XNORM = ABS( X( IX, J ) ) 00168 IF( ERR*SMLNUM.LE.XNORM ) THEN 00169 IF( XNORM.GT.ZERO ) 00170 $ ERR = ERR / XNORM 00171 ELSE 00172 IF( ERR.GT.ZERO ) 00173 $ ERR = ONE / EPS 00174 END IF 00175 IF( ERR*SMLNUM.LE.TNORM ) THEN 00176 IF( TNORM.GT.ZERO ) 00177 $ ERR = ERR / TNORM 00178 ELSE 00179 IF( ERR.GT.ZERO ) 00180 $ ERR = ONE / EPS 00181 END IF 00182 RESID = MAX( RESID, ERR ) 00183 40 CONTINUE 00184 * 00185 RETURN 00186 * 00187 * End of STPT03 00188 * 00189 END