![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b CPTT02 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 CPTT02( UPLO, N, NRHS, D, E, X, LDX, B, LDB, RESID ) 00012 * 00013 * .. Scalar Arguments .. 00014 * CHARACTER UPLO 00015 * INTEGER LDB, LDX, N, NRHS 00016 * REAL RESID 00017 * .. 00018 * .. Array Arguments .. 00019 * REAL D( * ) 00020 * COMPLEX B( LDB, * ), E( * ), X( LDX, * ) 00021 * .. 00022 * 00023 * 00024 *> \par Purpose: 00025 * ============= 00026 *> 00027 *> \verbatim 00028 *> 00029 *> CPTT02 computes the residual for the solution to a symmetric 00030 *> tridiagonal system of equations: 00031 *> RESID = norm(B - A*X) / (norm(A) * norm(X) * EPS), 00032 *> where EPS is the machine epsilon. 00033 *> \endverbatim 00034 * 00035 * Arguments: 00036 * ========== 00037 * 00038 *> \param[in] UPLO 00039 *> \verbatim 00040 *> UPLO is CHARACTER*1 00041 *> Specifies whether the superdiagonal or the subdiagonal of the 00042 *> tridiagonal matrix A is stored. 00043 *> = 'U': E is the superdiagonal of A 00044 *> = 'L': E is the subdiagonal of A 00045 *> \endverbatim 00046 *> 00047 *> \param[in] N 00048 *> \verbatim 00049 *> N is INTEGTER 00050 *> The order of the matrix A. 00051 *> \endverbatim 00052 *> 00053 *> \param[in] NRHS 00054 *> \verbatim 00055 *> NRHS is INTEGER 00056 *> The number of right hand sides, i.e., the number of columns 00057 *> of the matrices B and X. NRHS >= 0. 00058 *> \endverbatim 00059 *> 00060 *> \param[in] D 00061 *> \verbatim 00062 *> D is REAL array, dimension (N) 00063 *> The n diagonal elements of the tridiagonal matrix A. 00064 *> \endverbatim 00065 *> 00066 *> \param[in] E 00067 *> \verbatim 00068 *> E is COMPLEX array, dimension (N-1) 00069 *> The (n-1) subdiagonal elements of the tridiagonal matrix A. 00070 *> \endverbatim 00071 *> 00072 *> \param[in] X 00073 *> \verbatim 00074 *> X is COMPLEX array, dimension (LDX,NRHS) 00075 *> The n by nrhs matrix of solution vectors X. 00076 *> \endverbatim 00077 *> 00078 *> \param[in] LDX 00079 *> \verbatim 00080 *> LDX is INTEGER 00081 *> The leading dimension of the array X. LDX >= max(1,N). 00082 *> \endverbatim 00083 *> 00084 *> \param[in,out] B 00085 *> \verbatim 00086 *> B is COMPLEX array, dimension (LDB,NRHS) 00087 *> On entry, the n by nrhs matrix of right hand side vectors B. 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] RESID 00098 *> \verbatim 00099 *> RESID is REAL 00100 *> norm(B - A*X) / (norm(A) * norm(X) * EPS) 00101 *> \endverbatim 00102 * 00103 * Authors: 00104 * ======== 00105 * 00106 *> \author Univ. of Tennessee 00107 *> \author Univ. of California Berkeley 00108 *> \author Univ. of Colorado Denver 00109 *> \author NAG Ltd. 00110 * 00111 *> \date November 2011 00112 * 00113 *> \ingroup complex_lin 00114 * 00115 * ===================================================================== 00116 SUBROUTINE CPTT02( UPLO, N, NRHS, D, E, X, LDX, B, LDB, RESID ) 00117 * 00118 * -- LAPACK test routine (version 3.4.0) -- 00119 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00120 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00121 * November 2011 00122 * 00123 * .. Scalar Arguments .. 00124 CHARACTER UPLO 00125 INTEGER LDB, LDX, N, NRHS 00126 REAL RESID 00127 * .. 00128 * .. Array Arguments .. 00129 REAL D( * ) 00130 COMPLEX B( LDB, * ), E( * ), X( LDX, * ) 00131 * .. 00132 * 00133 * ===================================================================== 00134 * 00135 * .. Parameters .. 00136 REAL ONE, ZERO 00137 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) 00138 * .. 00139 * .. Local Scalars .. 00140 INTEGER J 00141 REAL ANORM, BNORM, EPS, XNORM 00142 * .. 00143 * .. External Functions .. 00144 REAL CLANHT, SCASUM, SLAMCH 00145 EXTERNAL CLANHT, SCASUM, SLAMCH 00146 * .. 00147 * .. Intrinsic Functions .. 00148 INTRINSIC MAX 00149 * .. 00150 * .. External Subroutines .. 00151 EXTERNAL CLAPTM 00152 * .. 00153 * .. Executable Statements .. 00154 * 00155 * Quick return if possible 00156 * 00157 IF( N.LE.0 ) THEN 00158 RESID = ZERO 00159 RETURN 00160 END IF 00161 * 00162 * Compute the 1-norm of the tridiagonal matrix A. 00163 * 00164 ANORM = CLANHT( '1', N, D, E ) 00165 * 00166 * Exit with RESID = 1/EPS if ANORM = 0. 00167 * 00168 EPS = SLAMCH( 'Epsilon' ) 00169 IF( ANORM.LE.ZERO ) THEN 00170 RESID = ONE / EPS 00171 RETURN 00172 END IF 00173 * 00174 * Compute B - A*X. 00175 * 00176 CALL CLAPTM( UPLO, N, NRHS, -ONE, D, E, X, LDX, ONE, B, LDB ) 00177 * 00178 * Compute the maximum over the number of right hand sides of 00179 * norm(B - A*X) / ( norm(A) * norm(X) * EPS ). 00180 * 00181 RESID = ZERO 00182 DO 10 J = 1, NRHS 00183 BNORM = SCASUM( N, B( 1, J ), 1 ) 00184 XNORM = SCASUM( N, X( 1, J ), 1 ) 00185 IF( XNORM.LE.ZERO ) THEN 00186 RESID = ONE / EPS 00187 ELSE 00188 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS ) 00189 END IF 00190 10 CONTINUE 00191 * 00192 RETURN 00193 * 00194 * End of CPTT02 00195 * 00196 END