![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief <b> CSPSVX computes the solution to system of linear equations A * X = B for OTHER matrices</b> 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download CSPSVX + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cspsvx.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cspsvx.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cspsvx.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE CSPSVX( FACT, UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X, 00022 * LDX, RCOND, FERR, BERR, WORK, RWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER FACT, UPLO 00026 * INTEGER INFO, LDB, LDX, N, NRHS 00027 * REAL RCOND 00028 * .. 00029 * .. Array Arguments .. 00030 * INTEGER IPIV( * ) 00031 * REAL BERR( * ), FERR( * ), RWORK( * ) 00032 * COMPLEX AFP( * ), AP( * ), B( LDB, * ), WORK( * ), 00033 * $ X( LDX, * ) 00034 * .. 00035 * 00036 * 00037 *> \par Purpose: 00038 * ============= 00039 *> 00040 *> \verbatim 00041 *> 00042 *> CSPSVX uses the diagonal pivoting factorization A = U*D*U**T or 00043 *> A = L*D*L**T to compute the solution to a complex system of linear 00044 *> equations A * X = B, where A is an N-by-N symmetric matrix stored 00045 *> in packed format and X and B are N-by-NRHS matrices. 00046 *> 00047 *> Error bounds on the solution and a condition estimate are also 00048 *> provided. 00049 *> \endverbatim 00050 * 00051 *> \par Description: 00052 * ================= 00053 *> 00054 *> \verbatim 00055 *> 00056 *> The following steps are performed: 00057 *> 00058 *> 1. If FACT = 'N', the diagonal pivoting method is used to factor A as 00059 *> A = U * D * U**T, if UPLO = 'U', or 00060 *> A = L * D * L**T, if UPLO = 'L', 00061 *> where U (or L) is a product of permutation and unit upper (lower) 00062 *> triangular matrices and D is symmetric and block diagonal with 00063 *> 1-by-1 and 2-by-2 diagonal blocks. 00064 *> 00065 *> 2. If some D(i,i)=0, so that D is exactly singular, then the routine 00066 *> returns with INFO = i. Otherwise, the factored form of A is used 00067 *> to estimate the condition number of the matrix A. If the 00068 *> reciprocal of the condition number is less than machine precision, 00069 *> INFO = N+1 is returned as a warning, but the routine still goes on 00070 *> to solve for X and compute error bounds as described below. 00071 *> 00072 *> 3. The system of equations is solved for X using the factored form 00073 *> of A. 00074 *> 00075 *> 4. Iterative refinement is applied to improve the computed solution 00076 *> matrix and calculate error bounds and backward error estimates 00077 *> for it. 00078 *> \endverbatim 00079 * 00080 * Arguments: 00081 * ========== 00082 * 00083 *> \param[in] FACT 00084 *> \verbatim 00085 *> FACT is CHARACTER*1 00086 *> Specifies whether or not the factored form of A has been 00087 *> supplied on entry. 00088 *> = 'F': On entry, AFP and IPIV contain the factored form 00089 *> of A. AP, AFP and IPIV will not be modified. 00090 *> = 'N': The matrix A will be copied to AFP and factored. 00091 *> \endverbatim 00092 *> 00093 *> \param[in] UPLO 00094 *> \verbatim 00095 *> UPLO is CHARACTER*1 00096 *> = 'U': Upper triangle of A is stored; 00097 *> = 'L': Lower triangle of A is stored. 00098 *> \endverbatim 00099 *> 00100 *> \param[in] N 00101 *> \verbatim 00102 *> N is INTEGER 00103 *> The number of linear equations, i.e., the order of the 00104 *> matrix A. N >= 0. 00105 *> \endverbatim 00106 *> 00107 *> \param[in] NRHS 00108 *> \verbatim 00109 *> NRHS is INTEGER 00110 *> The number of right hand sides, i.e., the number of columns 00111 *> of the matrices B and X. NRHS >= 0. 00112 *> \endverbatim 00113 *> 00114 *> \param[in] AP 00115 *> \verbatim 00116 *> AP is COMPLEX array, dimension (N*(N+1)/2) 00117 *> The upper or lower triangle of the symmetric matrix A, packed 00118 *> columnwise in a linear array. The j-th column of A is stored 00119 *> in the array AP as follows: 00120 *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00121 *> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. 00122 *> See below for further details. 00123 *> \endverbatim 00124 *> 00125 *> \param[in,out] AFP 00126 *> \verbatim 00127 *> AFP is COMPLEX array, dimension (N*(N+1)/2) 00128 *> If FACT = 'F', then AFP is an input argument and on entry 00129 *> contains the block diagonal matrix D and the multipliers used 00130 *> to obtain the factor U or L from the factorization 00131 *> A = U*D*U**T or A = L*D*L**T as computed by CSPTRF, stored as 00132 *> a packed triangular matrix in the same storage format as A. 00133 *> 00134 *> If FACT = 'N', then AFP is an output argument and on exit 00135 *> contains the block diagonal matrix D and the multipliers used 00136 *> to obtain the factor U or L from the factorization 00137 *> A = U*D*U**T or A = L*D*L**T as computed by CSPTRF, stored as 00138 *> a packed triangular matrix in the same storage format as A. 00139 *> \endverbatim 00140 *> 00141 *> \param[in,out] IPIV 00142 *> \verbatim 00143 *> IPIV is INTEGER array, dimension (N) 00144 *> If FACT = 'F', then IPIV is an input argument and on entry 00145 *> contains details of the interchanges and the block structure 00146 *> of D, as determined by CSPTRF. 00147 *> If IPIV(k) > 0, then rows and columns k and IPIV(k) were 00148 *> interchanged and D(k,k) is a 1-by-1 diagonal block. 00149 *> If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and 00150 *> columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) 00151 *> is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) = 00152 *> IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were 00153 *> interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. 00154 *> 00155 *> If FACT = 'N', then IPIV is an output argument and on exit 00156 *> contains details of the interchanges and the block structure 00157 *> of D, as determined by CSPTRF. 00158 *> \endverbatim 00159 *> 00160 *> \param[in] B 00161 *> \verbatim 00162 *> B is COMPLEX array, dimension (LDB,NRHS) 00163 *> The N-by-NRHS right hand side matrix B. 00164 *> \endverbatim 00165 *> 00166 *> \param[in] LDB 00167 *> \verbatim 00168 *> LDB is INTEGER 00169 *> The leading dimension of the array B. LDB >= max(1,N). 00170 *> \endverbatim 00171 *> 00172 *> \param[out] X 00173 *> \verbatim 00174 *> X is COMPLEX array, dimension (LDX,NRHS) 00175 *> If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X. 00176 *> \endverbatim 00177 *> 00178 *> \param[in] LDX 00179 *> \verbatim 00180 *> LDX is INTEGER 00181 *> The leading dimension of the array X. LDX >= max(1,N). 00182 *> \endverbatim 00183 *> 00184 *> \param[out] RCOND 00185 *> \verbatim 00186 *> RCOND is REAL 00187 *> The estimate of the reciprocal condition number of the matrix 00188 *> A. If RCOND is less than the machine precision (in 00189 *> particular, if RCOND = 0), the matrix is singular to working 00190 *> precision. This condition is indicated by a return code of 00191 *> INFO > 0. 00192 *> \endverbatim 00193 *> 00194 *> \param[out] FERR 00195 *> \verbatim 00196 *> FERR is REAL array, dimension (NRHS) 00197 *> The estimated forward error bound for each solution vector 00198 *> X(j) (the j-th column of the solution matrix X). 00199 *> If XTRUE is the true solution corresponding to X(j), FERR(j) 00200 *> is an estimated upper bound for the magnitude of the largest 00201 *> element in (X(j) - XTRUE) divided by the magnitude of the 00202 *> largest element in X(j). The estimate is as reliable as 00203 *> the estimate for RCOND, and is almost always a slight 00204 *> overestimate of the true error. 00205 *> \endverbatim 00206 *> 00207 *> \param[out] BERR 00208 *> \verbatim 00209 *> BERR is REAL array, dimension (NRHS) 00210 *> The componentwise relative backward error of each solution 00211 *> vector X(j) (i.e., the smallest relative change in 00212 *> any element of A or B that makes X(j) an exact solution). 00213 *> \endverbatim 00214 *> 00215 *> \param[out] WORK 00216 *> \verbatim 00217 *> WORK is COMPLEX array, dimension (2*N) 00218 *> \endverbatim 00219 *> 00220 *> \param[out] RWORK 00221 *> \verbatim 00222 *> RWORK is REAL array, dimension (N) 00223 *> \endverbatim 00224 *> 00225 *> \param[out] INFO 00226 *> \verbatim 00227 *> INFO is INTEGER 00228 *> = 0: successful exit 00229 *> < 0: if INFO = -i, the i-th argument had an illegal value 00230 *> > 0: if INFO = i, and i is 00231 *> <= N: D(i,i) is exactly zero. The factorization 00232 *> has been completed but the factor D is exactly 00233 *> singular, so the solution and error bounds could 00234 *> not be computed. RCOND = 0 is returned. 00235 *> = N+1: D is nonsingular, but RCOND is less than machine 00236 *> precision, meaning that the matrix is singular 00237 *> to working precision. Nevertheless, the 00238 *> solution and error bounds are computed because 00239 *> there are a number of situations where the 00240 *> computed solution can be more accurate than the 00241 *> value of RCOND would suggest. 00242 *> \endverbatim 00243 * 00244 * Authors: 00245 * ======== 00246 * 00247 *> \author Univ. of Tennessee 00248 *> \author Univ. of California Berkeley 00249 *> \author Univ. of Colorado Denver 00250 *> \author NAG Ltd. 00251 * 00252 *> \date April 2012 00253 * 00254 *> \ingroup complexOTHERsolve 00255 * 00256 *> \par Further Details: 00257 * ===================== 00258 *> 00259 *> \verbatim 00260 *> 00261 *> The packed storage scheme is illustrated by the following example 00262 *> when N = 4, UPLO = 'U': 00263 *> 00264 *> Two-dimensional storage of the symmetric matrix A: 00265 *> 00266 *> a11 a12 a13 a14 00267 *> a22 a23 a24 00268 *> a33 a34 (aij = aji) 00269 *> a44 00270 *> 00271 *> Packed storage of the upper triangle of A: 00272 *> 00273 *> AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] 00274 *> \endverbatim 00275 *> 00276 * ===================================================================== 00277 SUBROUTINE CSPSVX( FACT, UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X, 00278 $ LDX, RCOND, FERR, BERR, WORK, RWORK, INFO ) 00279 * 00280 * -- LAPACK driver routine (version 3.4.1) -- 00281 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00282 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00283 * April 2012 00284 * 00285 * .. Scalar Arguments .. 00286 CHARACTER FACT, UPLO 00287 INTEGER INFO, LDB, LDX, N, NRHS 00288 REAL RCOND 00289 * .. 00290 * .. Array Arguments .. 00291 INTEGER IPIV( * ) 00292 REAL BERR( * ), FERR( * ), RWORK( * ) 00293 COMPLEX AFP( * ), AP( * ), B( LDB, * ), WORK( * ), 00294 $ X( LDX, * ) 00295 * .. 00296 * 00297 * ===================================================================== 00298 * 00299 * .. Parameters .. 00300 REAL ZERO 00301 PARAMETER ( ZERO = 0.0E+0 ) 00302 * .. 00303 * .. Local Scalars .. 00304 LOGICAL NOFACT 00305 REAL ANORM 00306 * .. 00307 * .. External Functions .. 00308 LOGICAL LSAME 00309 REAL CLANSP, SLAMCH 00310 EXTERNAL LSAME, CLANSP, SLAMCH 00311 * .. 00312 * .. External Subroutines .. 00313 EXTERNAL CCOPY, CLACPY, CSPCON, CSPRFS, CSPTRF, CSPTRS, 00314 $ XERBLA 00315 * .. 00316 * .. Intrinsic Functions .. 00317 INTRINSIC MAX 00318 * .. 00319 * .. Executable Statements .. 00320 * 00321 * Test the input parameters. 00322 * 00323 INFO = 0 00324 NOFACT = LSAME( FACT, 'N' ) 00325 IF( .NOT.NOFACT .AND. .NOT.LSAME( FACT, 'F' ) ) THEN 00326 INFO = -1 00327 ELSE IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) 00328 $ THEN 00329 INFO = -2 00330 ELSE IF( N.LT.0 ) THEN 00331 INFO = -3 00332 ELSE IF( NRHS.LT.0 ) THEN 00333 INFO = -4 00334 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN 00335 INFO = -9 00336 ELSE IF( LDX.LT.MAX( 1, N ) ) THEN 00337 INFO = -11 00338 END IF 00339 IF( INFO.NE.0 ) THEN 00340 CALL XERBLA( 'CSPSVX', -INFO ) 00341 RETURN 00342 END IF 00343 * 00344 IF( NOFACT ) THEN 00345 * 00346 * Compute the factorization A = U*D*U**T or A = L*D*L**T. 00347 * 00348 CALL CCOPY( N*( N+1 ) / 2, AP, 1, AFP, 1 ) 00349 CALL CSPTRF( UPLO, N, AFP, IPIV, INFO ) 00350 * 00351 * Return if INFO is non-zero. 00352 * 00353 IF( INFO.GT.0 )THEN 00354 RCOND = ZERO 00355 RETURN 00356 END IF 00357 END IF 00358 * 00359 * Compute the norm of the matrix A. 00360 * 00361 ANORM = CLANSP( 'I', UPLO, N, AP, RWORK ) 00362 * 00363 * Compute the reciprocal of the condition number of A. 00364 * 00365 CALL CSPCON( UPLO, N, AFP, IPIV, ANORM, RCOND, WORK, INFO ) 00366 * 00367 * Compute the solution vectors X. 00368 * 00369 CALL CLACPY( 'Full', N, NRHS, B, LDB, X, LDX ) 00370 CALL CSPTRS( UPLO, N, NRHS, AFP, IPIV, X, LDX, INFO ) 00371 * 00372 * Use iterative refinement to improve the computed solutions and 00373 * compute error bounds and backward error estimates for them. 00374 * 00375 CALL CSPRFS( UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X, LDX, FERR, 00376 $ BERR, WORK, RWORK, INFO ) 00377 * 00378 * Set INFO = N+1 if the matrix is singular to working precision. 00379 * 00380 IF( RCOND.LT.SLAMCH( 'Epsilon' ) ) 00381 $ INFO = N + 1 00382 * 00383 RETURN 00384 * 00385 * End of CSPSVX 00386 * 00387 END