LAPACK 3.3.0
|
00001 SUBROUTINE DSPEVD( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, LWORK, 00002 $ IWORK, LIWORK, INFO ) 00003 * 00004 * -- LAPACK driver routine (version 3.2) -- 00005 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00006 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00007 * November 2006 00008 * 00009 * .. Scalar Arguments .. 00010 CHARACTER JOBZ, UPLO 00011 INTEGER INFO, LDZ, LIWORK, LWORK, N 00012 * .. 00013 * .. Array Arguments .. 00014 INTEGER IWORK( * ) 00015 DOUBLE PRECISION AP( * ), W( * ), WORK( * ), Z( LDZ, * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * DSPEVD computes all the eigenvalues and, optionally, eigenvectors 00022 * of a real symmetric matrix A in packed storage. If eigenvectors are 00023 * desired, it uses a divide and conquer algorithm. 00024 * 00025 * The divide and conquer algorithm makes very mild assumptions about 00026 * floating point arithmetic. It will work on machines with a guard 00027 * digit in add/subtract, or on those binary machines without guard 00028 * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or 00029 * Cray-2. It could conceivably fail on hexadecimal or decimal machines 00030 * without guard digits, but we know of none. 00031 * 00032 * Arguments 00033 * ========= 00034 * 00035 * JOBZ (input) CHARACTER*1 00036 * = 'N': Compute eigenvalues only; 00037 * = 'V': Compute eigenvalues and eigenvectors. 00038 * 00039 * UPLO (input) CHARACTER*1 00040 * = 'U': Upper triangle of A is stored; 00041 * = 'L': Lower triangle of A is stored. 00042 * 00043 * N (input) INTEGER 00044 * The order of the matrix A. N >= 0. 00045 * 00046 * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) 00047 * On entry, the upper or lower triangle of the symmetric matrix 00048 * A, packed columnwise in a linear array. The j-th column of A 00049 * is stored in the array AP as follows: 00050 * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00051 * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. 00052 * 00053 * On exit, AP is overwritten by values generated during the 00054 * reduction to tridiagonal form. If UPLO = 'U', the diagonal 00055 * and first superdiagonal of the tridiagonal matrix T overwrite 00056 * the corresponding elements of A, and if UPLO = 'L', the 00057 * diagonal and first subdiagonal of T overwrite the 00058 * corresponding elements of A. 00059 * 00060 * W (output) DOUBLE PRECISION array, dimension (N) 00061 * If INFO = 0, the eigenvalues in ascending order. 00062 * 00063 * Z (output) DOUBLE PRECISION array, dimension (LDZ, N) 00064 * If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal 00065 * eigenvectors of the matrix A, with the i-th column of Z 00066 * holding the eigenvector associated with W(i). 00067 * If JOBZ = 'N', then Z is not referenced. 00068 * 00069 * LDZ (input) INTEGER 00070 * The leading dimension of the array Z. LDZ >= 1, and if 00071 * JOBZ = 'V', LDZ >= max(1,N). 00072 * 00073 * WORK (workspace/output) DOUBLE PRECISION array, 00074 * dimension (LWORK) 00075 * On exit, if INFO = 0, WORK(1) returns the required LWORK. 00076 * 00077 * LWORK (input) INTEGER 00078 * The dimension of the array WORK. 00079 * If N <= 1, LWORK must be at least 1. 00080 * If JOBZ = 'N' and N > 1, LWORK must be at least 2*N. 00081 * If JOBZ = 'V' and N > 1, LWORK must be at least 00082 * 1 + 6*N + N**2. 00083 * 00084 * If LWORK = -1, then a workspace query is assumed; the routine 00085 * only calculates the required sizes of the WORK and IWORK 00086 * arrays, returns these values as the first entries of the WORK 00087 * and IWORK arrays, and no error message related to LWORK or 00088 * LIWORK is issued by XERBLA. 00089 * 00090 * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK)) 00091 * On exit, if INFO = 0, IWORK(1) returns the required LIWORK. 00092 * 00093 * LIWORK (input) INTEGER 00094 * The dimension of the array IWORK. 00095 * If JOBZ = 'N' or N <= 1, LIWORK must be at least 1. 00096 * If JOBZ = 'V' and N > 1, LIWORK must be at least 3 + 5*N. 00097 * 00098 * If LIWORK = -1, then a workspace query is assumed; the 00099 * routine only calculates the required sizes of the WORK and 00100 * IWORK arrays, returns these values as the first entries of 00101 * the WORK and IWORK arrays, and no error message related to 00102 * LWORK or LIWORK is issued by XERBLA. 00103 * 00104 * INFO (output) INTEGER 00105 * = 0: successful exit 00106 * < 0: if INFO = -i, the i-th argument had an illegal value. 00107 * > 0: if INFO = i, the algorithm failed to converge; i 00108 * off-diagonal elements of an intermediate tridiagonal 00109 * form did not converge to zero. 00110 * 00111 * ===================================================================== 00112 * 00113 * .. Parameters .. 00114 DOUBLE PRECISION ZERO, ONE 00115 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) 00116 * .. 00117 * .. Local Scalars .. 00118 LOGICAL LQUERY, WANTZ 00119 INTEGER IINFO, INDE, INDTAU, INDWRK, ISCALE, LIWMIN, 00120 $ LLWORK, LWMIN 00121 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, 00122 $ SMLNUM 00123 * .. 00124 * .. External Functions .. 00125 LOGICAL LSAME 00126 DOUBLE PRECISION DLAMCH, DLANSP 00127 EXTERNAL LSAME, DLAMCH, DLANSP 00128 * .. 00129 * .. External Subroutines .. 00130 EXTERNAL DOPMTR, DSCAL, DSPTRD, DSTEDC, DSTERF, XERBLA 00131 * .. 00132 * .. Intrinsic Functions .. 00133 INTRINSIC SQRT 00134 * .. 00135 * .. Executable Statements .. 00136 * 00137 * Test the input parameters. 00138 * 00139 WANTZ = LSAME( JOBZ, 'V' ) 00140 LQUERY = ( LWORK.EQ.-1 .OR. LIWORK.EQ.-1 ) 00141 * 00142 INFO = 0 00143 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00144 INFO = -1 00145 ELSE IF( .NOT.( LSAME( UPLO, 'U' ) .OR. LSAME( UPLO, 'L' ) ) ) 00146 $ THEN 00147 INFO = -2 00148 ELSE IF( N.LT.0 ) THEN 00149 INFO = -3 00150 ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN 00151 INFO = -7 00152 END IF 00153 * 00154 IF( INFO.EQ.0 ) THEN 00155 IF( N.LE.1 ) THEN 00156 LIWMIN = 1 00157 LWMIN = 1 00158 ELSE 00159 IF( WANTZ ) THEN 00160 LIWMIN = 3 + 5*N 00161 LWMIN = 1 + 6*N + N**2 00162 ELSE 00163 LIWMIN = 1 00164 LWMIN = 2*N 00165 END IF 00166 END IF 00167 IWORK( 1 ) = LIWMIN 00168 WORK( 1 ) = LWMIN 00169 * 00170 IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN 00171 INFO = -9 00172 ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN 00173 INFO = -11 00174 END IF 00175 END IF 00176 * 00177 IF( INFO.NE.0 ) THEN 00178 CALL XERBLA( 'DSPEVD', -INFO ) 00179 RETURN 00180 ELSE IF( LQUERY ) THEN 00181 RETURN 00182 END IF 00183 * 00184 * Quick return if possible 00185 * 00186 IF( N.EQ.0 ) 00187 $ RETURN 00188 * 00189 IF( N.EQ.1 ) THEN 00190 W( 1 ) = AP( 1 ) 00191 IF( WANTZ ) 00192 $ Z( 1, 1 ) = ONE 00193 RETURN 00194 END IF 00195 * 00196 * Get machine constants. 00197 * 00198 SAFMIN = DLAMCH( 'Safe minimum' ) 00199 EPS = DLAMCH( 'Precision' ) 00200 SMLNUM = SAFMIN / EPS 00201 BIGNUM = ONE / SMLNUM 00202 RMIN = SQRT( SMLNUM ) 00203 RMAX = SQRT( BIGNUM ) 00204 * 00205 * Scale matrix to allowable range, if necessary. 00206 * 00207 ANRM = DLANSP( 'M', UPLO, N, AP, WORK ) 00208 ISCALE = 0 00209 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN 00210 ISCALE = 1 00211 SIGMA = RMIN / ANRM 00212 ELSE IF( ANRM.GT.RMAX ) THEN 00213 ISCALE = 1 00214 SIGMA = RMAX / ANRM 00215 END IF 00216 IF( ISCALE.EQ.1 ) THEN 00217 CALL DSCAL( ( N*( N+1 ) ) / 2, SIGMA, AP, 1 ) 00218 END IF 00219 * 00220 * Call DSPTRD to reduce symmetric packed matrix to tridiagonal form. 00221 * 00222 INDE = 1 00223 INDTAU = INDE + N 00224 CALL DSPTRD( UPLO, N, AP, W, WORK( INDE ), WORK( INDTAU ), IINFO ) 00225 * 00226 * For eigenvalues only, call DSTERF. For eigenvectors, first call 00227 * DSTEDC to generate the eigenvector matrix, WORK(INDWRK), of the 00228 * tridiagonal matrix, then call DOPMTR to multiply it by the 00229 * Householder transformations represented in AP. 00230 * 00231 IF( .NOT.WANTZ ) THEN 00232 CALL DSTERF( N, W, WORK( INDE ), INFO ) 00233 ELSE 00234 INDWRK = INDTAU + N 00235 LLWORK = LWORK - INDWRK + 1 00236 CALL DSTEDC( 'I', N, W, WORK( INDE ), Z, LDZ, WORK( INDWRK ), 00237 $ LLWORK, IWORK, LIWORK, INFO ) 00238 CALL DOPMTR( 'L', UPLO, 'N', N, N, AP, WORK( INDTAU ), Z, LDZ, 00239 $ WORK( INDWRK ), IINFO ) 00240 END IF 00241 * 00242 * If matrix was scaled, then rescale eigenvalues appropriately. 00243 * 00244 IF( ISCALE.EQ.1 ) 00245 $ CALL DSCAL( N, ONE / SIGMA, W, 1 ) 00246 * 00247 WORK( 1 ) = LWMIN 00248 IWORK( 1 ) = LIWMIN 00249 RETURN 00250 * 00251 * End of DSPEVD 00252 * 00253 END