LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE ZSPSVX( FACT, UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X, 00002 $ LDX, RCOND, FERR, BERR, WORK, RWORK, INFO ) 00003 * 00004 * -- LAPACK driver routine (version 3.3.1) -- 00005 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00006 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00007 * -- April 2011 -- 00008 * 00009 * .. Scalar Arguments .. 00010 CHARACTER FACT, UPLO 00011 INTEGER INFO, LDB, LDX, N, NRHS 00012 DOUBLE PRECISION RCOND 00013 * .. 00014 * .. Array Arguments .. 00015 INTEGER IPIV( * ) 00016 DOUBLE PRECISION BERR( * ), FERR( * ), RWORK( * ) 00017 COMPLEX*16 AFP( * ), AP( * ), B( LDB, * ), WORK( * ), 00018 $ X( LDX, * ) 00019 * .. 00020 * 00021 * Purpose 00022 * ======= 00023 * 00024 * ZSPSVX uses the diagonal pivoting factorization A = U*D*U**T or 00025 * A = L*D*L**T to compute the solution to a complex system of linear 00026 * equations A * X = B, where A is an N-by-N symmetric matrix stored 00027 * in packed format and X and B are N-by-NRHS matrices. 00028 * 00029 * Error bounds on the solution and a condition estimate are also 00030 * provided. 00031 * 00032 * Description 00033 * =========== 00034 * 00035 * The following steps are performed: 00036 * 00037 * 1. If FACT = 'N', the diagonal pivoting method is used to factor A as 00038 * A = U * D * U**T, if UPLO = 'U', or 00039 * A = L * D * L**T, if UPLO = 'L', 00040 * where U (or L) is a product of permutation and unit upper (lower) 00041 * triangular matrices and D is symmetric and block diagonal with 00042 * 1-by-1 and 2-by-2 diagonal blocks. 00043 * 00044 * 2. If some D(i,i)=0, so that D is exactly singular, then the routine 00045 * returns with INFO = i. Otherwise, the factored form of A is used 00046 * to estimate the condition number of the matrix A. If the 00047 * reciprocal of the condition number is less than machine precision, 00048 * INFO = N+1 is returned as a warning, but the routine still goes on 00049 * to solve for X and compute error bounds as described below. 00050 * 00051 * 3. The system of equations is solved for X using the factored form 00052 * of A. 00053 * 00054 * 4. Iterative refinement is applied to improve the computed solution 00055 * matrix and calculate error bounds and backward error estimates 00056 * for it. 00057 * 00058 * Arguments 00059 * ========= 00060 * 00061 * FACT (input) CHARACTER*1 00062 * Specifies whether or not the factored form of A has been 00063 * supplied on entry. 00064 * = 'F': On entry, AFP and IPIV contain the factored form 00065 * of A. AP, AFP and IPIV will not be modified. 00066 * = 'N': The matrix A will be copied to AFP and factored. 00067 * 00068 * UPLO (input) CHARACTER*1 00069 * = 'U': Upper triangle of A is stored; 00070 * = 'L': Lower triangle of A is stored. 00071 * 00072 * N (input) INTEGER 00073 * The number of linear equations, i.e., the order of the 00074 * matrix A. N >= 0. 00075 * 00076 * NRHS (input) INTEGER 00077 * The number of right hand sides, i.e., the number of columns 00078 * of the matrices B and X. NRHS >= 0. 00079 * 00080 * AP (input) COMPLEX*16 array, dimension (N*(N+1)/2) 00081 * The upper or lower triangle of the symmetric matrix A, packed 00082 * columnwise in a linear array. The j-th column of A is stored 00083 * in the array AP as follows: 00084 * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00085 * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. 00086 * See below for further details. 00087 * 00088 * AFP (input or output) COMPLEX*16 array, dimension (N*(N+1)/2) 00089 * If FACT = 'F', then AFP is an input argument and on entry 00090 * contains the block diagonal matrix D and the multipliers used 00091 * to obtain the factor U or L from the factorization 00092 * A = U*D*U**T or A = L*D*L**T as computed by ZSPTRF, stored as 00093 * a packed triangular matrix in the same storage format as A. 00094 * 00095 * If FACT = 'N', then AFP is an output argument and on exit 00096 * contains the block diagonal matrix D and the multipliers used 00097 * to obtain the factor U or L from the factorization 00098 * A = U*D*U**T or A = L*D*L**T as computed by ZSPTRF, stored as 00099 * a packed triangular matrix in the same storage format as A. 00100 * 00101 * IPIV (input or output) INTEGER array, dimension (N) 00102 * If FACT = 'F', then IPIV is an input argument and on entry 00103 * contains details of the interchanges and the block structure 00104 * of D, as determined by ZSPTRF. 00105 * If IPIV(k) > 0, then rows and columns k and IPIV(k) were 00106 * interchanged and D(k,k) is a 1-by-1 diagonal block. 00107 * If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and 00108 * columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) 00109 * is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) = 00110 * IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were 00111 * interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. 00112 * 00113 * If FACT = 'N', then IPIV is an output argument and on exit 00114 * contains details of the interchanges and the block structure 00115 * of D, as determined by ZSPTRF. 00116 * 00117 * B (input) COMPLEX*16 array, dimension (LDB,NRHS) 00118 * The N-by-NRHS right hand side matrix B. 00119 * 00120 * LDB (input) INTEGER 00121 * The leading dimension of the array B. LDB >= max(1,N). 00122 * 00123 * X (output) COMPLEX*16 array, dimension (LDX,NRHS) 00124 * If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X. 00125 * 00126 * LDX (input) INTEGER 00127 * The leading dimension of the array X. LDX >= max(1,N). 00128 * 00129 * RCOND (output) DOUBLE PRECISION 00130 * The estimate of the reciprocal condition number of the matrix 00131 * A. If RCOND is less than the machine precision (in 00132 * particular, if RCOND = 0), the matrix is singular to working 00133 * precision. This condition is indicated by a return code of 00134 * INFO > 0. 00135 * 00136 * FERR (output) DOUBLE PRECISION array, dimension (NRHS) 00137 * The estimated forward error bound for each solution vector 00138 * X(j) (the j-th column of the solution matrix X). 00139 * If XTRUE is the true solution corresponding to X(j), FERR(j) 00140 * is an estimated upper bound for the magnitude of the largest 00141 * element in (X(j) - XTRUE) divided by the magnitude of the 00142 * largest element in X(j). The estimate is as reliable as 00143 * the estimate for RCOND, and is almost always a slight 00144 * overestimate of the true error. 00145 * 00146 * BERR (output) DOUBLE PRECISION array, dimension (NRHS) 00147 * The componentwise relative backward error of each solution 00148 * vector X(j) (i.e., the smallest relative change in 00149 * any element of A or B that makes X(j) an exact solution). 00150 * 00151 * WORK (workspace) COMPLEX*16 array, dimension (2*N) 00152 * 00153 * RWORK (workspace) DOUBLE PRECISION array, dimension (N) 00154 * 00155 * INFO (output) INTEGER 00156 * = 0: successful exit 00157 * < 0: if INFO = -i, the i-th argument had an illegal value 00158 * > 0: if INFO = i, and i is 00159 * <= N: D(i,i) is exactly zero. The factorization 00160 * has been completed but the factor D is exactly 00161 * singular, so the solution and error bounds could 00162 * not be computed. RCOND = 0 is returned. 00163 * = N+1: D is nonsingular, but RCOND is less than machine 00164 * precision, meaning that the matrix is singular 00165 * to working precision. Nevertheless, the 00166 * solution and error bounds are computed because 00167 * there are a number of situations where the 00168 * computed solution can be more accurate than the 00169 * value of RCOND would suggest. 00170 * 00171 * Further Details 00172 * =============== 00173 * 00174 * The packed storage scheme is illustrated by the following example 00175 * when N = 4, UPLO = 'U': 00176 * 00177 * Two-dimensional storage of the symmetric matrix A: 00178 * 00179 * a11 a12 a13 a14 00180 * a22 a23 a24 00181 * a33 a34 (aij = aji) 00182 * a44 00183 * 00184 * Packed storage of the upper triangle of A: 00185 * 00186 * AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] 00187 * 00188 * ===================================================================== 00189 * 00190 * .. Parameters .. 00191 DOUBLE PRECISION ZERO 00192 PARAMETER ( ZERO = 0.0D+0 ) 00193 * .. 00194 * .. Local Scalars .. 00195 LOGICAL NOFACT 00196 DOUBLE PRECISION ANORM 00197 * .. 00198 * .. External Functions .. 00199 LOGICAL LSAME 00200 DOUBLE PRECISION DLAMCH, ZLANSP 00201 EXTERNAL LSAME, DLAMCH, ZLANSP 00202 * .. 00203 * .. External Subroutines .. 00204 EXTERNAL XERBLA, ZCOPY, ZLACPY, ZSPCON, ZSPRFS, ZSPTRF, 00205 $ ZSPTRS 00206 * .. 00207 * .. Intrinsic Functions .. 00208 INTRINSIC MAX 00209 * .. 00210 * .. Executable Statements .. 00211 * 00212 * Test the input parameters. 00213 * 00214 INFO = 0 00215 NOFACT = LSAME( FACT, 'N' ) 00216 IF( .NOT.NOFACT .AND. .NOT.LSAME( FACT, 'F' ) ) THEN 00217 INFO = -1 00218 ELSE IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) 00219 $ THEN 00220 INFO = -2 00221 ELSE IF( N.LT.0 ) THEN 00222 INFO = -3 00223 ELSE IF( NRHS.LT.0 ) THEN 00224 INFO = -4 00225 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN 00226 INFO = -9 00227 ELSE IF( LDX.LT.MAX( 1, N ) ) THEN 00228 INFO = -11 00229 END IF 00230 IF( INFO.NE.0 ) THEN 00231 CALL XERBLA( 'ZSPSVX', -INFO ) 00232 RETURN 00233 END IF 00234 * 00235 IF( NOFACT ) THEN 00236 * 00237 * Compute the factorization A = U*D*U**T or A = L*D*L**T. 00238 * 00239 CALL ZCOPY( N*( N+1 ) / 2, AP, 1, AFP, 1 ) 00240 CALL ZSPTRF( UPLO, N, AFP, IPIV, INFO ) 00241 * 00242 * Return if INFO is non-zero. 00243 * 00244 IF( INFO.GT.0 )THEN 00245 RCOND = ZERO 00246 RETURN 00247 END IF 00248 END IF 00249 * 00250 * Compute the norm of the matrix A. 00251 * 00252 ANORM = ZLANSP( 'I', UPLO, N, AP, RWORK ) 00253 * 00254 * Compute the reciprocal of the condition number of A. 00255 * 00256 CALL ZSPCON( UPLO, N, AFP, IPIV, ANORM, RCOND, WORK, INFO ) 00257 * 00258 * Compute the solution vectors X. 00259 * 00260 CALL ZLACPY( 'Full', N, NRHS, B, LDB, X, LDX ) 00261 CALL ZSPTRS( UPLO, N, NRHS, AFP, IPIV, X, LDX, INFO ) 00262 * 00263 * Use iterative refinement to improve the computed solutions and 00264 * compute error bounds and backward error estimates for them. 00265 * 00266 CALL ZSPRFS( UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X, LDX, FERR, 00267 $ BERR, WORK, RWORK, INFO ) 00268 * 00269 * Set INFO = N+1 if the matrix is singular to working precision. 00270 * 00271 IF( RCOND.LT.DLAMCH( 'Epsilon' ) ) 00272 $ INFO = N + 1 00273 * 00274 RETURN 00275 * 00276 * End of ZSPSVX 00277 * 00278 END