![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief <b> CSYSV computes the solution to system of linear equations A * X = B for SY 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 CSYSV + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/csysv.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/csysv.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/csysv.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE CSYSV( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK, 00022 * LWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER UPLO 00026 * INTEGER INFO, LDA, LDB, LWORK, N, NRHS 00027 * .. 00028 * .. Array Arguments .. 00029 * INTEGER IPIV( * ) 00030 * COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ) 00031 * .. 00032 * 00033 * 00034 *> \par Purpose: 00035 * ============= 00036 *> 00037 *> \verbatim 00038 *> 00039 *> CSYSV computes the solution to a complex system of linear equations 00040 *> A * X = B, 00041 *> where A is an N-by-N symmetric matrix and X and B are N-by-NRHS 00042 *> matrices. 00043 *> 00044 *> The diagonal pivoting method is used to factor A as 00045 *> A = U * D * U**T, if UPLO = 'U', or 00046 *> A = L * D * L**T, if UPLO = 'L', 00047 *> where U (or L) is a product of permutation and unit upper (lower) 00048 *> triangular matrices, and D is symmetric and block diagonal with 00049 *> 1-by-1 and 2-by-2 diagonal blocks. The factored form of A is then 00050 *> used to solve the system of equations A * X = B. 00051 *> \endverbatim 00052 * 00053 * Arguments: 00054 * ========== 00055 * 00056 *> \param[in] UPLO 00057 *> \verbatim 00058 *> UPLO is CHARACTER*1 00059 *> = 'U': Upper triangle of A is stored; 00060 *> = 'L': Lower triangle of A is stored. 00061 *> \endverbatim 00062 *> 00063 *> \param[in] N 00064 *> \verbatim 00065 *> N is INTEGER 00066 *> The number of linear equations, i.e., the order of the 00067 *> matrix A. N >= 0. 00068 *> \endverbatim 00069 *> 00070 *> \param[in] NRHS 00071 *> \verbatim 00072 *> NRHS is INTEGER 00073 *> The number of right hand sides, i.e., the number of columns 00074 *> of the matrix B. NRHS >= 0. 00075 *> \endverbatim 00076 *> 00077 *> \param[in,out] A 00078 *> \verbatim 00079 *> A is COMPLEX array, dimension (LDA,N) 00080 *> On entry, the symmetric matrix A. If UPLO = 'U', the leading 00081 *> N-by-N upper triangular part of A contains the upper 00082 *> triangular part of the matrix A, and the strictly lower 00083 *> triangular part of A is not referenced. If UPLO = 'L', the 00084 *> leading N-by-N lower triangular part of A contains the lower 00085 *> triangular part of the matrix A, and the strictly upper 00086 *> triangular part of A is not referenced. 00087 *> 00088 *> On exit, if INFO = 0, the block diagonal matrix D and the 00089 *> multipliers used to obtain the factor U or L from the 00090 *> factorization A = U*D*U**T or A = L*D*L**T as computed by 00091 *> CSYTRF. 00092 *> \endverbatim 00093 *> 00094 *> \param[in] LDA 00095 *> \verbatim 00096 *> LDA is INTEGER 00097 *> The leading dimension of the array A. LDA >= max(1,N). 00098 *> \endverbatim 00099 *> 00100 *> \param[out] IPIV 00101 *> \verbatim 00102 *> IPIV is INTEGER array, dimension (N) 00103 *> Details of the interchanges and the block structure of D, as 00104 *> determined by CSYTRF. If IPIV(k) > 0, then rows and columns 00105 *> k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1 00106 *> diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, 00107 *> then rows and columns k-1 and -IPIV(k) were interchanged and 00108 *> D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and 00109 *> IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and 00110 *> -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2 00111 *> diagonal block. 00112 *> \endverbatim 00113 *> 00114 *> \param[in,out] B 00115 *> \verbatim 00116 *> B is COMPLEX array, dimension (LDB,NRHS) 00117 *> On entry, the N-by-NRHS right hand side matrix B. 00118 *> On exit, if INFO = 0, the N-by-NRHS solution matrix X. 00119 *> \endverbatim 00120 *> 00121 *> \param[in] LDB 00122 *> \verbatim 00123 *> LDB is INTEGER 00124 *> The leading dimension of the array B. LDB >= max(1,N). 00125 *> \endverbatim 00126 *> 00127 *> \param[out] WORK 00128 *> \verbatim 00129 *> WORK is COMPLEX array, dimension (MAX(1,LWORK)) 00130 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 00131 *> \endverbatim 00132 *> 00133 *> \param[in] LWORK 00134 *> \verbatim 00135 *> LWORK is INTEGER 00136 *> The length of WORK. LWORK >= 1, and for best performance 00137 *> LWORK >= max(1,N*NB), where NB is the optimal blocksize for 00138 *> CSYTRF. 00139 *> for LWORK < N, TRS will be done with Level BLAS 2 00140 *> for LWORK >= N, TRS will be done with Level BLAS 3 00141 *> 00142 *> If LWORK = -1, then a workspace query is assumed; the routine 00143 *> only calculates the optimal size of the WORK array, returns 00144 *> this value as the first entry of the WORK array, and no error 00145 *> message related to LWORK is issued by XERBLA. 00146 *> \endverbatim 00147 *> 00148 *> \param[out] INFO 00149 *> \verbatim 00150 *> INFO is INTEGER 00151 *> = 0: successful exit 00152 *> < 0: if INFO = -i, the i-th argument had an illegal value 00153 *> > 0: if INFO = i, D(i,i) is exactly zero. The factorization 00154 *> has been completed, but the block diagonal matrix D is 00155 *> exactly singular, so the solution could not be computed. 00156 *> \endverbatim 00157 * 00158 * Authors: 00159 * ======== 00160 * 00161 *> \author Univ. of Tennessee 00162 *> \author Univ. of California Berkeley 00163 *> \author Univ. of Colorado Denver 00164 *> \author NAG Ltd. 00165 * 00166 *> \date November 2011 00167 * 00168 *> \ingroup complexSYsolve 00169 * 00170 * ===================================================================== 00171 SUBROUTINE CSYSV( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK, 00172 $ LWORK, INFO ) 00173 * 00174 * -- LAPACK driver routine (version 3.4.0) -- 00175 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00176 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00177 * November 2011 00178 * 00179 * .. Scalar Arguments .. 00180 CHARACTER UPLO 00181 INTEGER INFO, LDA, LDB, LWORK, N, NRHS 00182 * .. 00183 * .. Array Arguments .. 00184 INTEGER IPIV( * ) 00185 COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ) 00186 * .. 00187 * 00188 * ===================================================================== 00189 * 00190 * .. Local Scalars .. 00191 LOGICAL LQUERY 00192 INTEGER LWKOPT 00193 * .. 00194 * .. External Functions .. 00195 LOGICAL LSAME 00196 EXTERNAL LSAME 00197 * .. 00198 * .. External Subroutines .. 00199 EXTERNAL XERBLA, CSYTRF, CSYTRS, CSYTRS2 00200 * .. 00201 * .. Intrinsic Functions .. 00202 INTRINSIC MAX 00203 * .. 00204 * .. Executable Statements .. 00205 * 00206 * Test the input parameters. 00207 * 00208 INFO = 0 00209 LQUERY = ( LWORK.EQ.-1 ) 00210 IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN 00211 INFO = -1 00212 ELSE IF( N.LT.0 ) THEN 00213 INFO = -2 00214 ELSE IF( NRHS.LT.0 ) THEN 00215 INFO = -3 00216 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 00217 INFO = -5 00218 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN 00219 INFO = -8 00220 ELSE IF( LWORK.LT.1 .AND. .NOT.LQUERY ) THEN 00221 INFO = -10 00222 END IF 00223 * 00224 IF( INFO.EQ.0 ) THEN 00225 IF( N.EQ.0 ) THEN 00226 LWKOPT = 1 00227 ELSE 00228 CALL CSYTRF( UPLO, N, A, LDA, IPIV, WORK, -1, INFO ) 00229 LWKOPT = WORK(1) 00230 END IF 00231 WORK( 1 ) = LWKOPT 00232 END IF 00233 * 00234 IF( INFO.NE.0 ) THEN 00235 CALL XERBLA( 'CSYSV ', -INFO ) 00236 RETURN 00237 ELSE IF( LQUERY ) THEN 00238 RETURN 00239 END IF 00240 * 00241 * Compute the factorization A = U*D*U**T or A = L*D*L**T. 00242 * 00243 CALL CSYTRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO ) 00244 IF( INFO.EQ.0 ) THEN 00245 * 00246 * Solve the system A*X = B, overwriting B with X. 00247 * 00248 IF ( LWORK.LT.N ) THEN 00249 * 00250 * Solve with TRS ( Use Level BLAS 2) 00251 * 00252 CALL CSYTRS( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, INFO ) 00253 * 00254 ELSE 00255 * 00256 * Solve with TRS2 ( Use Level BLAS 3) 00257 * 00258 CALL CSYTRS2( UPLO,N,NRHS,A,LDA,IPIV,B,LDB,WORK,INFO ) 00259 * 00260 END IF 00261 * 00262 END IF 00263 * 00264 WORK( 1 ) = LWKOPT 00265 * 00266 RETURN 00267 * 00268 * End of CSYSV 00269 * 00270 END