LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE SSBEVX( JOBZ, RANGE, UPLO, N, KD, AB, LDAB, Q, LDQ, VL, 00002 $ VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, IWORK, 00003 $ IFAIL, INFO ) 00004 * 00005 * -- LAPACK driver routine (version 3.2) -- 00006 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00007 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00008 * November 2006 00009 * 00010 * .. Scalar Arguments .. 00011 CHARACTER JOBZ, RANGE, UPLO 00012 INTEGER IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N 00013 REAL ABSTOL, VL, VU 00014 * .. 00015 * .. Array Arguments .. 00016 INTEGER IFAIL( * ), IWORK( * ) 00017 REAL AB( LDAB, * ), Q( LDQ, * ), W( * ), WORK( * ), 00018 $ Z( LDZ, * ) 00019 * .. 00020 * 00021 * Purpose 00022 * ======= 00023 * 00024 * SSBEVX computes selected eigenvalues and, optionally, eigenvectors 00025 * of a real symmetric band matrix A. Eigenvalues and eigenvectors can 00026 * be selected by specifying either a range of values or a range of 00027 * indices for the desired eigenvalues. 00028 * 00029 * Arguments 00030 * ========= 00031 * 00032 * JOBZ (input) CHARACTER*1 00033 * = 'N': Compute eigenvalues only; 00034 * = 'V': Compute eigenvalues and eigenvectors. 00035 * 00036 * RANGE (input) CHARACTER*1 00037 * = 'A': all eigenvalues will be found; 00038 * = 'V': all eigenvalues in the half-open interval (VL,VU] 00039 * will be found; 00040 * = 'I': the IL-th through IU-th eigenvalues will be found. 00041 * 00042 * UPLO (input) CHARACTER*1 00043 * = 'U': Upper triangle of A is stored; 00044 * = 'L': Lower triangle of A is stored. 00045 * 00046 * N (input) INTEGER 00047 * The order of the matrix A. N >= 0. 00048 * 00049 * KD (input) INTEGER 00050 * The number of superdiagonals of the matrix A if UPLO = 'U', 00051 * or the number of subdiagonals if UPLO = 'L'. KD >= 0. 00052 * 00053 * AB (input/output) REAL array, dimension (LDAB, N) 00054 * On entry, the upper or lower triangle of the symmetric band 00055 * matrix A, stored in the first KD+1 rows of the array. The 00056 * j-th column of A is stored in the j-th column of the array AB 00057 * as follows: 00058 * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; 00059 * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). 00060 * 00061 * On exit, AB is overwritten by values generated during the 00062 * reduction to tridiagonal form. If UPLO = 'U', the first 00063 * superdiagonal and the diagonal of the tridiagonal matrix T 00064 * are returned in rows KD and KD+1 of AB, and if UPLO = 'L', 00065 * the diagonal and first subdiagonal of T are returned in the 00066 * first two rows of AB. 00067 * 00068 * LDAB (input) INTEGER 00069 * The leading dimension of the array AB. LDAB >= KD + 1. 00070 * 00071 * Q (output) REAL array, dimension (LDQ, N) 00072 * If JOBZ = 'V', the N-by-N orthogonal matrix used in the 00073 * reduction to tridiagonal form. 00074 * If JOBZ = 'N', the array Q is not referenced. 00075 * 00076 * LDQ (input) INTEGER 00077 * The leading dimension of the array Q. If JOBZ = 'V', then 00078 * LDQ >= max(1,N). 00079 * 00080 * VL (input) REAL 00081 * VU (input) REAL 00082 * If RANGE='V', the lower and upper bounds of the interval to 00083 * be searched for eigenvalues. VL < VU. 00084 * Not referenced if RANGE = 'A' or 'I'. 00085 * 00086 * IL (input) INTEGER 00087 * IU (input) INTEGER 00088 * If RANGE='I', the indices (in ascending order) of the 00089 * smallest and largest eigenvalues to be returned. 00090 * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. 00091 * Not referenced if RANGE = 'A' or 'V'. 00092 * 00093 * ABSTOL (input) REAL 00094 * The absolute error tolerance for the eigenvalues. 00095 * An approximate eigenvalue is accepted as converged 00096 * when it is determined to lie in an interval [a,b] 00097 * of width less than or equal to 00098 * 00099 * ABSTOL + EPS * max( |a|,|b| ) , 00100 * 00101 * where EPS is the machine precision. If ABSTOL is less than 00102 * or equal to zero, then EPS*|T| will be used in its place, 00103 * where |T| is the 1-norm of the tridiagonal matrix obtained 00104 * by reducing AB to tridiagonal form. 00105 * 00106 * Eigenvalues will be computed most accurately when ABSTOL is 00107 * set to twice the underflow threshold 2*SLAMCH('S'), not zero. 00108 * If this routine returns with INFO>0, indicating that some 00109 * eigenvectors did not converge, try setting ABSTOL to 00110 * 2*SLAMCH('S'). 00111 * 00112 * See "Computing Small Singular Values of Bidiagonal Matrices 00113 * with Guaranteed High Relative Accuracy," by Demmel and 00114 * Kahan, LAPACK Working Note #3. 00115 * 00116 * M (output) INTEGER 00117 * The total number of eigenvalues found. 0 <= M <= N. 00118 * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1. 00119 * 00120 * W (output) REAL array, dimension (N) 00121 * The first M elements contain the selected eigenvalues in 00122 * ascending order. 00123 * 00124 * Z (output) REAL array, dimension (LDZ, max(1,M)) 00125 * If JOBZ = 'V', then if INFO = 0, the first M columns of Z 00126 * contain the orthonormal eigenvectors of the matrix A 00127 * corresponding to the selected eigenvalues, with the i-th 00128 * column of Z holding the eigenvector associated with W(i). 00129 * If an eigenvector fails to converge, then that column of Z 00130 * contains the latest approximation to the eigenvector, and the 00131 * index of the eigenvector is returned in IFAIL. 00132 * If JOBZ = 'N', then Z is not referenced. 00133 * Note: the user must ensure that at least max(1,M) columns are 00134 * supplied in the array Z; if RANGE = 'V', the exact value of M 00135 * is not known in advance and an upper bound must be used. 00136 * 00137 * LDZ (input) INTEGER 00138 * The leading dimension of the array Z. LDZ >= 1, and if 00139 * JOBZ = 'V', LDZ >= max(1,N). 00140 * 00141 * WORK (workspace) REAL array, dimension (7*N) 00142 * 00143 * IWORK (workspace) INTEGER array, dimension (5*N) 00144 * 00145 * IFAIL (output) INTEGER array, dimension (N) 00146 * If JOBZ = 'V', then if INFO = 0, the first M elements of 00147 * IFAIL are zero. If INFO > 0, then IFAIL contains the 00148 * indices of the eigenvectors that failed to converge. 00149 * If JOBZ = 'N', then IFAIL is not referenced. 00150 * 00151 * INFO (output) INTEGER 00152 * = 0: successful exit. 00153 * < 0: if INFO = -i, the i-th argument had an illegal value. 00154 * > 0: if INFO = i, then i eigenvectors failed to converge. 00155 * Their indices are stored in array IFAIL. 00156 * 00157 * ===================================================================== 00158 * 00159 * .. Parameters .. 00160 REAL ZERO, ONE 00161 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 ) 00162 * .. 00163 * .. Local Scalars .. 00164 LOGICAL ALLEIG, INDEIG, LOWER, TEST, VALEIG, WANTZ 00165 CHARACTER ORDER 00166 INTEGER I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL, 00167 $ INDISP, INDIWO, INDWRK, ISCALE, ITMP1, J, JJ, 00168 $ NSPLIT 00169 REAL ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, 00170 $ SIGMA, SMLNUM, TMP1, VLL, VUU 00171 * .. 00172 * .. External Functions .. 00173 LOGICAL LSAME 00174 REAL SLAMCH, SLANSB 00175 EXTERNAL LSAME, SLAMCH, SLANSB 00176 * .. 00177 * .. External Subroutines .. 00178 EXTERNAL SCOPY, SGEMV, SLACPY, SLASCL, SSBTRD, SSCAL, 00179 $ SSTEBZ, SSTEIN, SSTEQR, SSTERF, SSWAP, XERBLA 00180 * .. 00181 * .. Intrinsic Functions .. 00182 INTRINSIC MAX, MIN, SQRT 00183 * .. 00184 * .. Executable Statements .. 00185 * 00186 * Test the input parameters. 00187 * 00188 WANTZ = LSAME( JOBZ, 'V' ) 00189 ALLEIG = LSAME( RANGE, 'A' ) 00190 VALEIG = LSAME( RANGE, 'V' ) 00191 INDEIG = LSAME( RANGE, 'I' ) 00192 LOWER = LSAME( UPLO, 'L' ) 00193 * 00194 INFO = 0 00195 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00196 INFO = -1 00197 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN 00198 INFO = -2 00199 ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN 00200 INFO = -3 00201 ELSE IF( N.LT.0 ) THEN 00202 INFO = -4 00203 ELSE IF( KD.LT.0 ) THEN 00204 INFO = -5 00205 ELSE IF( LDAB.LT.KD+1 ) THEN 00206 INFO = -7 00207 ELSE IF( WANTZ .AND. LDQ.LT.MAX( 1, N ) ) THEN 00208 INFO = -9 00209 ELSE 00210 IF( VALEIG ) THEN 00211 IF( N.GT.0 .AND. VU.LE.VL ) 00212 $ INFO = -11 00213 ELSE IF( INDEIG ) THEN 00214 IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN 00215 INFO = -12 00216 ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN 00217 INFO = -13 00218 END IF 00219 END IF 00220 END IF 00221 IF( INFO.EQ.0 ) THEN 00222 IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) 00223 $ INFO = -18 00224 END IF 00225 * 00226 IF( INFO.NE.0 ) THEN 00227 CALL XERBLA( 'SSBEVX', -INFO ) 00228 RETURN 00229 END IF 00230 * 00231 * Quick return if possible 00232 * 00233 M = 0 00234 IF( N.EQ.0 ) 00235 $ RETURN 00236 * 00237 IF( N.EQ.1 ) THEN 00238 M = 1 00239 IF( LOWER ) THEN 00240 TMP1 = AB( 1, 1 ) 00241 ELSE 00242 TMP1 = AB( KD+1, 1 ) 00243 END IF 00244 IF( VALEIG ) THEN 00245 IF( .NOT.( VL.LT.TMP1 .AND. VU.GE.TMP1 ) ) 00246 $ M = 0 00247 END IF 00248 IF( M.EQ.1 ) THEN 00249 W( 1 ) = TMP1 00250 IF( WANTZ ) 00251 $ Z( 1, 1 ) = ONE 00252 END IF 00253 RETURN 00254 END IF 00255 * 00256 * Get machine constants. 00257 * 00258 SAFMIN = SLAMCH( 'Safe minimum' ) 00259 EPS = SLAMCH( 'Precision' ) 00260 SMLNUM = SAFMIN / EPS 00261 BIGNUM = ONE / SMLNUM 00262 RMIN = SQRT( SMLNUM ) 00263 RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) ) 00264 * 00265 * Scale matrix to allowable range, if necessary. 00266 * 00267 ISCALE = 0 00268 ABSTLL = ABSTOL 00269 IF ( VALEIG ) THEN 00270 VLL = VL 00271 VUU = VU 00272 ELSE 00273 VLL = ZERO 00274 VUU = ZERO 00275 ENDIF 00276 ANRM = SLANSB( 'M', UPLO, N, KD, AB, LDAB, WORK ) 00277 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN 00278 ISCALE = 1 00279 SIGMA = RMIN / ANRM 00280 ELSE IF( ANRM.GT.RMAX ) THEN 00281 ISCALE = 1 00282 SIGMA = RMAX / ANRM 00283 END IF 00284 IF( ISCALE.EQ.1 ) THEN 00285 IF( LOWER ) THEN 00286 CALL SLASCL( 'B', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO ) 00287 ELSE 00288 CALL SLASCL( 'Q', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO ) 00289 END IF 00290 IF( ABSTOL.GT.0 ) 00291 $ ABSTLL = ABSTOL*SIGMA 00292 IF( VALEIG ) THEN 00293 VLL = VL*SIGMA 00294 VUU = VU*SIGMA 00295 END IF 00296 END IF 00297 * 00298 * Call SSBTRD to reduce symmetric band matrix to tridiagonal form. 00299 * 00300 INDD = 1 00301 INDE = INDD + N 00302 INDWRK = INDE + N 00303 CALL SSBTRD( JOBZ, UPLO, N, KD, AB, LDAB, WORK( INDD ), 00304 $ WORK( INDE ), Q, LDQ, WORK( INDWRK ), IINFO ) 00305 * 00306 * If all eigenvalues are desired and ABSTOL is less than or equal 00307 * to zero, then call SSTERF or SSTEQR. If this fails for some 00308 * eigenvalue, then try SSTEBZ. 00309 * 00310 TEST = .FALSE. 00311 IF (INDEIG) THEN 00312 IF (IL.EQ.1 .AND. IU.EQ.N) THEN 00313 TEST = .TRUE. 00314 END IF 00315 END IF 00316 IF ((ALLEIG .OR. TEST) .AND. (ABSTOL.LE.ZERO)) THEN 00317 CALL SCOPY( N, WORK( INDD ), 1, W, 1 ) 00318 INDEE = INDWRK + 2*N 00319 IF( .NOT.WANTZ ) THEN 00320 CALL SCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 ) 00321 CALL SSTERF( N, W, WORK( INDEE ), INFO ) 00322 ELSE 00323 CALL SLACPY( 'A', N, N, Q, LDQ, Z, LDZ ) 00324 CALL SCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 ) 00325 CALL SSTEQR( JOBZ, N, W, WORK( INDEE ), Z, LDZ, 00326 $ WORK( INDWRK ), INFO ) 00327 IF( INFO.EQ.0 ) THEN 00328 DO 10 I = 1, N 00329 IFAIL( I ) = 0 00330 10 CONTINUE 00331 END IF 00332 END IF 00333 IF( INFO.EQ.0 ) THEN 00334 M = N 00335 GO TO 30 00336 END IF 00337 INFO = 0 00338 END IF 00339 * 00340 * Otherwise, call SSTEBZ and, if eigenvectors are desired, SSTEIN. 00341 * 00342 IF( WANTZ ) THEN 00343 ORDER = 'B' 00344 ELSE 00345 ORDER = 'E' 00346 END IF 00347 INDIBL = 1 00348 INDISP = INDIBL + N 00349 INDIWO = INDISP + N 00350 CALL SSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL, 00351 $ WORK( INDD ), WORK( INDE ), M, NSPLIT, W, 00352 $ IWORK( INDIBL ), IWORK( INDISP ), WORK( INDWRK ), 00353 $ IWORK( INDIWO ), INFO ) 00354 * 00355 IF( WANTZ ) THEN 00356 CALL SSTEIN( N, WORK( INDD ), WORK( INDE ), M, W, 00357 $ IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ, 00358 $ WORK( INDWRK ), IWORK( INDIWO ), IFAIL, INFO ) 00359 * 00360 * Apply orthogonal matrix used in reduction to tridiagonal 00361 * form to eigenvectors returned by SSTEIN. 00362 * 00363 DO 20 J = 1, M 00364 CALL SCOPY( N, Z( 1, J ), 1, WORK( 1 ), 1 ) 00365 CALL SGEMV( 'N', N, N, ONE, Q, LDQ, WORK, 1, ZERO, 00366 $ Z( 1, J ), 1 ) 00367 20 CONTINUE 00368 END IF 00369 * 00370 * If matrix was scaled, then rescale eigenvalues appropriately. 00371 * 00372 30 CONTINUE 00373 IF( ISCALE.EQ.1 ) THEN 00374 IF( INFO.EQ.0 ) THEN 00375 IMAX = M 00376 ELSE 00377 IMAX = INFO - 1 00378 END IF 00379 CALL SSCAL( IMAX, ONE / SIGMA, W, 1 ) 00380 END IF 00381 * 00382 * If eigenvalues are not in order, then sort them, along with 00383 * eigenvectors. 00384 * 00385 IF( WANTZ ) THEN 00386 DO 50 J = 1, M - 1 00387 I = 0 00388 TMP1 = W( J ) 00389 DO 40 JJ = J + 1, M 00390 IF( W( JJ ).LT.TMP1 ) THEN 00391 I = JJ 00392 TMP1 = W( JJ ) 00393 END IF 00394 40 CONTINUE 00395 * 00396 IF( I.NE.0 ) THEN 00397 ITMP1 = IWORK( INDIBL+I-1 ) 00398 W( I ) = W( J ) 00399 IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 ) 00400 W( J ) = TMP1 00401 IWORK( INDIBL+J-1 ) = ITMP1 00402 CALL SSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 ) 00403 IF( INFO.NE.0 ) THEN 00404 ITMP1 = IFAIL( I ) 00405 IFAIL( I ) = IFAIL( J ) 00406 IFAIL( J ) = ITMP1 00407 END IF 00408 END IF 00409 50 CONTINUE 00410 END IF 00411 * 00412 RETURN 00413 * 00414 * End of SSBEVX 00415 * 00416 END