![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b CGET02 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 CGET02( 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 RWORK( * ) 00021 * COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * ) 00022 * .. 00023 * 00024 * 00025 *> \par Purpose: 00026 * ============= 00027 *> 00028 *> \verbatim 00029 *> 00030 *> CGET02 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^T*x = b, where A^T is the transpose of A 00045 *> = 'C': A^H*x = b, where A^H is the conjugate 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 COMPLEX 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 COMPLEX 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 COMPLEX 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 complex_eig 00131 * 00132 * ===================================================================== 00133 SUBROUTINE CGET02( 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 RWORK( * ) 00148 COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * ) 00149 * .. 00150 * 00151 * ===================================================================== 00152 * 00153 * .. Parameters .. 00154 REAL ZERO, ONE 00155 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00156 COMPLEX CONE 00157 PARAMETER ( CONE = 1.0E+0 ) 00158 * .. 00159 * .. Local Scalars .. 00160 INTEGER J, N1, N2 00161 REAL ANORM, BNORM, EPS, XNORM 00162 * .. 00163 * .. External Functions .. 00164 LOGICAL LSAME 00165 REAL CLANGE, SCASUM, SLAMCH 00166 EXTERNAL LSAME, CLANGE, SCASUM, SLAMCH 00167 * .. 00168 * .. External Subroutines .. 00169 EXTERNAL CGEMM 00170 * .. 00171 * .. Intrinsic Functions .. 00172 INTRINSIC MAX 00173 * .. 00174 * .. Executable Statements .. 00175 * 00176 * Quick exit if M = 0 or N = 0 or NRHS = 0 00177 * 00178 IF( M.LE.0 .OR. N.LE.0 .OR. NRHS.EQ.0 ) THEN 00179 RESID = ZERO 00180 RETURN 00181 END IF 00182 * 00183 IF( LSAME( TRANS, 'T' ) .OR. LSAME( TRANS, 'C' ) ) THEN 00184 N1 = N 00185 N2 = M 00186 ELSE 00187 N1 = M 00188 N2 = N 00189 END IF 00190 * 00191 * Exit with RESID = 1/EPS if ANORM = 0. 00192 * 00193 EPS = SLAMCH( 'Epsilon' ) 00194 ANORM = CLANGE( '1', N1, N2, A, LDA, RWORK ) 00195 IF( ANORM.LE.ZERO ) THEN 00196 RESID = ONE / EPS 00197 RETURN 00198 END IF 00199 * 00200 * Compute B - A*X (or B - A'*X ) and store in B. 00201 * 00202 CALL CGEMM( TRANS, 'No transpose', N1, NRHS, N2, -CONE, A, LDA, X, 00203 $ LDX, CONE, B, LDB ) 00204 * 00205 * Compute the maximum over the number of right hand sides of 00206 * norm(B - A*X) / ( norm(A) * norm(X) * EPS ) . 00207 * 00208 RESID = ZERO 00209 DO 10 J = 1, NRHS 00210 BNORM = SCASUM( N1, B( 1, J ), 1 ) 00211 XNORM = SCASUM( N2, X( 1, J ), 1 ) 00212 IF( XNORM.LE.ZERO ) THEN 00213 RESID = ONE / EPS 00214 ELSE 00215 RESID = MAX( RESID, ( ( BNORM/ANORM )/XNORM )/EPS ) 00216 END IF 00217 10 CONTINUE 00218 * 00219 RETURN 00220 * 00221 * End of CGET02 00222 * 00223 END