![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SPPT02 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 * Definition: 00009 * =========== 00010 * 00011 * SUBROUTINE SPPT02( UPLO, N, NRHS, A, X, LDX, B, LDB, RWORK, 00012 * RESID ) 00013 * 00014 * .. Scalar Arguments .. 00015 * CHARACTER UPLO 00016 * INTEGER LDB, LDX, N, NRHS 00017 * REAL RESID 00018 * .. 00019 * .. Array Arguments .. 00020 * REAL A( * ), B( LDB, * ), RWORK( * ), X( LDX, * ) 00021 * .. 00022 * 00023 * 00024 *> \par Purpose: 00025 * ============= 00026 *> 00027 *> \verbatim 00028 *> 00029 *> SPPT02 computes the residual in the solution of a symmetric system 00030 *> of linear equations A*x = b when packed storage is used for the 00031 *> coefficient matrix. The ratio computed is 00032 *> 00033 *> RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS), 00034 *> 00035 *> where EPS is the machine precision. 00036 *> \endverbatim 00037 * 00038 * Arguments: 00039 * ========== 00040 * 00041 *> \param[in] UPLO 00042 *> \verbatim 00043 *> UPLO is CHARACTER*1 00044 *> Specifies whether the upper or lower triangular part of the 00045 *> symmetric matrix A is stored: 00046 *> = 'U': Upper triangular 00047 *> = 'L': Lower triangular 00048 *> \endverbatim 00049 *> 00050 *> \param[in] N 00051 *> \verbatim 00052 *> N is INTEGER 00053 *> The number of rows and columns of the matrix A. N >= 0. 00054 *> \endverbatim 00055 *> 00056 *> \param[in] NRHS 00057 *> \verbatim 00058 *> NRHS is INTEGER 00059 *> The number of columns of B, the matrix of right hand sides. 00060 *> NRHS >= 0. 00061 *> \endverbatim 00062 *> 00063 *> \param[in] A 00064 *> \verbatim 00065 *> A is REAL array, dimension (N*(N+1)/2) 00066 *> The original symmetric matrix A, stored as a packed 00067 *> triangular matrix. 00068 *> \endverbatim 00069 *> 00070 *> \param[in] X 00071 *> \verbatim 00072 *> X is REAL array, dimension (LDX,NRHS) 00073 *> The computed solution vectors for the system of linear 00074 *> equations. 00075 *> \endverbatim 00076 *> 00077 *> \param[in] LDX 00078 *> \verbatim 00079 *> LDX is INTEGER 00080 *> The leading dimension of the array X. LDX >= max(1,N). 00081 *> \endverbatim 00082 *> 00083 *> \param[in,out] B 00084 *> \verbatim 00085 *> B is REAL array, dimension (LDB,NRHS) 00086 *> On entry, the right hand side vectors for the system of 00087 *> linear equations. 00088 *> On exit, B is overwritten with the difference B - A*X. 00089 *> \endverbatim 00090 *> 00091 *> \param[in] LDB 00092 *> \verbatim 00093 *> LDB is INTEGER 00094 *> The leading dimension of the array B. LDB >= max(1,N). 00095 *> \endverbatim 00096 *> 00097 *> \param[out] RWORK 00098 *> \verbatim 00099 *> RWORK is REAL array, dimension (N) 00100 *> \endverbatim 00101 *> 00102 *> \param[out] RESID 00103 *> \verbatim 00104 *> RESID is REAL 00105 *> The maximum over the number of right hand sides of 00106 *> norm(B - A*X) / ( norm(A) * norm(X) * EPS ). 00107 *> \endverbatim 00108 * 00109 * Authors: 00110 * ======== 00111 * 00112 *> \author Univ. of Tennessee 00113 *> \author Univ. of California Berkeley 00114 *> \author Univ. of Colorado Denver 00115 *> \author NAG Ltd. 00116 * 00117 *> \date November 2011 00118 * 00119 *> \ingroup single_lin 00120 * 00121 * ===================================================================== 00122 SUBROUTINE SPPT02( UPLO, N, NRHS, A, X, LDX, B, LDB, RWORK, 00123 $ RESID ) 00124 * 00125 * -- LAPACK test routine (version 3.4.0) -- 00126 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00127 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00128 * November 2011 00129 * 00130 * .. Scalar Arguments .. 00131 CHARACTER UPLO 00132 INTEGER LDB, LDX, N, NRHS 00133 REAL RESID 00134 * .. 00135 * .. Array Arguments .. 00136 REAL A( * ), B( LDB, * ), RWORK( * ), X( LDX, * ) 00137 * .. 00138 * 00139 * ===================================================================== 00140 * 00141 * .. Parameters .. 00142 REAL ZERO, ONE 00143 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00144 * .. 00145 * .. Local Scalars .. 00146 INTEGER J 00147 REAL ANORM, BNORM, EPS, XNORM 00148 * .. 00149 * .. External Functions .. 00150 REAL SASUM, SLAMCH, SLANSP 00151 EXTERNAL SASUM, SLAMCH, SLANSP 00152 * .. 00153 * .. External Subroutines .. 00154 EXTERNAL SSPMV 00155 * .. 00156 * .. Intrinsic Functions .. 00157 INTRINSIC MAX 00158 * .. 00159 * .. Executable Statements .. 00160 * 00161 * Quick exit if N = 0 or NRHS = 0. 00162 * 00163 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN 00164 RESID = ZERO 00165 RETURN 00166 END IF 00167 * 00168 * Exit with RESID = 1/EPS if ANORM = 0. 00169 * 00170 EPS = SLAMCH( 'Epsilon' ) 00171 ANORM = SLANSP( '1', UPLO, N, A, RWORK ) 00172 IF( ANORM.LE.ZERO ) THEN 00173 RESID = ONE / EPS 00174 RETURN 00175 END IF 00176 * 00177 * Compute B - A*X for the matrix of right hand sides B. 00178 * 00179 DO 10 J = 1, NRHS 00180 CALL SSPMV( UPLO, N, -ONE, A, X( 1, J ), 1, ONE, B( 1, J ), 1 ) 00181 10 CONTINUE 00182 * 00183 * Compute the maximum over the number of right hand sides of 00184 * norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) . 00185 * 00186 RESID = ZERO 00187 DO 20 J = 1, NRHS 00188 BNORM = SASUM( N, B( 1, J ), 1 ) 00189 XNORM = SASUM( N, X( 1, J ), 1 ) 00190 IF( XNORM.LE.ZERO ) THEN 00191 RESID = ONE / EPS 00192 ELSE 00193 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS ) 00194 END IF 00195 20 CONTINUE 00196 * 00197 RETURN 00198 * 00199 * End of SPPT02 00200 * 00201 END