LAPACK 3.12.1
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  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,  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 , 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  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,
!>          , 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 301 of file sstevr.f.

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