![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b DSYGST 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download DSYGV + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsygv.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsygv.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsygv.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE DSYGV( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK, 00022 * LWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER JOBZ, UPLO 00026 * INTEGER INFO, ITYPE, LDA, LDB, LWORK, N 00027 * .. 00028 * .. Array Arguments .. 00029 * DOUBLE PRECISION A( LDA, * ), B( LDB, * ), W( * ), WORK( * ) 00030 * .. 00031 * 00032 * 00033 *> \par Purpose: 00034 * ============= 00035 *> 00036 *> \verbatim 00037 *> 00038 *> DSYGV computes all the eigenvalues, and optionally, the eigenvectors 00039 *> of a real generalized symmetric-definite eigenproblem, of the form 00040 *> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. 00041 *> Here A and B are assumed to be symmetric and B is also 00042 *> positive definite. 00043 *> \endverbatim 00044 * 00045 * Arguments: 00046 * ========== 00047 * 00048 *> \param[in] ITYPE 00049 *> \verbatim 00050 *> ITYPE is INTEGER 00051 *> Specifies the problem type to be solved: 00052 *> = 1: A*x = (lambda)*B*x 00053 *> = 2: A*B*x = (lambda)*x 00054 *> = 3: B*A*x = (lambda)*x 00055 *> \endverbatim 00056 *> 00057 *> \param[in] JOBZ 00058 *> \verbatim 00059 *> JOBZ is CHARACTER*1 00060 *> = 'N': Compute eigenvalues only; 00061 *> = 'V': Compute eigenvalues and eigenvectors. 00062 *> \endverbatim 00063 *> 00064 *> \param[in] UPLO 00065 *> \verbatim 00066 *> UPLO is CHARACTER*1 00067 *> = 'U': Upper triangles of A and B are stored; 00068 *> = 'L': Lower triangles of A and B are stored. 00069 *> \endverbatim 00070 *> 00071 *> \param[in] N 00072 *> \verbatim 00073 *> N is INTEGER 00074 *> The order of the matrices A and B. N >= 0. 00075 *> \endverbatim 00076 *> 00077 *> \param[in,out] A 00078 *> \verbatim 00079 *> A is DOUBLE PRECISION array, dimension (LDA, N) 00080 *> On entry, the symmetric matrix A. If UPLO = 'U', the 00081 *> leading N-by-N upper triangular part of A contains the 00082 *> upper triangular part of the matrix A. If UPLO = 'L', 00083 *> the leading N-by-N lower triangular part of A contains 00084 *> the lower triangular part of the matrix A. 00085 *> 00086 *> On exit, if JOBZ = 'V', then if INFO = 0, A contains the 00087 *> matrix Z of eigenvectors. The eigenvectors are normalized 00088 *> as follows: 00089 *> if ITYPE = 1 or 2, Z**T*B*Z = I; 00090 *> if ITYPE = 3, Z**T*inv(B)*Z = I. 00091 *> If JOBZ = 'N', then on exit the upper triangle (if UPLO='U') 00092 *> or the lower triangle (if UPLO='L') of A, including the 00093 *> diagonal, is destroyed. 00094 *> \endverbatim 00095 *> 00096 *> \param[in] LDA 00097 *> \verbatim 00098 *> LDA is INTEGER 00099 *> The leading dimension of the array A. LDA >= max(1,N). 00100 *> \endverbatim 00101 *> 00102 *> \param[in,out] B 00103 *> \verbatim 00104 *> B is DOUBLE PRECISION array, dimension (LDB, N) 00105 *> On entry, the symmetric positive definite matrix B. 00106 *> If UPLO = 'U', the leading N-by-N upper triangular part of B 00107 *> contains the upper triangular part of the matrix B. 00108 *> If UPLO = 'L', the leading N-by-N lower triangular part of B 00109 *> contains the lower triangular part of the matrix B. 00110 *> 00111 *> On exit, if INFO <= N, the part of B containing the matrix is 00112 *> overwritten by the triangular factor U or L from the Cholesky 00113 *> factorization B = U**T*U or B = L*L**T. 00114 *> \endverbatim 00115 *> 00116 *> \param[in] LDB 00117 *> \verbatim 00118 *> LDB is INTEGER 00119 *> The leading dimension of the array B. LDB >= max(1,N). 00120 *> \endverbatim 00121 *> 00122 *> \param[out] W 00123 *> \verbatim 00124 *> W is DOUBLE PRECISION array, dimension (N) 00125 *> If INFO = 0, the eigenvalues in ascending order. 00126 *> \endverbatim 00127 *> 00128 *> \param[out] WORK 00129 *> \verbatim 00130 *> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)) 00131 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 00132 *> \endverbatim 00133 *> 00134 *> \param[in] LWORK 00135 *> \verbatim 00136 *> LWORK is INTEGER 00137 *> The length of the array WORK. LWORK >= max(1,3*N-1). 00138 *> For optimal efficiency, LWORK >= (NB+2)*N, 00139 *> where NB is the blocksize for DSYTRD returned by ILAENV. 00140 *> 00141 *> If LWORK = -1, then a workspace query is assumed; the routine 00142 *> only calculates the optimal size of the WORK array, returns 00143 *> this value as the first entry of the WORK array, and no error 00144 *> message related to LWORK is issued by XERBLA. 00145 *> \endverbatim 00146 *> 00147 *> \param[out] INFO 00148 *> \verbatim 00149 *> INFO is INTEGER 00150 *> = 0: successful exit 00151 *> < 0: if INFO = -i, the i-th argument had an illegal value 00152 *> > 0: DPOTRF or DSYEV returned an error code: 00153 *> <= N: if INFO = i, DSYEV failed to converge; 00154 *> i off-diagonal elements of an intermediate 00155 *> tridiagonal form did not converge to zero; 00156 *> > N: if INFO = N + i, for 1 <= i <= N, then the leading 00157 *> minor of order i of B is not positive definite. 00158 *> The factorization of B could not be completed and 00159 *> no eigenvalues or eigenvectors were computed. 00160 *> \endverbatim 00161 * 00162 * Authors: 00163 * ======== 00164 * 00165 *> \author Univ. of Tennessee 00166 *> \author Univ. of California Berkeley 00167 *> \author Univ. of Colorado Denver 00168 *> \author NAG Ltd. 00169 * 00170 *> \date November 2011 00171 * 00172 *> \ingroup doubleSYeigen 00173 * 00174 * ===================================================================== 00175 SUBROUTINE DSYGV( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK, 00176 $ LWORK, INFO ) 00177 * 00178 * -- LAPACK driver routine (version 3.4.0) -- 00179 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00180 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00181 * November 2011 00182 * 00183 * .. Scalar Arguments .. 00184 CHARACTER JOBZ, UPLO 00185 INTEGER INFO, ITYPE, LDA, LDB, LWORK, N 00186 * .. 00187 * .. Array Arguments .. 00188 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), W( * ), WORK( * ) 00189 * .. 00190 * 00191 * ===================================================================== 00192 * 00193 * .. Parameters .. 00194 DOUBLE PRECISION ONE 00195 PARAMETER ( ONE = 1.0D+0 ) 00196 * .. 00197 * .. Local Scalars .. 00198 LOGICAL LQUERY, UPPER, WANTZ 00199 CHARACTER TRANS 00200 INTEGER LWKMIN, LWKOPT, NB, NEIG 00201 * .. 00202 * .. External Functions .. 00203 LOGICAL LSAME 00204 INTEGER ILAENV 00205 EXTERNAL LSAME, ILAENV 00206 * .. 00207 * .. External Subroutines .. 00208 EXTERNAL DPOTRF, DSYEV, DSYGST, DTRMM, DTRSM, XERBLA 00209 * .. 00210 * .. Intrinsic Functions .. 00211 INTRINSIC MAX 00212 * .. 00213 * .. Executable Statements .. 00214 * 00215 * Test the input parameters. 00216 * 00217 WANTZ = LSAME( JOBZ, 'V' ) 00218 UPPER = LSAME( UPLO, 'U' ) 00219 LQUERY = ( LWORK.EQ.-1 ) 00220 * 00221 INFO = 0 00222 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN 00223 INFO = -1 00224 ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00225 INFO = -2 00226 ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN 00227 INFO = -3 00228 ELSE IF( N.LT.0 ) THEN 00229 INFO = -4 00230 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 00231 INFO = -6 00232 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN 00233 INFO = -8 00234 END IF 00235 * 00236 IF( INFO.EQ.0 ) THEN 00237 LWKMIN = MAX( 1, 3*N - 1 ) 00238 NB = ILAENV( 1, 'DSYTRD', UPLO, N, -1, -1, -1 ) 00239 LWKOPT = MAX( LWKMIN, ( NB + 2 )*N ) 00240 WORK( 1 ) = LWKOPT 00241 * 00242 IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY ) THEN 00243 INFO = -11 00244 END IF 00245 END IF 00246 * 00247 IF( INFO.NE.0 ) THEN 00248 CALL XERBLA( 'DSYGV ', -INFO ) 00249 RETURN 00250 ELSE IF( LQUERY ) THEN 00251 RETURN 00252 END IF 00253 * 00254 * Quick return if possible 00255 * 00256 IF( N.EQ.0 ) 00257 $ RETURN 00258 * 00259 * Form a Cholesky factorization of B. 00260 * 00261 CALL DPOTRF( UPLO, N, B, LDB, INFO ) 00262 IF( INFO.NE.0 ) THEN 00263 INFO = N + INFO 00264 RETURN 00265 END IF 00266 * 00267 * Transform problem to standard eigenvalue problem and solve. 00268 * 00269 CALL DSYGST( ITYPE, UPLO, N, A, LDA, B, LDB, INFO ) 00270 CALL DSYEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, INFO ) 00271 * 00272 IF( WANTZ ) THEN 00273 * 00274 * Backtransform eigenvectors to the original problem. 00275 * 00276 NEIG = N 00277 IF( INFO.GT.0 ) 00278 $ NEIG = INFO - 1 00279 IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN 00280 * 00281 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x; 00282 * backtransform eigenvectors: x = inv(L)**T*y or inv(U)*y 00283 * 00284 IF( UPPER ) THEN 00285 TRANS = 'N' 00286 ELSE 00287 TRANS = 'T' 00288 END IF 00289 * 00290 CALL DTRSM( 'Left', UPLO, TRANS, 'Non-unit', N, NEIG, ONE, 00291 $ B, LDB, A, LDA ) 00292 * 00293 ELSE IF( ITYPE.EQ.3 ) THEN 00294 * 00295 * For B*A*x=(lambda)*x; 00296 * backtransform eigenvectors: x = L*y or U**T*y 00297 * 00298 IF( UPPER ) THEN 00299 TRANS = 'T' 00300 ELSE 00301 TRANS = 'N' 00302 END IF 00303 * 00304 CALL DTRMM( 'Left', UPLO, TRANS, 'Non-unit', N, NEIG, ONE, 00305 $ B, LDB, A, LDA ) 00306 END IF 00307 END IF 00308 * 00309 WORK( 1 ) = LWKOPT 00310 RETURN 00311 * 00312 * End of DSYGV 00313 * 00314 END