1 *> \brief <b> SSBEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b>
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SSBEVX + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssbevx.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssbevx.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssbevx.f">
21 * SUBROUTINE SSBEVX( JOBZ, RANGE, UPLO, N, KD, AB, LDAB, Q, LDQ, VL,
22 * VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, IWORK,
25 * .. Scalar Arguments ..
26 * CHARACTER JOBZ, RANGE, UPLO
27 * INTEGER IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N
30 * .. Array Arguments ..
31 * INTEGER IFAIL( * ), IWORK( * )
32 * REAL AB( LDAB, * ), Q( LDQ, * ), W( * ), WORK( * ),
42 *> SSBEVX computes selected eigenvalues and, optionally, eigenvectors
43 *> of a real symmetric band matrix A. Eigenvalues and eigenvectors can
44 *> be selected by specifying either a range of values or a range of
45 *> indices for the desired eigenvalues.
53 *> JOBZ is CHARACTER*1
54 *> = 'N': Compute eigenvalues only;
55 *> = 'V': Compute eigenvalues and eigenvectors.
60 *> RANGE is CHARACTER*1
61 *> = 'A': all eigenvalues will be found;
62 *> = 'V': all eigenvalues in the half-open interval (VL,VU]
64 *> = 'I': the IL-th through IU-th eigenvalues will be found.
69 *> UPLO is CHARACTER*1
70 *> = 'U': Upper triangle of A is stored;
71 *> = 'L': Lower triangle of A is stored.
77 *> The order of the matrix A. N >= 0.
83 *> The number of superdiagonals of the matrix A if UPLO = 'U',
84 *> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
89 *> AB is REAL array, dimension (LDAB, N)
90 *> On entry, the upper or lower triangle of the symmetric band
91 *> matrix A, stored in the first KD+1 rows of the array. The
92 *> j-th column of A is stored in the j-th column of the array AB
94 *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
95 *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
97 *> On exit, AB is overwritten by values generated during the
98 *> reduction to tridiagonal form. If UPLO = 'U', the first
99 *> superdiagonal and the diagonal of the tridiagonal matrix T
100 *> are returned in rows KD and KD+1 of AB, and if UPLO = 'L',
101 *> the diagonal and first subdiagonal of T are returned in the
102 *> first two rows of AB.
108 *> The leading dimension of the array AB. LDAB >= KD + 1.
113 *> Q is REAL array, dimension (LDQ, N)
114 *> If JOBZ = 'V', the N-by-N orthogonal matrix used in the
115 *> reduction to tridiagonal form.
116 *> If JOBZ = 'N', the array Q is not referenced.
122 *> The leading dimension of the array Q. If JOBZ = 'V', then
129 *> If RANGE='V', the lower bound of the interval to
130 *> be searched for eigenvalues. VL < VU.
131 *> Not referenced if RANGE = 'A' or 'I'.
137 *> If RANGE='V', the upper bound of the interval to
138 *> be searched for eigenvalues. VL < VU.
139 *> Not referenced if RANGE = 'A' or 'I'.
145 *> If RANGE='I', the index of the
146 *> smallest eigenvalue to be returned.
147 *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
148 *> Not referenced if RANGE = 'A' or 'V'.
154 *> If RANGE='I', the index of the
155 *> largest eigenvalue to be returned.
156 *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
157 *> Not referenced if RANGE = 'A' or 'V'.
163 *> The absolute error tolerance for the eigenvalues.
164 *> An approximate eigenvalue is accepted as converged
165 *> when it is determined to lie in an interval [a,b]
166 *> of width less than or equal to
168 *> ABSTOL + EPS * max( |a|,|b| ) ,
170 *> where EPS is the machine precision. If ABSTOL is less than
171 *> or equal to zero, then EPS*|T| will be used in its place,
172 *> where |T| is the 1-norm of the tridiagonal matrix obtained
173 *> by reducing AB to tridiagonal form.
175 *> Eigenvalues will be computed most accurately when ABSTOL is
176 *> set to twice the underflow threshold 2*SLAMCH('S'), not zero.
177 *> If this routine returns with INFO>0, indicating that some
178 *> eigenvectors did not converge, try setting ABSTOL to
181 *> See "Computing Small Singular Values of Bidiagonal Matrices
182 *> with Guaranteed High Relative Accuracy," by Demmel and
183 *> Kahan, LAPACK Working Note #3.
189 *> The total number of eigenvalues found. 0 <= M <= N.
190 *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
195 *> W is REAL array, dimension (N)
196 *> The first M elements contain the selected eigenvalues in
202 *> Z is REAL array, dimension (LDZ, max(1,M))
203 *> If JOBZ = 'V', then if INFO = 0, the first M columns of Z
204 *> contain the orthonormal eigenvectors of the matrix A
205 *> corresponding to the selected eigenvalues, with the i-th
206 *> column of Z holding the eigenvector associated with W(i).
207 *> If an eigenvector fails to converge, then that column of Z
208 *> contains the latest approximation to the eigenvector, and the
209 *> index of the eigenvector is returned in IFAIL.
210 *> If JOBZ = 'N', then Z is not referenced.
211 *> Note: the user must ensure that at least max(1,M) columns are
212 *> supplied in the array Z; if RANGE = 'V', the exact value of M
213 *> is not known in advance and an upper bound must be used.
219 *> The leading dimension of the array Z. LDZ >= 1, and if
220 *> JOBZ = 'V', LDZ >= max(1,N).
225 *> WORK is REAL array, dimension (7*N)
230 *> IWORK is INTEGER array, dimension (5*N)
235 *> IFAIL is INTEGER array, dimension (N)
236 *> If JOBZ = 'V', then if INFO = 0, the first M elements of
237 *> IFAIL are zero. If INFO > 0, then IFAIL contains the
238 *> indices of the eigenvectors that failed to converge.
239 *> If JOBZ = 'N', then IFAIL is not referenced.
245 *> = 0: successful exit.
246 *> < 0: if INFO = -i, the i-th argument had an illegal value.
247 *> > 0: if INFO = i, then i eigenvectors failed to converge.
248 *> Their indices are stored in array IFAIL.
254 *> \author Univ. of Tennessee
255 *> \author Univ. of California Berkeley
256 *> \author Univ. of Colorado Denver
261 *> \ingroup realOTHEReigen
263 * =====================================================================
264 SUBROUTINE SSBEVX( JOBZ, RANGE, UPLO, N, KD, AB, LDAB, Q, LDQ, VL,
265 $ VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, IWORK,
268 * -- LAPACK driver routine (version 3.6.1) --
269 * -- LAPACK is a software package provided by Univ. of Tennessee, --
270 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
273 * .. Scalar Arguments ..
274 CHARACTER JOBZ, RANGE, UPLO
275 INTEGER IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N
278 * .. Array Arguments ..
279 INTEGER IFAIL( * ), IWORK( * )
280 REAL AB( LDAB, * ), Q( LDQ, * ), W( * ), WORK( * ),
284 * =====================================================================
288 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
290 * .. Local Scalars ..
291 LOGICAL ALLEIG, INDEIG, LOWER, TEST, VALEIG, WANTZ
293 INTEGER I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL,
294 $ INDISP, INDIWO, INDWRK, ISCALE, ITMP1, J, JJ,
296 REAL ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
297 $ SIGMA, SMLNUM, TMP1, VLL, VUU
299 * .. External Functions ..
302 EXTERNAL LSAME, SLAMCH, SLANSB
304 * .. External Subroutines ..
305 EXTERNAL SCOPY, SGEMV, SLACPY, SLASCL, SSBTRD, SSCAL,
306 $ SSTEBZ, SSTEIN, SSTEQR, SSTERF, SSWAP, XERBLA
308 * .. Intrinsic Functions ..
309 INTRINSIC MAX, MIN, SQRT
311 * .. Executable Statements ..
313 * Test the input parameters.
315 WANTZ = LSAME( JOBZ, 'V' )
316 ALLEIG = LSAME( RANGE, 'A' )
317 VALEIG = LSAME( RANGE, 'V' )
318 INDEIG = LSAME( RANGE, 'I' )
319 LOWER = LSAME( UPLO, 'L' )
322 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
324 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
326 ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN
328 ELSE IF( N.LT.0 ) THEN
330 ELSE IF( KD.LT.0 ) THEN
332 ELSE IF( LDAB.LT.KD+1 ) THEN
334 ELSE IF( WANTZ .AND. LDQ.LT.MAX( 1, N ) ) THEN
338 IF( N.GT.0 .AND. VU.LE.VL )
340 ELSE IF( INDEIG ) THEN
341 IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
343 ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
349 IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) )
354 CALL XERBLA( 'SSBEVX', -INFO )
358 * Quick return if possible
372 IF( .NOT.( VL.LT.TMP1 .AND. VU.GE.TMP1 ) )
383 * Get machine constants.
385 SAFMIN = SLAMCH( 'Safe minimum' )
386 EPS = SLAMCH( 'Precision' )
387 SMLNUM = SAFMIN / EPS
388 BIGNUM = ONE / SMLNUM
389 RMIN = SQRT( SMLNUM )
390 RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
392 * Scale matrix to allowable range, if necessary.
403 ANRM = SLANSB( 'M', UPLO, N, KD, AB, LDAB, WORK )
404 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
407 ELSE IF( ANRM.GT.RMAX ) THEN
411 IF( ISCALE.EQ.1 ) THEN
413 CALL SLASCL( 'B', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO )
415 CALL SLASCL( 'Q', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO )
418 $ ABSTLL = ABSTOL*SIGMA
425 * Call SSBTRD to reduce symmetric band matrix to tridiagonal form.
430 CALL SSBTRD( JOBZ, UPLO, N, KD, AB, LDAB, WORK( INDD ),
431 $ WORK( INDE ), Q, LDQ, WORK( INDWRK ), IINFO )
433 * If all eigenvalues are desired and ABSTOL is less than or equal
434 * to zero, then call SSTERF or SSTEQR. If this fails for some
435 * eigenvalue, then try SSTEBZ.
439 IF (IL.EQ.1 .AND. IU.EQ.N) THEN
443 IF ((ALLEIG .OR. TEST) .AND. (ABSTOL.LE.ZERO)) THEN
444 CALL SCOPY( N, WORK( INDD ), 1, W, 1 )
446 IF( .NOT.WANTZ ) THEN
447 CALL SCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
448 CALL SSTERF( N, W, WORK( INDEE ), INFO )
450 CALL SLACPY( 'A', N, N, Q, LDQ, Z, LDZ )
451 CALL SCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
452 CALL SSTEQR( JOBZ, N, W, WORK( INDEE ), Z, LDZ,
453 $ WORK( INDWRK ), INFO )
467 * Otherwise, call SSTEBZ and, if eigenvectors are desired, SSTEIN.
477 CALL SSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL,
478 $ WORK( INDD ), WORK( INDE ), M, NSPLIT, W,
479 $ IWORK( INDIBL ), IWORK( INDISP ), WORK( INDWRK ),
480 $ IWORK( INDIWO ), INFO )
483 CALL SSTEIN( N, WORK( INDD ), WORK( INDE ), M, W,
484 $ IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
485 $ WORK( INDWRK ), IWORK( INDIWO ), IFAIL, INFO )
487 * Apply orthogonal matrix used in reduction to tridiagonal
488 * form to eigenvectors returned by SSTEIN.
491 CALL SCOPY( N, Z( 1, J ), 1, WORK( 1 ), 1 )
492 CALL SGEMV( 'N', N, N, ONE, Q, LDQ, WORK, 1, ZERO,
497 * If matrix was scaled, then rescale eigenvalues appropriately.
500 IF( ISCALE.EQ.1 ) THEN
506 CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
509 * If eigenvalues are not in order, then sort them, along with
517 IF( W( JJ ).LT.TMP1 ) THEN
524 ITMP1 = IWORK( INDIBL+I-1 )
526 IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
528 IWORK( INDIBL+J-1 ) = ITMP1
529 CALL SSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
532 IFAIL( I ) = IFAIL( J )