LAPACK 3.11.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ sstevr()

subroutine sstevr ( character  JOBZ,
character  RANGE,
integer  N,
real, dimension( * )  D,
real, dimension( * )  E,
real  VL,
real  VU,
integer  IL,
integer  IU,
real  ABSTOL,
integer  M,
real, dimension( * )  W,
real, dimension( ldz, * )  Z,
integer  LDZ,
integer, dimension( * )  ISUPPZ,
real, dimension( * )  WORK,
integer  LWORK,
integer, dimension( * )  IWORK,
integer  LIWORK,
integer  INFO 
)

SSTEVR computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices

Download SSTEVR + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 SSTEVR computes selected eigenvalues and, optionally, eigenvectors
 of a real symmetric tridiagonal matrix T.  Eigenvalues and
 eigenvectors can be selected by specifying either a range of values
 or a range of indices for the desired eigenvalues.

 Whenever possible, SSTEVR calls SSTEMR to compute the
 eigenspectrum using Relatively Robust Representations.  SSTEMR
 computes eigenvalues by the dqds algorithm, while orthogonal
 eigenvectors are computed from various "good" L D L^T representations
 (also known as Relatively Robust Representations). Gram-Schmidt
 orthogonalization is avoided as far as possible. More specifically,
 the various steps of the algorithm are as follows. For the i-th
 unreduced block of T,
    (a) Compute T - sigma_i = L_i D_i L_i^T, such that L_i D_i L_i^T
         is a relatively robust representation,
    (b) Compute the eigenvalues, lambda_j, of L_i D_i L_i^T to high
        relative accuracy by the dqds algorithm,
    (c) If there is a cluster of close eigenvalues, "choose" sigma_i
        close to the cluster, and go to step (a),
    (d) Given the approximate eigenvalue lambda_j of L_i D_i L_i^T,
        compute the corresponding eigenvector by forming a
        rank-revealing twisted factorization.
 The desired accuracy of the output can be specified by the input
 parameter ABSTOL.

 For more details, see "A new O(n^2) algorithm for the symmetric
 tridiagonal eigenvalue/eigenvector problem", by Inderjit Dhillon,
 Computer Science Division Technical Report No. UCB//CSD-97-971,
 UC Berkeley, May 1997.


 Note 1 : SSTEVR calls SSTEMR when the full spectrum is requested
 on machines which conform to the ieee-754 floating point standard.
 SSTEVR calls SSTEBZ and SSTEIN on non-ieee machines and
 when partial spectrum requests are made.

 Normal execution of SSTEMR may create NaNs and infinities and
 hence may abort due to a floating point exception in environments
 which do not handle NaNs and infinities in the ieee standard default
 manner.
Parameters
[in]JOBZ
          JOBZ is CHARACTER*1
          = 'N':  Compute eigenvalues only;
          = 'V':  Compute eigenvalues and eigenvectors.
[in]RANGE
          RANGE is CHARACTER*1
          = 'A': all eigenvalues will be found.
          = 'V': all eigenvalues in the half-open interval (VL,VU]
                 will be found.
          = 'I': the IL-th through IU-th eigenvalues will be found.
          For RANGE = 'V' or 'I' and IU - IL < N - 1, SSTEBZ and
          SSTEIN are called
[in]N
          N is INTEGER
          The order of the matrix.  N >= 0.
[in,out]D
          D is REAL array, dimension (N)
          On entry, the n diagonal elements of the tridiagonal matrix
          A.
          On exit, D may be multiplied by a constant factor chosen
          to avoid over/underflow in computing the eigenvalues.
[in,out]E
          E is REAL array, dimension (max(1,N-1))
          On entry, the (n-1) subdiagonal elements of the tridiagonal
          matrix A in elements 1 to N-1 of E.
          On exit, E may be multiplied by a constant factor chosen
          to avoid over/underflow in computing the eigenvalues.
