LAPACK 3.3.0
|
00001 SUBROUTINE SPOT02( UPLO, N, NRHS, A, LDA, X, LDX, B, LDB, RWORK, 00002 $ 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 UPLO 00010 INTEGER LDA, LDB, LDX, N, NRHS 00011 REAL RESID 00012 * .. 00013 * .. Array Arguments .. 00014 REAL A( LDA, * ), B( LDB, * ), RWORK( * ), 00015 $ X( LDX, * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * SPOT02 computes the residual for the solution of a symmetric system 00022 * of linear equations A*x = b: 00023 * 00024 * RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS ), 00025 * 00026 * where EPS is the machine epsilon. 00027 * 00028 * Arguments 00029 * ========= 00030 * 00031 * UPLO (input) CHARACTER*1 00032 * Specifies whether the upper or lower triangular part of the 00033 * symmetric matrix A is stored: 00034 * = 'U': Upper triangular 00035 * = 'L': Lower triangular 00036 * 00037 * N (input) INTEGER 00038 * The number of rows and columns of the matrix A. N >= 0. 00039 * 00040 * NRHS (input) INTEGER 00041 * The number of columns of B, the matrix of right hand sides. 00042 * NRHS >= 0. 00043 * 00044 * A (input) REAL array, dimension (LDA,N) 00045 * The original symmetric matrix A. 00046 * 00047 * LDA (input) INTEGER 00048 * The leading dimension of the array A. LDA >= max(1,N) 00049 * 00050 * X (input) REAL array, dimension (LDX,NRHS) 00051 * The computed solution vectors for the system of linear 00052 * equations. 00053 * 00054 * LDX (input) INTEGER 00055 * The leading dimension of the array X. LDX >= max(1,N). 00056 * 00057 * B (input/output) REAL array, dimension (LDB,NRHS) 00058 * On entry, the right hand side vectors for the system of 00059 * linear equations. 00060 * On exit, B is overwritten with the difference B - A*X. 00061 * 00062 * LDB (input) INTEGER 00063 * The leading dimension of the array B. LDB >= max(1,N). 00064 * 00065 * RWORK (workspace) REAL array, dimension (N) 00066 * 00067 * RESID (output) REAL 00068 * The maximum over the number of right hand sides of 00069 * norm(B - A*X) / ( norm(A) * norm(X) * EPS ). 00070 * 00071 * ===================================================================== 00072 * 00073 * .. Parameters .. 00074 REAL ZERO, ONE 00075 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00076 * .. 00077 * .. Local Scalars .. 00078 INTEGER J 00079 REAL ANORM, BNORM, EPS, XNORM 00080 * .. 00081 * .. External Functions .. 00082 REAL SASUM, SLAMCH, SLANSY 00083 EXTERNAL SASUM, SLAMCH, SLANSY 00084 * .. 00085 * .. External Subroutines .. 00086 EXTERNAL SSYMM 00087 * .. 00088 * .. Intrinsic Functions .. 00089 INTRINSIC MAX 00090 * .. 00091 * .. Executable Statements .. 00092 * 00093 * Quick exit if N = 0 or NRHS = 0. 00094 * 00095 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 00096 RESID = ZERO 00097 RETURN 00098 END IF 00099 * 00100 * Exit with RESID = 1/EPS if ANORM = 0. 00101 * 00102 EPS = SLAMCH( 'Epsilon' ) 00103 ANORM = SLANSY( '1', UPLO, N, A, LDA, RWORK ) 00104 IF( ANORM.LE.ZERO ) THEN 00105 RESID = ONE / EPS 00106 RETURN 00107 END IF 00108 * 00109 * Compute B - A*X 00110 * 00111 CALL SSYMM( 'Left', UPLO, N, NRHS, -ONE, A, LDA, X, LDX, ONE, B, 00112 $ LDB ) 00113 * 00114 * Compute the maximum over the number of right hand sides of 00115 * norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) . 00116 * 00117 RESID = ZERO 00118 DO 10 J = 1, NRHS 00119 BNORM = SASUM( N, B( 1, J ), 1 ) 00120 XNORM = SASUM( N, X( 1, J ), 1 ) 00121 IF( XNORM.LE.ZERO ) THEN 00122 RESID = ONE / EPS 00123 ELSE 00124 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS ) 00125 END IF 00126 10 CONTINUE 00127 * 00128 RETURN 00129 * 00130 * End of SPOT02 00131 * 00132 END