![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SGET02 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 SGET02( TRANS, M, N, NRHS, A, LDA, X, LDX, B, LDB, 00012 * RWORK, RESID ) 00013 * 00014 * .. Scalar Arguments .. 00015 * CHARACTER TRANS 00016 * INTEGER LDA, LDB, LDX, M, N, NRHS 00017 * REAL RESID 00018 * .. 00019 * .. Array Arguments .. 00020 * REAL A( LDA, * ), B( LDB, * ), RWORK( * ), 00021 * $ X( LDX, * ) 00022 * .. 00023 * 00024 * 00025 *> \par Purpose: 00026 * ============= 00027 *> 00028 *> \verbatim 00029 *> 00030 *> SGET02 computes the residual for a solution of a system of linear 00031 *> equations A*x = b or A'*x = b: 00032 *> RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS ), 00033 *> where EPS is the machine epsilon. 00034 *> \endverbatim 00035 * 00036 * Arguments: 00037 * ========== 00038 * 00039 *> \param[in] TRANS 00040 *> \verbatim 00041 *> TRANS is CHARACTER*1 00042 *> Specifies the form of the system of equations: 00043 *> = 'N': A *x = b 00044 *> = 'T': A'*x = b, where A' is the transpose of A 00045 *> = 'C': A'*x = b, where A' is the transpose of A 00046 *> \endverbatim 00047 *> 00048 *> \param[in] M 00049 *> \verbatim 00050 *> M is INTEGER 00051 *> The number of rows of the matrix A. M >= 0. 00052 *> \endverbatim 00053 *> 00054 *> \param[in] N 00055 *> \verbatim 00056 *> N is INTEGER 00057 *> The number of columns of the matrix A. N >= 0. 00058 *> \endverbatim 00059 *> 00060 *> \param[in] NRHS 00061 *> \verbatim 00062 *> NRHS is INTEGER 00063 *> The number of columns of B, the matrix of right hand sides. 00064 *> NRHS >= 0. 00065 *> \endverbatim 00066 *> 00067 *> \param[in] A 00068 *> \verbatim 00069 *> A is REAL array, dimension (LDA,N) 00070 *> The original M x N matrix A. 00071 *> \endverbatim 00072 *> 00073 *> \param[in] LDA 00074 *> \verbatim 00075 *> LDA is INTEGER 00076 *> The leading dimension of the array A. LDA >= max(1,M). 00077 *> \endverbatim 00078 *> 00079 *> \param[in] X 00080 *> \verbatim 00081 *> X is REAL array, dimension (LDX,NRHS) 00082 *> The computed solution vectors for the system of linear 00083 *> equations. 00084 *> \endverbatim 00085 *> 00086 *> \param[in] LDX 00087 *> \verbatim 00088 *> LDX is INTEGER 00089 *> The leading dimension of the array X. If TRANS = 'N', 00090 *> LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M). 00091 *> \endverbatim 00092 *> 00093 *> \param[in,out] B 00094 *> \verbatim 00095 *> B is REAL array, dimension (LDB,NRHS) 00096 *> On entry, the right hand side vectors for the system of 00097 *> linear equations. 00098 *> On exit, B is overwritten with the difference B - A*X. 00099 *> \endverbatim 00100 *> 00101 *> \param[in] LDB 00102 *> \verbatim 00103 *> LDB is INTEGER 00104 *> The leading dimension of the array B. IF TRANS = 'N', 00105 *> LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N). 00106 *> \endverbatim 00107 *> 00108 *> \param[out] RWORK 00109 *> \verbatim 00110 *> RWORK is REAL array, dimension (M) 00111 *> \endverbatim 00112 *> 00113 *> \param[out] RESID 00114 *> \verbatim 00115 *> RESID is REAL 00116 *> The maximum over the number of right hand sides of 00117 *> norm(B - A*X) / ( norm(A) * norm(X) * EPS ). 00118 *> \endverbatim 00119 * 00120 * Authors: 00121 * ======== 00122 * 00123 *> \author Univ. of Tennessee 00124 *> \author Univ. of California Berkeley 00125 *> \author Univ. of Colorado Denver 00126 *> \author NAG Ltd. 00127 * 00128 *> \date November 2011 00129 * 00130 *> \ingroup single_lin 00131 * 00132 * ===================================================================== 00133 SUBROUTINE SGET02( TRANS, M, N, NRHS, A, LDA, X, LDX, B, LDB, 00134 $ RWORK, RESID ) 00135 * 00136 * -- LAPACK test routine (version 3.4.0) -- 00137 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00138 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00139 * November 2011 00140 * 00141 * .. Scalar Arguments .. 00142 CHARACTER TRANS 00143 INTEGER LDA, LDB, LDX, M, N, NRHS 00144 REAL RESID 00145 * .. 00146 * .. Array Arguments .. 00147 REAL A( LDA, * ), B( LDB, * ), RWORK( * ), 00148 $ X( LDX, * ) 00149 * .. 00150 * 00151 * ===================================================================== 00152 * 00153 * .. Parameters .. 00154 REAL ZERO, ONE 00155 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00156 * .. 00157 * .. Local Scalars .. 00158 INTEGER J, N1, N2 00159 REAL ANORM, BNORM, EPS, XNORM 00160 * .. 00161 * .. External Functions .. 00162 LOGICAL LSAME 00163 REAL SASUM, SLAMCH, SLANGE 00164 EXTERNAL LSAME, SASUM, SLAMCH, SLANGE 00165 * .. 00166 * .. External Subroutines .. 00167 EXTERNAL SGEMM 00168 * .. 00169 * .. Intrinsic Functions .. 00170 INTRINSIC MAX 00171 * .. 00172 * .. Executable Statements .. 00173 * 00174 * Quick exit if M = 0 or N = 0 or NRHS = 0 00175 * 00176 IF( M.LE.0 .OR. N.LE.0 .OR. NRHS.EQ.0 ) THEN 00177 RESID = ZERO 00178 RETURN 00179 END IF 00180 * 00181 IF( LSAME( TRANS, 'T' ) .OR. LSAME( TRANS, 'C' ) ) THEN 00182 N1 = N 00183 N2 = M 00184 ELSE 00185 N1 = M 00186 N2 = N 00187 END IF 00188 * 00189 * Exit with RESID = 1/EPS if ANORM = 0. 00190 * 00191 EPS = SLAMCH( 'Epsilon' ) 00192 ANORM = SLANGE( '1', N1, N2, A, LDA, RWORK ) 00193 IF( ANORM.LE.ZERO ) THEN 00194 RESID = ONE / EPS 00195 RETURN 00196 END IF 00197 * 00198 * Compute B - A*X (or B - A'*X ) and store in B. 00199 * 00200 CALL SGEMM( TRANS, 'No transpose', N1, NRHS, N2, -ONE, A, LDA, X, 00201 $ LDX, ONE, B, LDB ) 00202 * 00203 * Compute the maximum over the number of right hand sides of 00204 * norm(B - A*X) / ( norm(A) * norm(X) * EPS ) . 00205 * 00206 RESID = ZERO 00207 DO 10 J = 1, NRHS 00208 BNORM = SASUM( N1, B( 1, J ), 1 ) 00209 XNORM = SASUM( N2, X( 1, J ), 1 ) 00210 IF( XNORM.LE.ZERO ) THEN 00211 RESID = ONE / EPS 00212 ELSE 00213 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS ) 00214 END IF 00215 10 CONTINUE 00216 * 00217 RETURN 00218 * 00219 * End of SGET02 00220 * 00221 END