[in]VL
          VL is REAL
          If RANGE='V', the lower bound of the interval to
          be searched for eigenvalues. VL < VU.
          Not referenced if RANGE = 'A' or 'I'.
[in]VU
          VU is REAL
          If RANGE='V', the upper bound of the interval to
          be searched for eigenvalues. VL < VU.
          Not referenced if RANGE = 'A' or 'I'.
[in]IL
          IL is INTEGER
          If RANGE='I', the index of the
          smallest eigenvalue to be returned.
          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
          Not referenced if RANGE = 'A' or 'V'.
[in]IU
          IU is INTEGER
          If RANGE='I', the index of the
          largest eigenvalue to be returned.
          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
          Not referenced if RANGE = 'A' or 'V'.
[in]ABSTOL
          ABSTOL is REAL
          The absolute error tolerance for the eigenvalues.
          An approximate eigenvalue is accepted as converged
          when it is determined to lie in an interval [a,b]
          of width less than or equal to

                  ABSTOL + EPS *   max( |a|,|b| ) ,

          where EPS is the machine precision.  If ABSTOL is less than
          or equal to zero, then  EPS*|T|  will be used in its place,
          where |T| is the 1-norm of the tridiagonal matrix obtained
          by reducing A to tridiagonal form.

          See "Computing Small Singular Values of Bidiagonal Matrices
          with Guaranteed High Relative Accuracy," by Demmel and
          Kahan, LAPACK Working Note #3.

          If high relative accuracy is important, set ABSTOL to
          SLAMCH( 'Safe minimum' ).  Doing so will guarantee that
          eigenvalues are computed to high relative accuracy when
          possible in future releases.  The current code does not
          make any guarantees about high relative accuracy, but
          future releases will. See J. Barlow and J. Demmel,
          "Computing Accurate Eigensystems of Scaled Diagonally
          Dominant Matrices", LAPACK Working Note #7, for a discussion
          of which matrices define their eigenvalues to high relative
          accuracy.
[out]M
          M is INTEGER
          The total number of eigenvalues found.  0 <= M <= N.
          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
[out]W
          W is REAL array, dimension (N)
          The first M elements contain the selected eigenvalues in
          ascending order.
[out]Z
          Z is REAL array, dimension (LDZ, max(1,M) )
          If JOBZ = 'V', then if INFO = 0, the first M columns of Z
          contain the orthonormal eigenvectors of the matrix A
          corresponding to the selected eigenvalues, with the i-th
          column of Z holding the eigenvector associated with W(i).
          Note: the user must ensure that at least max(1,M) columns are
          supplied in the array Z; if RANGE = 'V', the exact value of M
          is not known in advance and an upper bound must be used.
[in]LDZ
          LDZ is INTEGER
          The leading dimension of the array Z.  LDZ >= 1, and if
          JOBZ = 'V', LDZ >= max(1,N).
[out]ISUPPZ
          ISUPPZ is INTEGER array, dimension ( 2*max(1,M) )
          The support of the eigenvectors in Z, i.e., the indices
          indicating the nonzero elements in Z. The i-th eigenvector
          is nonzero only in elements ISUPPZ( 2*i-1 ) through
          ISUPPZ( 2*i ).
          Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1
[out]WORK
          WORK is REAL array, dimension (MAX(1,LWORK))
          On exit, if INFO = 0, WORK(1) returns the optimal (and
          minimal) LWORK.
[in]LWORK
          LWORK is INTEGER
          The dimension of the array WORK.  LWORK >= 20*N.

          If LWORK = -1, then a workspace query is assumed; the routine
          only calculates the optimal sizes of the WORK and IWORK
          arrays, returns these values as the first entries of the WORK
          and IWORK arrays, and no error message related to LWORK or
          LIWORK is issued by XERBLA.
[out]IWORK
          IWORK is INTEGER array, dimension (MAX(1,LIWORK))
          On exit, if INFO = 0, IWORK(1) returns the optimal (and
          minimal) LIWORK.
