![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b DSPGST 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download DSPGVD + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dspgvd.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dspgvd.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dspgvd.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE DSPGVD( ITYPE, JOBZ, UPLO, N, AP, BP, W, Z, LDZ, WORK, 00022 * LWORK, IWORK, LIWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER JOBZ, UPLO 00026 * INTEGER INFO, ITYPE, LDZ, LIWORK, LWORK, N 00027 * .. 00028 * .. Array Arguments .. 00029 * INTEGER IWORK( * ) 00030 * DOUBLE PRECISION AP( * ), BP( * ), W( * ), WORK( * ), 00031 * $ Z( LDZ, * ) 00032 * .. 00033 * 00034 * 00035 *> \par Purpose: 00036 * ============= 00037 *> 00038 *> \verbatim 00039 *> 00040 *> DSPGVD computes all the eigenvalues, and optionally, the eigenvectors 00041 *> of a real generalized symmetric-definite eigenproblem, of the form 00042 *> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A and 00043 *> B are assumed to be symmetric, stored in packed format, and B is also 00044 *> positive definite. 00045 *> If eigenvectors are desired, it uses a divide and conquer algorithm. 00046 *> 00047 *> The divide and conquer algorithm makes very mild assumptions about 00048 *> floating point arithmetic. It will work on machines with a guard 00049 *> digit in add/subtract, or on those binary machines without guard 00050 *> digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or 00051 *> Cray-2. It could conceivably fail on hexadecimal or decimal machines 00052 *> without guard digits, but we know of none. 00053 *> \endverbatim 00054 * 00055 * Arguments: 00056 * ========== 00057 * 00058 *> \param[in] ITYPE 00059 *> \verbatim 00060 *> ITYPE is INTEGER 00061 *> Specifies the problem type to be solved: 00062 *> = 1: A*x = (lambda)*B*x 00063 *> = 2: A*B*x = (lambda)*x 00064 *> = 3: B*A*x = (lambda)*x 00065 *> \endverbatim 00066 *> 00067 *> \param[in] JOBZ 00068 *> \verbatim 00069 *> JOBZ is CHARACTER*1 00070 *> = 'N': Compute eigenvalues only; 00071 *> = 'V': Compute eigenvalues and eigenvectors. 00072 *> \endverbatim 00073 *> 00074 *> \param[in] UPLO 00075 *> \verbatim 00076 *> UPLO is CHARACTER*1 00077 *> = 'U': Upper triangles of A and B are stored; 00078 *> = 'L': Lower triangles of A and B are stored. 00079 *> \endverbatim 00080 *> 00081 *> \param[in] N 00082 *> \verbatim 00083 *> N is INTEGER 00084 *> The order of the matrices A and B. N >= 0. 00085 *> \endverbatim 00086 *> 00087 *> \param[in,out] AP 00088 *> \verbatim 00089 *> AP is DOUBLE PRECISION array, dimension (N*(N+1)/2) 00090 *> On entry, the upper or lower triangle of the symmetric matrix 00091 *> A, packed columnwise in a linear array. The j-th column of A 00092 *> is stored in the array AP as follows: 00093 *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00094 *> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. 00095 *> 00096 *> On exit, the contents of AP are destroyed. 00097 *> \endverbatim 00098 *> 00099 *> \param[in,out] BP 00100 *> \verbatim 00101 *> BP is DOUBLE PRECISION array, dimension (N*(N+1)/2) 00102 *> On entry, the upper or lower triangle of the symmetric matrix 00103 *> B, packed columnwise in a linear array. The j-th column of B 00104 *> is stored in the array BP as follows: 00105 *> if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j; 00106 *> if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n. 00107 *> 00108 *> On exit, the triangular factor U or L from the Cholesky 00109 *> factorization B = U**T*U or B = L*L**T, in the same storage 00110 *> format as B. 00111 *> \endverbatim 00112 *> 00113 *> \param[out] W 00114 *> \verbatim 00115 *> W is DOUBLE PRECISION array, dimension (N) 00116 *> If INFO = 0, the eigenvalues in ascending order. 00117 *> \endverbatim 00118 *> 00119 *> \param[out] Z 00120 *> \verbatim 00121 *> Z is DOUBLE PRECISION array, dimension (LDZ, N) 00122 *> If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of 00123 *> eigenvectors. The eigenvectors are normalized as follows: 00124 *> if ITYPE = 1 or 2, Z**T*B*Z = I; 00125 *> if ITYPE = 3, Z**T*inv(B)*Z = I. 00126 *> If JOBZ = 'N', then Z is not referenced. 00127 *> \endverbatim 00128 *> 00129 *> \param[in] LDZ 00130 *> \verbatim 00131 *> LDZ is INTEGER 00132 *> The leading dimension of the array Z. LDZ >= 1, and if 00133 *> JOBZ = 'V', LDZ >= max(1,N). 00134 *> \endverbatim 00135 *> 00136 *> \param[out] WORK 00137 *> \verbatim 00138 *> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)) 00139 *> On exit, if INFO = 0, WORK(1) returns the required LWORK. 00140 *> \endverbatim 00141 *> 00142 *> \param[in] LWORK 00143 *> \verbatim 00144 *> LWORK is INTEGER 00145 *> The dimension of the array WORK. 00146 *> If N <= 1, LWORK >= 1. 00147 *> If JOBZ = 'N' and N > 1, LWORK >= 2*N. 00148 *> If JOBZ = 'V' and N > 1, LWORK >= 1 + 6*N + 2*N**2. 00149 *> 00150 *> If LWORK = -1, then a workspace query is assumed; the routine 00151 *> only calculates the required sizes of the WORK and IWORK 00152 *> arrays, returns these values as the first entries of the WORK 00153 *> and IWORK arrays, and no error message related to LWORK or 00154 *> LIWORK is issued by XERBLA. 00155 *> \endverbatim 00156 *> 00157 *> \param[out] IWORK 00158 *> \verbatim 00159 *> IWORK is INTEGER array, dimension (MAX(1,LIWORK)) 00160 *> On exit, if INFO = 0, IWORK(1) returns the required LIWORK. 00161 *> \endverbatim 00162 *> 00163 *> \param[in] LIWORK 00164 *> \verbatim 00165 *> LIWORK is INTEGER 00166 *> The dimension of the array IWORK. 00167 *> If JOBZ = 'N' or N <= 1, LIWORK >= 1. 00168 *> If JOBZ = 'V' and N > 1, LIWORK >= 3 + 5*N. 00169 *> 00170 *> If LIWORK = -1, then a workspace query is assumed; the 00171 *> routine only calculates the required sizes of the WORK and 00172 *> IWORK arrays, returns these values as the first entries of 00173 *> the WORK and IWORK arrays, and no error message related to 00174 *> LWORK or LIWORK is issued by XERBLA. 00175 *> \endverbatim 00176 *> 00177 *> \param[out] INFO 00178 *> \verbatim 00179 *> INFO is INTEGER 00180 *> = 0: successful exit 00181 *> < 0: if INFO = -i, the i-th argument had an illegal value 00182 *> > 0: DPPTRF or DSPEVD returned an error code: 00183 *> <= N: if INFO = i, DSPEVD failed to converge; 00184 *> i off-diagonal elements of an intermediate 00185 *> tridiagonal form did not converge to zero; 00186 *> > N: if INFO = N + i, for 1 <= i <= N, then the leading 00187 *> minor of order i of B is not positive definite. 00188 *> The factorization of B could not be completed and 00189 *> no eigenvalues or eigenvectors were computed. 00190 *> \endverbatim 00191 * 00192 * Authors: 00193 * ======== 00194 * 00195 *> \author Univ. of Tennessee 00196 *> \author Univ. of California Berkeley 00197 *> \author Univ. of Colorado Denver 00198 *> \author NAG Ltd. 00199 * 00200 *> \date November 2011 00201 * 00202 *> \ingroup doubleOTHEReigen 00203 * 00204 *> \par Contributors: 00205 * ================== 00206 *> 00207 *> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA 00208 * 00209 * ===================================================================== 00210 SUBROUTINE DSPGVD( ITYPE, JOBZ, UPLO, N, AP, BP, W, Z, LDZ, WORK, 00211 $ LWORK, IWORK, LIWORK, INFO ) 00212 * 00213 * -- LAPACK driver routine (version 3.4.0) -- 00214 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00215 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00216 * November 2011 00217 * 00218 * .. Scalar Arguments .. 00219 CHARACTER JOBZ, UPLO 00220 INTEGER INFO, ITYPE, LDZ, LIWORK, LWORK, N 00221 * .. 00222 * .. Array Arguments .. 00223 INTEGER IWORK( * ) 00224 DOUBLE PRECISION AP( * ), BP( * ), W( * ), WORK( * ), 00225 $ Z( LDZ, * ) 00226 * .. 00227 * 00228 * ===================================================================== 00229 * 00230 * .. Local Scalars .. 00231 LOGICAL LQUERY, UPPER, WANTZ 00232 CHARACTER TRANS 00233 INTEGER J, LIWMIN, LWMIN, NEIG 00234 * .. 00235 * .. External Functions .. 00236 LOGICAL LSAME 00237 EXTERNAL LSAME 00238 * .. 00239 * .. External Subroutines .. 00240 EXTERNAL DPPTRF, DSPEVD, DSPGST, DTPMV, DTPSV, XERBLA 00241 * .. 00242 * .. Intrinsic Functions .. 00243 INTRINSIC DBLE, MAX 00244 * .. 00245 * .. Executable Statements .. 00246 * 00247 * Test the input parameters. 00248 * 00249 WANTZ = LSAME( JOBZ, 'V' ) 00250 UPPER = LSAME( UPLO, 'U' ) 00251 LQUERY = ( LWORK.EQ.-1 .OR. LIWORK.EQ.-1 ) 00252 * 00253 INFO = 0 00254 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN 00255 INFO = -1 00256 ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00257 INFO = -2 00258 ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN 00259 INFO = -3 00260 ELSE IF( N.LT.0 ) THEN 00261 INFO = -4 00262 ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN 00263 INFO = -9 00264 END IF 00265 * 00266 IF( INFO.EQ.0 ) THEN 00267 IF( N.LE.1 ) THEN 00268 LIWMIN = 1 00269 LWMIN = 1 00270 ELSE 00271 IF( WANTZ ) THEN 00272 LIWMIN = 3 + 5*N 00273 LWMIN = 1 + 6*N + 2*N**2 00274 ELSE 00275 LIWMIN = 1 00276 LWMIN = 2*N 00277 END IF 00278 END IF 00279 WORK( 1 ) = LWMIN 00280 IWORK( 1 ) = LIWMIN 00281 IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN 00282 INFO = -11 00283 ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN 00284 INFO = -13 00285 END IF 00286 END IF 00287 * 00288 IF( INFO.NE.0 ) THEN 00289 CALL XERBLA( 'DSPGVD', -INFO ) 00290 RETURN 00291 ELSE IF( LQUERY ) THEN 00292 RETURN 00293 END IF 00294 * 00295 * Quick return if possible 00296 * 00297 IF( N.EQ.0 ) 00298 $ RETURN 00299 * 00300 * Form a Cholesky factorization of BP. 00301 * 00302 CALL DPPTRF( UPLO, N, BP, INFO ) 00303 IF( INFO.NE.0 ) THEN 00304 INFO = N + INFO 00305 RETURN 00306 END IF 00307 * 00308 * Transform problem to standard eigenvalue problem and solve. 00309 * 00310 CALL DSPGST( ITYPE, UPLO, N, AP, BP, INFO ) 00311 CALL DSPEVD( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, LWORK, IWORK, 00312 $ LIWORK, INFO ) 00313 LWMIN = MAX( DBLE( LWMIN ), DBLE( WORK( 1 ) ) ) 00314 LIWMIN = MAX( DBLE( LIWMIN ), DBLE( IWORK( 1 ) ) ) 00315 * 00316 IF( WANTZ ) THEN 00317 * 00318 * Backtransform eigenvectors to the original problem. 00319 * 00320 NEIG = N 00321 IF( INFO.GT.0 ) 00322 $ NEIG = INFO - 1 00323 IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN 00324 * 00325 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x; 00326 * backtransform eigenvectors: x = inv(L)**T *y or inv(U)*y 00327 * 00328 IF( UPPER ) THEN 00329 TRANS = 'N' 00330 ELSE 00331 TRANS = 'T' 00332 END IF 00333 * 00334 DO 10 J = 1, NEIG 00335 CALL DTPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ), 00336 $ 1 ) 00337 10 CONTINUE 00338 * 00339 ELSE IF( ITYPE.EQ.3 ) THEN 00340 * 00341 * For B*A*x=(lambda)*x; 00342 * backtransform eigenvectors: x = L*y or U**T *y 00343 * 00344 IF( UPPER ) THEN 00345 TRANS = 'T' 00346 ELSE 00347 TRANS = 'N' 00348 END IF 00349 * 00350 DO 20 J = 1, NEIG 00351 CALL DTPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ), 00352 $ 1 ) 00353 20 CONTINUE 00354 END IF 00355 END IF 00356 * 00357 WORK( 1 ) = LWMIN 00358 IWORK( 1 ) = LIWMIN 00359 * 00360 RETURN 00361 * 00362 * End of DSPGVD 00363 * 00364 END