![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SSYGST 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download SSYGVX + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssygvx.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssygvx.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssygvx.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE SSYGVX( ITYPE, JOBZ, RANGE, UPLO, N, A, LDA, B, LDB, 00022 * VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, 00023 * LWORK, IWORK, IFAIL, INFO ) 00024 * 00025 * .. Scalar Arguments .. 00026 * CHARACTER JOBZ, RANGE, UPLO 00027 * INTEGER IL, INFO, ITYPE, IU, LDA, LDB, LDZ, LWORK, M, N 00028 * REAL ABSTOL, VL, VU 00029 * .. 00030 * .. Array Arguments .. 00031 * INTEGER IFAIL( * ), IWORK( * ) 00032 * REAL A( LDA, * ), B( LDB, * ), W( * ), WORK( * ), 00033 * $ Z( LDZ, * ) 00034 * .. 00035 * 00036 * 00037 *> \par Purpose: 00038 * ============= 00039 *> 00040 *> \verbatim 00041 *> 00042 *> SSYGVX computes selected eigenvalues, and optionally, eigenvectors 00043 *> of a real generalized symmetric-definite eigenproblem, of the form 00044 *> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A 00045 *> and B are assumed to be symmetric and B is also positive definite. 00046 *> Eigenvalues and eigenvectors can be selected by specifying either a 00047 *> range of values or a range of indices for the desired eigenvalues. 00048 *> \endverbatim 00049 * 00050 * Arguments: 00051 * ========== 00052 * 00053 *> \param[in] ITYPE 00054 *> \verbatim 00055 *> ITYPE is INTEGER 00056 *> Specifies the problem type to be solved: 00057 *> = 1: A*x = (lambda)*B*x 00058 *> = 2: A*B*x = (lambda)*x 00059 *> = 3: B*A*x = (lambda)*x 00060 *> \endverbatim 00061 *> 00062 *> \param[in] JOBZ 00063 *> \verbatim 00064 *> JOBZ is CHARACTER*1 00065 *> = 'N': Compute eigenvalues only; 00066 *> = 'V': Compute eigenvalues and eigenvectors. 00067 *> \endverbatim 00068 *> 00069 *> \param[in] RANGE 00070 *> \verbatim 00071 *> RANGE is CHARACTER*1 00072 *> = 'A': all eigenvalues will be found. 00073 *> = 'V': all eigenvalues in the half-open interval (VL,VU] 00074 *> will be found. 00075 *> = 'I': the IL-th through IU-th eigenvalues will be found. 00076 *> \endverbatim 00077 *> 00078 *> \param[in] UPLO 00079 *> \verbatim 00080 *> UPLO is CHARACTER*1 00081 *> = 'U': Upper triangle of A and B are stored; 00082 *> = 'L': Lower triangle of A and B are stored. 00083 *> \endverbatim 00084 *> 00085 *> \param[in] N 00086 *> \verbatim 00087 *> N is INTEGER 00088 *> The order of the matrix pencil (A,B). N >= 0. 00089 *> \endverbatim 00090 *> 00091 *> \param[in,out] A 00092 *> \verbatim 00093 *> A is REAL array, dimension (LDA, N) 00094 *> On entry, the symmetric matrix A. If UPLO = 'U', the 00095 *> leading N-by-N upper triangular part of A contains the 00096 *> upper triangular part of the matrix A. If UPLO = 'L', 00097 *> the leading N-by-N lower triangular part of A contains 00098 *> the lower triangular part of the matrix A. 00099 *> 00100 *> On exit, the lower triangle (if UPLO='L') or the upper 00101 *> triangle (if UPLO='U') of A, including the diagonal, is 00102 *> destroyed. 00103 *> \endverbatim 00104 *> 00105 *> \param[in] LDA 00106 *> \verbatim 00107 *> LDA is INTEGER 00108 *> The leading dimension of the array A. LDA >= max(1,N). 00109 *> \endverbatim 00110 *> 00111 *> \param[in,out] B 00112 *> \verbatim 00113 *> B is REAL array, dimension (LDA, N) 00114 *> On entry, the symmetric matrix B. If UPLO = 'U', the 00115 *> leading N-by-N upper triangular part of B contains the 00116 *> upper triangular part of the matrix B. If UPLO = 'L', 00117 *> the leading N-by-N lower triangular part of B contains 00118 *> the lower triangular part of the matrix B. 00119 *> 00120 *> On exit, if INFO <= N, the part of B containing the matrix is 00121 *> overwritten by the triangular factor U or L from the Cholesky 00122 *> factorization B = U**T*U or B = L*L**T. 00123 *> \endverbatim 00124 *> 00125 *> \param[in] LDB 00126 *> \verbatim 00127 *> LDB is INTEGER 00128 *> The leading dimension of the array B. LDB >= max(1,N). 00129 *> \endverbatim 00130 *> 00131 *> \param[in] VL 00132 *> \verbatim 00133 *> VL is REAL 00134 *> \endverbatim 00135 *> 00136 *> \param[in] VU 00137 *> \verbatim 00138 *> VU is REAL 00139 *> If RANGE='V', the lower and upper bounds of the interval to 00140 *> be searched for eigenvalues. VL < VU. 00141 *> Not referenced if RANGE = 'A' or 'I'. 00142 *> \endverbatim 00143 *> 00144 *> \param[in] IL 00145 *> \verbatim 00146 *> IL is INTEGER 00147 *> \endverbatim 00148 *> 00149 *> \param[in] IU 00150 *> \verbatim 00151 *> IU is INTEGER 00152 *> If RANGE='I', the indices (in ascending order) of the 00153 *> smallest and largest eigenvalues to be returned. 00154 *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. 00155 *> Not referenced if RANGE = 'A' or 'V'. 00156 *> \endverbatim 00157 *> 00158 *> \param[in] ABSTOL 00159 *> \verbatim 00160 *> ABSTOL is REAL 00161 *> The absolute error tolerance for the eigenvalues. 00162 *> An approximate eigenvalue is accepted as converged 00163 *> when it is determined to lie in an interval [a,b] 00164 *> of width less than or equal to 00165 *> 00166 *> ABSTOL + EPS * max( |a|,|b| ) , 00167 *> 00168 *> where EPS is the machine precision. If ABSTOL is less than 00169 *> or equal to zero, then EPS*|T| will be used in its place, 00170 *> where |T| is the 1-norm of the tridiagonal matrix obtained 00171 *> by reducing C to tridiagonal form, where C is the symmetric 00172 *> matrix of the standard symmetric problem to which the 00173 *> generalized problem is transformed. 00174 *> 00175 *> Eigenvalues will be computed most accurately when ABSTOL is 00176 *> set to twice the underflow threshold 2*DLAMCH('S'), not zero. 00177 *> If this routine returns with INFO>0, indicating that some 00178 *> eigenvectors did not converge, try setting ABSTOL to 00179 *> 2*SLAMCH('S'). 00180 *> \endverbatim 00181 *> 00182 *> \param[out] M 00183 *> \verbatim 00184 *> M is INTEGER 00185 *> The total number of eigenvalues found. 0 <= M <= N. 00186 *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1. 00187 *> \endverbatim 00188 *> 00189 *> \param[out] W 00190 *> \verbatim 00191 *> W is REAL array, dimension (N) 00192 *> On normal exit, the first M elements contain the selected 00193 *> eigenvalues in ascending order. 00194 *> \endverbatim 00195 *> 00196 *> \param[out] Z 00197 *> \verbatim 00198 *> Z is REAL array, dimension (LDZ, max(1,M)) 00199 *> If JOBZ = 'N', then Z is not referenced. 00200 *> If JOBZ = 'V', then if INFO = 0, the first M columns of Z 00201 *> contain the orthonormal eigenvectors of the matrix A 00202 *> corresponding to the selected eigenvalues, with the i-th 00203 *> column of Z holding the eigenvector associated with W(i). 00204 *> The eigenvectors are normalized as follows: 00205 *> if ITYPE = 1 or 2, Z**T*B*Z = I; 00206 *> if ITYPE = 3, Z**T*inv(B)*Z = I. 00207 *> 00208 *> If an eigenvector fails to converge, then that column of Z 00209 *> contains the latest approximation to the eigenvector, and the 00210 *> index of the eigenvector is returned in IFAIL. 00211 *> Note: the user must ensure that at least max(1,M) columns are 00212 *> supplied in the array Z; if RANGE = 'V', the exact value of M 00213 *> is not known in advance and an upper bound must be used. 00214 *> \endverbatim 00215 *> 00216 *> \param[in] LDZ 00217 *> \verbatim 00218 *> LDZ is INTEGER 00219 *> The leading dimension of the array Z. LDZ >= 1, and if 00220 *> JOBZ = 'V', LDZ >= max(1,N). 00221 *> \endverbatim 00222 *> 00223 *> \param[out] WORK 00224 *> \verbatim 00225 *> WORK is REAL array, dimension (MAX(1,LWORK)) 00226 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 00227 *> \endverbatim 00228 *> 00229 *> \param[in] LWORK 00230 *> \verbatim 00231 *> LWORK is INTEGER 00232 *> The length of the array WORK. LWORK >= max(1,8*N). 00233 *> For optimal efficiency, LWORK >= (NB+3)*N, 00234 *> where NB is the blocksize for SSYTRD returned by ILAENV. 00235 *> 00236 *> If LWORK = -1, then a workspace query is assumed; the routine 00237 *> only calculates the optimal size of the WORK array, returns 00238 *> this value as the first entry of the WORK array, and no error 00239 *> message related to LWORK is issued by XERBLA. 00240 *> \endverbatim 00241 *> 00242 *> \param[out] IWORK 00243 *> \verbatim 00244 *> IWORK is INTEGER array, dimension (5*N) 00245 *> \endverbatim 00246 *> 00247 *> \param[out] IFAIL 00248 *> \verbatim 00249 *> IFAIL is INTEGER array, dimension (N) 00250 *> If JOBZ = 'V', then if INFO = 0, the first M elements of 00251 *> IFAIL are zero. If INFO > 0, then IFAIL contains the 00252 *> indices of the eigenvectors that failed to converge. 00253 *> If JOBZ = 'N', then IFAIL is not referenced. 00254 *> \endverbatim 00255 *> 00256 *> \param[out] INFO 00257 *> \verbatim 00258 *> INFO is INTEGER 00259 *> = 0: successful exit 00260 *> < 0: if INFO = -i, the i-th argument had an illegal value 00261 *> > 0: SPOTRF or SSYEVX returned an error code: 00262 *> <= N: if INFO = i, SSYEVX failed to converge; 00263 *> i eigenvectors failed to converge. Their indices 00264 *> are stored in array IFAIL. 00265 *> > N: if INFO = N + i, for 1 <= i <= N, then the leading 00266 *> minor of order i of B is not positive definite. 00267 *> The factorization of B could not be completed and 00268 *> no eigenvalues or eigenvectors were computed. 00269 *> \endverbatim 00270 * 00271 * Authors: 00272 * ======== 00273 * 00274 *> \author Univ. of Tennessee 00275 *> \author Univ. of California Berkeley 00276 *> \author Univ. of Colorado Denver 00277 *> \author NAG Ltd. 00278 * 00279 *> \date November 2011 00280 * 00281 *> \ingroup realSYeigen 00282 * 00283 *> \par Contributors: 00284 * ================== 00285 *> 00286 *> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA 00287 * 00288 * ===================================================================== 00289 SUBROUTINE SSYGVX( ITYPE, JOBZ, RANGE, UPLO, N, A, LDA, B, LDB, 00290 $ VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, 00291 $ LWORK, IWORK, IFAIL, INFO ) 00292 * 00293 * -- LAPACK driver routine (version 3.4.0) -- 00294 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00295 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00296 * November 2011 00297 * 00298 * .. Scalar Arguments .. 00299 CHARACTER JOBZ, RANGE, UPLO 00300 INTEGER IL, INFO, ITYPE, IU, LDA, LDB, LDZ, LWORK, M, N 00301 REAL ABSTOL, VL, VU 00302 * .. 00303 * .. Array Arguments .. 00304 INTEGER IFAIL( * ), IWORK( * ) 00305 REAL A( LDA, * ), B( LDB, * ), W( * ), WORK( * ), 00306 $ Z( LDZ, * ) 00307 * .. 00308 * 00309 * ===================================================================== 00310 * 00311 * .. Parameters .. 00312 REAL ONE 00313 PARAMETER ( ONE = 1.0E+0 ) 00314 * .. 00315 * .. Local Scalars .. 00316 LOGICAL ALLEIG, INDEIG, LQUERY, UPPER, VALEIG, WANTZ 00317 CHARACTER TRANS 00318 INTEGER LWKMIN, LWKOPT, NB 00319 * .. 00320 * .. External Functions .. 00321 LOGICAL LSAME 00322 INTEGER ILAENV 00323 EXTERNAL ILAENV, LSAME 00324 * .. 00325 * .. External Subroutines .. 00326 EXTERNAL SPOTRF, SSYEVX, SSYGST, STRMM, STRSM, XERBLA 00327 * .. 00328 * .. Intrinsic Functions .. 00329 INTRINSIC MAX, MIN 00330 * .. 00331 * .. Executable Statements .. 00332 * 00333 * Test the input parameters. 00334 * 00335 UPPER = LSAME( UPLO, 'U' ) 00336 WANTZ = LSAME( JOBZ, 'V' ) 00337 ALLEIG = LSAME( RANGE, 'A' ) 00338 VALEIG = LSAME( RANGE, 'V' ) 00339 INDEIG = LSAME( RANGE, 'I' ) 00340 LQUERY = ( LWORK.EQ.-1 ) 00341 * 00342 INFO = 0 00343 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN 00344 INFO = -1 00345 ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00346 INFO = -2 00347 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN 00348 INFO = -3 00349 ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN 00350 INFO = -4 00351 ELSE IF( N.LT.0 ) THEN 00352 INFO = -5 00353 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN 00354 INFO = -7 00355 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN 00356 INFO = -9 00357 ELSE 00358 IF( VALEIG ) THEN 00359 IF( N.GT.0 .AND. VU.LE.VL ) 00360 $ INFO = -11 00361 ELSE IF( INDEIG ) THEN 00362 IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN 00363 INFO = -12 00364 ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN 00365 INFO = -13 00366 END IF 00367 END IF 00368 END IF 00369 IF (INFO.EQ.0) THEN 00370 IF (LDZ.LT.1 .OR. (WANTZ .AND. LDZ.LT.N)) THEN 00371 INFO = -18 00372 END IF 00373 END IF 00374 * 00375 IF( INFO.EQ.0 ) THEN 00376 LWKMIN = MAX( 1, 8*N ) 00377 NB = ILAENV( 1, 'SSYTRD', UPLO, N, -1, -1, -1 ) 00378 LWKOPT = MAX( LWKMIN, ( NB + 3 )*N ) 00379 WORK( 1 ) = LWKOPT 00380 * 00381 IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY ) THEN 00382 INFO = -20 00383 END IF 00384 END IF 00385 * 00386 IF( INFO.NE.0 ) THEN 00387 CALL XERBLA( 'SSYGVX', -INFO ) 00388 RETURN 00389 ELSE IF( LQUERY ) THEN 00390 RETURN 00391 END IF 00392 * 00393 * Quick return if possible 00394 * 00395 M = 0 00396 IF( N.EQ.0 ) THEN 00397 RETURN 00398 END IF 00399 * 00400 * Form a Cholesky factorization of B. 00401 * 00402 CALL SPOTRF( UPLO, N, B, LDB, INFO ) 00403 IF( INFO.NE.0 ) THEN 00404 INFO = N + INFO 00405 RETURN 00406 END IF 00407 * 00408 * Transform problem to standard eigenvalue problem and solve. 00409 * 00410 CALL SSYGST( ITYPE, UPLO, N, A, LDA, B, LDB, INFO ) 00411 CALL SSYEVX( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU, ABSTOL, 00412 $ M, W, Z, LDZ, WORK, LWORK, IWORK, IFAIL, INFO ) 00413 * 00414 IF( WANTZ ) THEN 00415 * 00416 * Backtransform eigenvectors to the original problem. 00417 * 00418 IF( INFO.GT.0 ) 00419 $ M = INFO - 1 00420 IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN 00421 * 00422 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x; 00423 * backtransform eigenvectors: x = inv(L)**T*y or inv(U)*y 00424 * 00425 IF( UPPER ) THEN 00426 TRANS = 'N' 00427 ELSE 00428 TRANS = 'T' 00429 END IF 00430 * 00431 CALL STRSM( 'Left', UPLO, TRANS, 'Non-unit', N, M, ONE, B, 00432 $ LDB, Z, LDZ ) 00433 * 00434 ELSE IF( ITYPE.EQ.3 ) THEN 00435 * 00436 * For B*A*x=(lambda)*x; 00437 * backtransform eigenvectors: x = L*y or U**T*y 00438 * 00439 IF( UPPER ) THEN 00440 TRANS = 'T' 00441 ELSE 00442 TRANS = 'N' 00443 END IF 00444 * 00445 CALL STRMM( 'Left', UPLO, TRANS, 'Non-unit', N, M, ONE, B, 00446 $ LDB, Z, LDZ ) 00447 END IF 00448 END IF 00449 * 00450 * Set WORK(1) to optimal workspace size. 00451 * 00452 WORK( 1 ) = LWKOPT 00453 * 00454 RETURN 00455 * 00456 * End of SSYGVX 00457 * 00458 END