[in]LIWORK
          LIWORK is INTEGER
          The dimension of the array IWORK.  LIWORK >= 10*N.

          If LIWORK = -1, then a workspace query is assumed; the
          routine only calculates the optimal sizes of the WORK and
          IWORK arrays, returns these values as the first entries of
          the WORK and IWORK arrays, and no error message related to
          LWORK or LIWORK is issued by XERBLA.
[out]INFO
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -i, the i-th argument had an illegal value
          > 0:  Internal error
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Contributors:
Inderjit Dhillon, IBM Almaden, USA
Osni Marques, LBNL/NERSC, USA
Ken Stanley, Computer Science Division, University of California at Berkeley, USA
Jason Riedy, Computer Science Division, University of California at Berkeley, USA

Definition at line 303 of file sstevr.f.

306*
307* -- LAPACK driver routine --
308* -- LAPACK is a software package provided by Univ. of Tennessee, --
309* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
310*
311* .. Scalar Arguments ..
312 CHARACTER JOBZ, RANGE
313 INTEGER IL, INFO, IU, LDZ, LIWORK, LWORK, M, N
314 REAL ABSTOL, VL, VU
315* ..
316* .. Array Arguments ..
317 INTEGER ISUPPZ( * ), IWORK( * )
318 REAL D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
319* ..
320*
321* =====================================================================
322*
323* .. Parameters ..
324 REAL ZERO, ONE, TWO
325 parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0 )
326* ..
327* .. Local Scalars ..
328 LOGICAL ALLEIG, INDEIG, TEST, LQUERY, VALEIG, WANTZ,
329 $ TRYRAC
330 CHARACTER ORDER
331 INTEGER I, IEEEOK, IMAX, INDIBL, INDIFL, INDISP,
332 $ INDIWO, ISCALE, J, JJ, LIWMIN, LWMIN, NSPLIT
333 REAL BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, SMLNUM,
334 $ TMP1, TNRM, VLL, VUU
335* ..
336* .. External Functions ..
337 LOGICAL LSAME
338 INTEGER ILAENV
339 REAL SLAMCH, SLANST
340 EXTERNAL lsame, ilaenv, slamch, slanst
341* ..
342* .. External Subroutines ..
343 EXTERNAL scopy, sscal, sstebz, sstemr, sstein, ssterf,
344 $ sswap, xerbla
345* ..
346* .. Intrinsic Functions ..
347 INTRINSIC max, min, sqrt
348* ..
349* .. Executable Statements ..
350*
351*
352* Test the input parameters.
353*
354 ieeeok = ilaenv( 10, 'SSTEVR', 'N', 1, 2, 3, 4 )
355*
356 wantz = lsame( jobz, 'V' )
357 alleig = lsame( range, 'A' )
358 valeig = lsame( range, 'V' )
359 indeig = lsame( range, 'I' )
360*
361 lquery = ( ( lwork.EQ.-1 ) .OR. ( liwork.EQ.-1 ) )
362 lwmin = max( 1, 20*n )
363 liwmin = max(1, 10*n )
364*
365*
366 info = 0
367 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
368 info = -1
369 ELSE IF( .NOT.( alleig .OR. valeig .OR. indeig ) ) THEN
370 info = -2
371 ELSE IF( n.LT.0 ) THEN
372 info = -3
373 ELSE
374 IF( valeig ) THEN
375 IF( n.GT.0 .AND. vu.LE.vl )
376 $ info = -7
377 ELSE IF( indeig ) THEN
378 IF( il.LT.1 .OR. il.GT.max( 1, n ) ) THEN
379 info = -8
380 ELSE IF( iu.LT.min( n, il ) .OR. iu.GT.n ) THEN
381 info = -9
382 END IF
383 END IF
384 END IF
385 IF( info.EQ.0 ) THEN
386 IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
387 info = -14
388 END IF
389 END IF
390*
391 IF( info.EQ.0 ) THEN
392 work( 1 ) = lwmin
393 iwork( 1 ) = liwmin
394*
395 IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
396 info = -17
397 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
398 info = -19
399 END IF
400 END IF
401*
402 IF( info.NE.0 ) THEN
403 CALL xerbla( 'SSTEVR', -info )
404 RETURN
405 ELSE IF( lquery ) THEN
406 RETURN
407 END IF
408*
409* Quick return if possible
410*
411 m = 0
412 IF( n.EQ.0 )
413 $ RETURN
414*
415 IF( n.EQ.1 ) THEN
416 IF( alleig .OR. indeig ) THEN
417 m = 1
418 w( 1 ) = d( 1 )
419 ELSE
420 IF( vl.LT.d( 1 ) .AND. vu.GE.d( 1 ) ) THEN
421 m = 1
422 w( 1 ) = d( 1 )
423 END IF
424 END IF
425 IF( wantz )
426 $ z( 1, 1 ) = one
427 RETURN
428 END IF
429*
430* Get machine constants.
431*
432 safmin = slamch( 'Safe minimum' )
433 eps = slamch( 'Precision' )
434 smlnum = safmin / eps
435 bignum = one / smlnum
436 rmin = sqrt( smlnum )
437 rmax = min( sqrt( bignum ), one / sqrt( sqrt( safmin ) ) )
438*
439*
440* Scale matrix to allowable range, if necessary.
441*
442 iscale = 0
443 IF( valeig ) THEN
444 vll = vl
445 vuu = vu
446 END IF
447*
448 tnrm = slanst( 'M', n, d, e )
449 IF( tnrm.GT.zero .AND. tnrm.LT.rmin ) THEN
450 iscale = 1
451 sigma = rmin / tnrm
452 ELSE IF( tnrm.GT.rmax ) THEN
453 iscale = 1
454 sigma = rmax / tnrm
455 END IF
456 IF( iscale.EQ.1 ) THEN
457 CALL sscal( n, sigma, d, 1 )
458 CALL sscal( n-1, sigma, e( 1 ), 1 )
459 IF( valeig ) THEN
460 vll = vl*sigma
461 vuu = vu*sigma
462 END IF
463 END IF
464
465* Initialize indices into workspaces. Note: These indices are used only
466* if SSTERF or SSTEMR fail.
467
468* IWORK(INDIBL:INDIBL+M-1) corresponds to IBLOCK in SSTEBZ and
469* stores the block indices of each of the M<=N eigenvalues.
470 indibl = 1
471* IWORK(INDISP:INDISP+NSPLIT-1) corresponds to ISPLIT in SSTEBZ and
472* stores the starting and finishing indices of each block.
473 indisp = indibl + n
474* IWORK(INDIFL:INDIFL+N-1) stores the indices of eigenvectors
475* that corresponding to eigenvectors that fail to converge in
476* SSTEIN. This information is discarded; if any fail, the driver
477* returns INFO > 0.
478 indifl = indisp + n
479* INDIWO is the offset of the remaining integer workspace.
480 indiwo = indisp + n
481*
482* If all eigenvalues are desired, then
483* call SSTERF or SSTEMR. If this fails for some eigenvalue, then
484* try SSTEBZ.
485*
486*
487 test = .false.
488 IF( indeig ) THEN
489 IF( il.EQ.1 .AND. iu.EQ.n ) THEN
490 test = .true.
491 END IF
492 END IF
493 IF( ( alleig .OR. test ) .AND. ieeeok.EQ.1 ) THEN
494 CALL scopy( n-1, e( 1 ), 1, work( 1 ), 1 )
495 IF( .NOT.wantz ) THEN
496 CALL scopy( n, d, 1, w, 1 )
497 CALL ssterf( n, w, work, info )
498 ELSE
499 CALL scopy( n, d, 1, work( n+1 ), 1 )
500 IF (abstol .LE. two*n*eps) THEN
501 tryrac = .true.
502 ELSE
503 tryrac = .false.
504 END IF
505 CALL sstemr( jobz, 'A', n, work( n+1 ), work, vl, vu, il,
506 $ iu, m, w, z, ldz, n, isuppz, tryrac,
507 $ work( 2*n+1 ), lwork-2*n, iwork, liwork, info )
508*
509 END IF
510 IF( info.EQ.0 ) THEN
511 m = n
512 GO TO 10
513 END IF
514 info = 0
515 END IF
516*
517* Otherwise, call SSTEBZ and, if eigenvectors are desired, SSTEIN.
518*
519 IF( wantz ) THEN
520 order = 'B'
521 ELSE
522 order = 'E'
523 END IF
524
525 CALL sstebz( range, order, n, vll, vuu, il, iu, abstol, d, e, m,
526 $ nsplit, w, iwork( indibl ), iwork( indisp ), work,
527 $ iwork( indiwo ), info )
528*
529 IF( wantz ) THEN
530 CALL sstein( n, d, e, m, w, iwork( indibl ), iwork( indisp ),
531 $ z, ldz, work, iwork( indiwo ), iwork( indifl ),
532 $ info )
533 END IF
534*
535* If matrix was scaled, then rescale eigenvalues appropriately.
536*
537 10 CONTINUE
538 IF( iscale.EQ.1 ) THEN
539 IF( info.EQ.0 ) THEN
540 imax = m
541 ELSE
542 imax = info - 1
543 END IF
544 CALL sscal( imax, one / sigma, w, 1 )
545 END IF
546*
547* If eigenvalues are not in order, then sort them, along with
548* eigenvectors.
549*
550 IF( wantz ) THEN
551 DO 30 j = 1, m - 1
552 i = 0
553 tmp1 = w( j )
554 DO 20 jj = j + 1, m
555 IF( w( jj ).LT.tmp1 ) THEN
556 i = jj
557 tmp1 = w( jj )
558 END IF
559 20 CONTINUE
560*
561 IF( i.NE.0 ) THEN
562 w( i ) = w( j )
563 w( j ) = tmp1
564 CALL sswap( n, z( 1, i ), 1, z( 1, j ), 1 )
565 END IF
566 30 CONTINUE
567 END IF
568*
569* Causes problems with tests 19 & 20:
570* IF (wantz .and. INDEIG ) Z( 1,1) = Z(1,1) / 1.002 + .002
571*
572*
573 work( 1 ) = lwmin
574 iwork( 1 ) = liwmin
575 RETURN
576*
577* End of SSTEVR
578*
real function slanst(NORM, N, D, E)
SLANST returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: slanst.f:100
integer function ilaenv(ISPEC, NAME, OPTS, N1, N2, N3, N4)
ILAENV
Definition: ilaenv.f:162
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
subroutine ssterf(N, D, E, INFO)
SSTERF
Definition: ssterf.f:86
subroutine sstebz(RANGE, ORDER, N, VL, VU, IL, IU, ABSTOL, D, E, M, NSPLIT, W, IBLOCK, ISPLIT, WORK, IWORK, INFO)
SSTEBZ
Definition: sstebz.f:273
subroutine sstemr(JOBZ, RANGE, N, D, E, VL, VU, IL, IU, M, W, Z, LDZ, NZC, ISUPPZ, TRYRAC, WORK, LWORK, IWORK, LIWORK, INFO)
SSTEMR
Definition: sstemr.f:321
subroutine sstein(N, D, E, M, W, IBLOCK, ISPLIT, Z, LDZ, WORK, IWORK, IFAIL, INFO)
SSTEIN
Definition: sstein.f:174
subroutine sswap(N, SX, INCX, SY, INCY)
SSWAP
Definition: sswap.f:82
subroutine scopy(N, SX, INCX, SY, INCY)
SCOPY
Definition: scopy.f:82
subroutine sscal(N, SA, SX, INCX)
SSCAL
Definition: sscal.f:79
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:68
Here is the call graph for this function:
Here is the caller graph for this function: