![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief <b> DSPEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER 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 DSPEVD + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dspevd.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dspevd.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dspevd.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE DSPEVD( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, LWORK, 00022 * IWORK, LIWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER JOBZ, UPLO 00026 * INTEGER INFO, LDZ, LIWORK, LWORK, N 00027 * .. 00028 * .. Array Arguments .. 00029 * INTEGER IWORK( * ) 00030 * DOUBLE PRECISION AP( * ), W( * ), WORK( * ), Z( LDZ, * ) 00031 * .. 00032 * 00033 * 00034 *> \par Purpose: 00035 * ============= 00036 *> 00037 *> \verbatim 00038 *> 00039 *> DSPEVD computes all the eigenvalues and, optionally, eigenvectors 00040 *> of a real symmetric matrix A in packed storage. If eigenvectors are 00041 *> desired, it uses a divide and conquer algorithm. 00042 *> 00043 *> The divide and conquer algorithm makes very mild assumptions about 00044 *> floating point arithmetic. It will work on machines with a guard 00045 *> digit in add/subtract, or on those binary machines without guard 00046 *> digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or 00047 *> Cray-2. It could conceivably fail on hexadecimal or decimal machines 00048 *> without guard digits, but we know of none. 00049 *> \endverbatim 00050 * 00051 * Arguments: 00052 * ========== 00053 * 00054 *> \param[in] JOBZ 00055 *> \verbatim 00056 *> JOBZ is CHARACTER*1 00057 *> = 'N': Compute eigenvalues only; 00058 *> = 'V': Compute eigenvalues and eigenvectors. 00059 *> \endverbatim 00060 *> 00061 *> \param[in] UPLO 00062 *> \verbatim 00063 *> UPLO is CHARACTER*1 00064 *> = 'U': Upper triangle of A is stored; 00065 *> = 'L': Lower triangle of A is stored. 00066 *> \endverbatim 00067 *> 00068 *> \param[in] N 00069 *> \verbatim 00070 *> N is INTEGER 00071 *> The order of the matrix A. N >= 0. 00072 *> \endverbatim 00073 *> 00074 *> \param[in,out] AP 00075 *> \verbatim 00076 *> AP is DOUBLE PRECISION array, dimension (N*(N+1)/2) 00077 *> On entry, the upper or lower triangle of the symmetric matrix 00078 *> A, packed columnwise in a linear array. The j-th column of A 00079 *> is stored in the array AP as follows: 00080 *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00081 *> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. 00082 *> 00083 *> On exit, AP is overwritten by values generated during the 00084 *> reduction to tridiagonal form. If UPLO = 'U', the diagonal 00085 *> and first superdiagonal of the tridiagonal matrix T overwrite 00086 *> the corresponding elements of A, and if UPLO = 'L', the 00087 *> diagonal and first subdiagonal of T overwrite the 00088 *> corresponding elements of A. 00089 *> \endverbatim 00090 *> 00091 *> \param[out] W 00092 *> \verbatim 00093 *> W is DOUBLE PRECISION array, dimension (N) 00094 *> If INFO = 0, the eigenvalues in ascending order. 00095 *> \endverbatim 00096 *> 00097 *> \param[out] Z 00098 *> \verbatim 00099 *> Z is DOUBLE PRECISION array, dimension (LDZ, N) 00100 *> If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal 00101 *> eigenvectors of the matrix A, with the i-th column of Z 00102 *> holding the eigenvector associated with W(i). 00103 *> If JOBZ = 'N', then Z is not referenced. 00104 *> \endverbatim 00105 *> 00106 *> \param[in] LDZ 00107 *> \verbatim 00108 *> LDZ is INTEGER 00109 *> The leading dimension of the array Z. LDZ >= 1, and if 00110 *> JOBZ = 'V', LDZ >= max(1,N). 00111 *> \endverbatim 00112 *> 00113 *> \param[out] WORK 00114 *> \verbatim 00115 *> WORK is DOUBLE PRECISION array, 00116 *> dimension (LWORK) 00117 *> On exit, if INFO = 0, WORK(1) returns the required LWORK. 00118 *> \endverbatim 00119 *> 00120 *> \param[in] LWORK 00121 *> \verbatim 00122 *> LWORK is INTEGER 00123 *> The dimension of the array WORK. 00124 *> If N <= 1, LWORK must be at least 1. 00125 *> If JOBZ = 'N' and N > 1, LWORK must be at least 2*N. 00126 *> If JOBZ = 'V' and N > 1, LWORK must be at least 00127 *> 1 + 6*N + N**2. 00128 *> 00129 *> If LWORK = -1, then a workspace query is assumed; the routine 00130 *> only calculates the required sizes of the WORK and IWORK 00131 *> arrays, returns these values as the first entries of the WORK 00132 *> and IWORK arrays, and no error message related to LWORK or 00133 *> LIWORK is issued by XERBLA. 00134 *> \endverbatim 00135 *> 00136 *> \param[out] IWORK 00137 *> \verbatim 00138 *> IWORK is INTEGER array, dimension (MAX(1,LIWORK)) 00139 *> On exit, if INFO = 0, IWORK(1) returns the required LIWORK. 00140 *> \endverbatim 00141 *> 00142 *> \param[in] LIWORK 00143 *> \verbatim 00144 *> LIWORK is INTEGER 00145 *> The dimension of the array IWORK. 00146 *> If JOBZ = 'N' or N <= 1, LIWORK must be at least 1. 00147 *> If JOBZ = 'V' and N > 1, LIWORK must be at least 3 + 5*N. 00148 *> 00149 *> If LIWORK = -1, then a workspace query is assumed; the 00150 *> routine only calculates the required sizes of the WORK and 00151 *> IWORK arrays, returns these values as the first entries of 00152 *> the WORK and IWORK arrays, and no error message related to 00153 *> LWORK or LIWORK is issued by XERBLA. 00154 *> \endverbatim 00155 *> 00156 *> \param[out] INFO 00157 *> \verbatim 00158 *> INFO is INTEGER 00159 *> = 0: successful exit 00160 *> < 0: if INFO = -i, the i-th argument had an illegal value. 00161 *> > 0: if INFO = i, the algorithm failed to converge; i 00162 *> off-diagonal elements of an intermediate tridiagonal 00163 *> form did not converge to zero. 00164 *> \endverbatim 00165 * 00166 * Authors: 00167 * ======== 00168 * 00169 *> \author Univ. of Tennessee 00170 *> \author Univ. of California Berkeley 00171 *> \author Univ. of Colorado Denver 00172 *> \author NAG Ltd. 00173 * 00174 *> \date November 2011 00175 * 00176 *> \ingroup doubleOTHEReigen 00177 * 00178 * ===================================================================== 00179 SUBROUTINE DSPEVD( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, LWORK, 00180 $ IWORK, LIWORK, INFO ) 00181 * 00182 * -- LAPACK driver routine (version 3.4.0) -- 00183 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00184 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00185 * November 2011 00186 * 00187 * .. Scalar Arguments .. 00188 CHARACTER JOBZ, UPLO 00189 INTEGER INFO, LDZ, LIWORK, LWORK, N 00190 * .. 00191 * .. Array Arguments .. 00192 INTEGER IWORK( * ) 00193 DOUBLE PRECISION AP( * ), W( * ), WORK( * ), Z( LDZ, * ) 00194 * .. 00195 * 00196 * ===================================================================== 00197 * 00198 * .. Parameters .. 00199 DOUBLE PRECISION ZERO, ONE 00200 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) 00201 * .. 00202 * .. Local Scalars .. 00203 LOGICAL LQUERY, WANTZ 00204 INTEGER IINFO, INDE, INDTAU, INDWRK, ISCALE, LIWMIN, 00205 $ LLWORK, LWMIN 00206 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, 00207 $ SMLNUM 00208 * .. 00209 * .. External Functions .. 00210 LOGICAL LSAME 00211 DOUBLE PRECISION DLAMCH, DLANSP 00212 EXTERNAL LSAME, DLAMCH, DLANSP 00213 * .. 00214 * .. External Subroutines .. 00215 EXTERNAL DOPMTR, DSCAL, DSPTRD, DSTEDC, DSTERF, XERBLA 00216 * .. 00217 * .. Intrinsic Functions .. 00218 INTRINSIC SQRT 00219 * .. 00220 * .. Executable Statements .. 00221 * 00222 * Test the input parameters. 00223 * 00224 WANTZ = LSAME( JOBZ, 'V' ) 00225 LQUERY = ( LWORK.EQ.-1 .OR. LIWORK.EQ.-1 ) 00226 * 00227 INFO = 0 00228 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00229 INFO = -1 00230 ELSE IF( .NOT.( LSAME( UPLO, 'U' ) .OR. LSAME( UPLO, 'L' ) ) ) 00231 $ THEN 00232 INFO = -2 00233 ELSE IF( N.LT.0 ) THEN 00234 INFO = -3 00235 ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN 00236 INFO = -7 00237 END IF 00238 * 00239 IF( INFO.EQ.0 ) THEN 00240 IF( N.LE.1 ) THEN 00241 LIWMIN = 1 00242 LWMIN = 1 00243 ELSE 00244 IF( WANTZ ) THEN 00245 LIWMIN = 3 + 5*N 00246 LWMIN = 1 + 6*N + N**2 00247 ELSE 00248 LIWMIN = 1 00249 LWMIN = 2*N 00250 END IF 00251 END IF 00252 IWORK( 1 ) = LIWMIN 00253 WORK( 1 ) = LWMIN 00254 * 00255 IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN 00256 INFO = -9 00257 ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN 00258 INFO = -11 00259 END IF 00260 END IF 00261 * 00262 IF( INFO.NE.0 ) THEN 00263 CALL XERBLA( 'DSPEVD', -INFO ) 00264 RETURN 00265 ELSE IF( LQUERY ) THEN 00266 RETURN 00267 END IF 00268 * 00269 * Quick return if possible 00270 * 00271 IF( N.EQ.0 ) 00272 $ RETURN 00273 * 00274 IF( N.EQ.1 ) THEN 00275 W( 1 ) = AP( 1 ) 00276 IF( WANTZ ) 00277 $ Z( 1, 1 ) = ONE 00278 RETURN 00279 END IF 00280 * 00281 * Get machine constants. 00282 * 00283 SAFMIN = DLAMCH( 'Safe minimum' ) 00284 EPS = DLAMCH( 'Precision' ) 00285 SMLNUM = SAFMIN / EPS 00286 BIGNUM = ONE / SMLNUM 00287 RMIN = SQRT( SMLNUM ) 00288 RMAX = SQRT( BIGNUM ) 00289 * 00290 * Scale matrix to allowable range, if necessary. 00291 * 00292 ANRM = DLANSP( 'M', UPLO, N, AP, WORK ) 00293 ISCALE = 0 00294 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN 00295 ISCALE = 1 00296 SIGMA = RMIN / ANRM 00297 ELSE IF( ANRM.GT.RMAX ) THEN 00298 ISCALE = 1 00299 SIGMA = RMAX / ANRM 00300 END IF 00301 IF( ISCALE.EQ.1 ) THEN 00302 CALL DSCAL( ( N*( N+1 ) ) / 2, SIGMA, AP, 1 ) 00303 END IF 00304 * 00305 * Call DSPTRD to reduce symmetric packed matrix to tridiagonal form. 00306 * 00307 INDE = 1 00308 INDTAU = INDE + N 00309 CALL DSPTRD( UPLO, N, AP, W, WORK( INDE ), WORK( INDTAU ), IINFO ) 00310 * 00311 * For eigenvalues only, call DSTERF. For eigenvectors, first call 00312 * DSTEDC to generate the eigenvector matrix, WORK(INDWRK), of the 00313 * tridiagonal matrix, then call DOPMTR to multiply it by the 00314 * Householder transformations represented in AP. 00315 * 00316 IF( .NOT.WANTZ ) THEN 00317 CALL DSTERF( N, W, WORK( INDE ), INFO ) 00318 ELSE 00319 INDWRK = INDTAU + N 00320 LLWORK = LWORK - INDWRK + 1 00321 CALL DSTEDC( 'I', N, W, WORK( INDE ), Z, LDZ, WORK( INDWRK ), 00322 $ LLWORK, IWORK, LIWORK, INFO ) 00323 CALL DOPMTR( 'L', UPLO, 'N', N, N, AP, WORK( INDTAU ), Z, LDZ, 00324 $ WORK( INDWRK ), IINFO ) 00325 END IF 00326 * 00327 * If matrix was scaled, then rescale eigenvalues appropriately. 00328 * 00329 IF( ISCALE.EQ.1 ) 00330 $ CALL DSCAL( N, ONE / SIGMA, W, 1 ) 00331 * 00332 WORK( 1 ) = LWMIN 00333 IWORK( 1 ) = LIWMIN 00334 RETURN 00335 * 00336 * End of DSPEVD 00337 * 00338 END