Annotation of rpl/lapack/lapack/dstevr.f, revision 1.19

1.8       bertrand    1: *> \brief <b> DSTEVR computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b>
                      2: *
                      3: *  =========== DOCUMENTATION ===========
                      4: *
1.16      bertrand    5: * Online html documentation available at
                      6: *            http://www.netlib.org/lapack/explore-html/
1.8       bertrand    7: *
                      8: *> \htmlonly
1.16      bertrand    9: *> Download DSTEVR + dependencies
                     10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dstevr.f">
                     11: *> [TGZ]</a>
                     12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dstevr.f">
                     13: *> [ZIP]</a>
                     14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dstevr.f">
1.8       bertrand   15: *> [TXT]</a>
1.16      bertrand   16: *> \endhtmlonly
1.8       bertrand   17: *
                     18: *  Definition:
                     19: *  ===========
                     20: *
                     21: *       SUBROUTINE DSTEVR( JOBZ, RANGE, N, D, E, VL, VU, IL, IU, ABSTOL,
                     22: *                          M, W, Z, LDZ, ISUPPZ, WORK, LWORK, IWORK,
                     23: *                          LIWORK, INFO )
1.16      bertrand   24: *
1.8       bertrand   25: *       .. Scalar Arguments ..
                     26: *       CHARACTER          JOBZ, RANGE
                     27: *       INTEGER            IL, INFO, IU, LDZ, LIWORK, LWORK, M, N
                     28: *       DOUBLE PRECISION   ABSTOL, VL, VU
                     29: *       ..
                     30: *       .. Array Arguments ..
                     31: *       INTEGER            ISUPPZ( * ), IWORK( * )
                     32: *       DOUBLE PRECISION   D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
                     33: *       ..
1.16      bertrand   34: *
1.8       bertrand   35: *
                     36: *> \par Purpose:
                     37: *  =============
                     38: *>
                     39: *> \verbatim
                     40: *>
                     41: *> DSTEVR computes selected eigenvalues and, optionally, eigenvectors
                     42: *> of a real symmetric tridiagonal matrix T.  Eigenvalues and
                     43: *> eigenvectors can be selected by specifying either a range of values
                     44: *> or a range of indices for the desired eigenvalues.
                     45: *>
                     46: *> Whenever possible, DSTEVR calls DSTEMR to compute the
                     47: *> eigenspectrum using Relatively Robust Representations.  DSTEMR
                     48: *> computes eigenvalues by the dqds algorithm, while orthogonal
                     49: *> eigenvectors are computed from various "good" L D L^T representations
                     50: *> (also known as Relatively Robust Representations). Gram-Schmidt
                     51: *> orthogonalization is avoided as far as possible. More specifically,
                     52: *> the various steps of the algorithm are as follows. For the i-th
                     53: *> unreduced block of T,
                     54: *>    (a) Compute T - sigma_i = L_i D_i L_i^T, such that L_i D_i L_i^T
                     55: *>         is a relatively robust representation,
                     56: *>    (b) Compute the eigenvalues, lambda_j, of L_i D_i L_i^T to high
                     57: *>        relative accuracy by the dqds algorithm,
                     58: *>    (c) If there is a cluster of close eigenvalues, "choose" sigma_i
                     59: *>        close to the cluster, and go to step (a),
                     60: *>    (d) Given the approximate eigenvalue lambda_j of L_i D_i L_i^T,
                     61: *>        compute the corresponding eigenvector by forming a
                     62: *>        rank-revealing twisted factorization.
                     63: *> The desired accuracy of the output can be specified by the input
                     64: *> parameter ABSTOL.
                     65: *>
                     66: *> For more details, see "A new O(n^2) algorithm for the symmetric
                     67: *> tridiagonal eigenvalue/eigenvector problem", by Inderjit Dhillon,
                     68: *> Computer Science Division Technical Report No. UCB//CSD-97-971,
                     69: *> UC Berkeley, May 1997.
                     70: *>
                     71: *>
                     72: *> Note 1 : DSTEVR calls DSTEMR when the full spectrum is requested
                     73: *> on machines which conform to the ieee-754 floating point standard.
                     74: *> DSTEVR calls DSTEBZ and DSTEIN on non-ieee machines and
                     75: *> when partial spectrum requests are made.
                     76: *>
                     77: *> Normal execution of DSTEMR may create NaNs and infinities and
                     78: *> hence may abort due to a floating point exception in environments
                     79: *> which do not handle NaNs and infinities in the ieee standard default
                     80: *> manner.
                     81: *> \endverbatim
                     82: *
                     83: *  Arguments:
                     84: *  ==========
                     85: *
                     86: *> \param[in] JOBZ
                     87: *> \verbatim
                     88: *>          JOBZ is CHARACTER*1
                     89: *>          = 'N':  Compute eigenvalues only;
                     90: *>          = 'V':  Compute eigenvalues and eigenvectors.
                     91: *> \endverbatim
                     92: *>
                     93: *> \param[in] RANGE
                     94: *> \verbatim
                     95: *>          RANGE is CHARACTER*1
                     96: *>          = 'A': all eigenvalues will be found.
                     97: *>          = 'V': all eigenvalues in the half-open interval (VL,VU]
                     98: *>                 will be found.
                     99: *>          = 'I': the IL-th through IU-th eigenvalues will be found.
                    100: *>          For RANGE = 'V' or 'I' and IU - IL < N - 1, DSTEBZ and
                    101: *>          DSTEIN are called
                    102: *> \endverbatim
                    103: *>
                    104: *> \param[in] N
                    105: *> \verbatim
                    106: *>          N is INTEGER
                    107: *>          The order of the matrix.  N >= 0.
                    108: *> \endverbatim
                    109: *>
                    110: *> \param[in,out] D
                    111: *> \verbatim
                    112: *>          D is DOUBLE PRECISION array, dimension (N)
                    113: *>          On entry, the n diagonal elements of the tridiagonal matrix
                    114: *>          A.
                    115: *>          On exit, D may be multiplied by a constant factor chosen
                    116: *>          to avoid over/underflow in computing the eigenvalues.
                    117: *> \endverbatim
                    118: *>
                    119: *> \param[in,out] E
                    120: *> \verbatim
                    121: *>          E is DOUBLE PRECISION array, dimension (max(1,N-1))
                    122: *>          On entry, the (n-1) subdiagonal elements of the tridiagonal
                    123: *>          matrix A in elements 1 to N-1 of E.
                    124: *>          On exit, E may be multiplied by a constant factor chosen
                    125: *>          to avoid over/underflow in computing the eigenvalues.
                    126: *> \endverbatim
                    127: *>
                    128: *> \param[in] VL
                    129: *> \verbatim
                    130: *>          VL is DOUBLE PRECISION
1.14      bertrand  131: *>          If RANGE='V', the lower bound of the interval to
                    132: *>          be searched for eigenvalues. VL < VU.
                    133: *>          Not referenced if RANGE = 'A' or 'I'.
1.8       bertrand  134: *> \endverbatim
                    135: *>
                    136: *> \param[in] VU
                    137: *> \verbatim
                    138: *>          VU is DOUBLE PRECISION
1.14      bertrand  139: *>          If RANGE='V', the upper bound of the interval to
1.8       bertrand  140: *>          be searched for eigenvalues. VL < VU.
                    141: *>          Not referenced if RANGE = 'A' or 'I'.
                    142: *> \endverbatim
                    143: *>
                    144: *> \param[in] IL
                    145: *> \verbatim
                    146: *>          IL is INTEGER
1.14      bertrand  147: *>          If RANGE='I', the index of the
                    148: *>          smallest eigenvalue to be returned.
                    149: *>          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
                    150: *>          Not referenced if RANGE = 'A' or 'V'.
1.8       bertrand  151: *> \endverbatim
                    152: *>
                    153: *> \param[in] IU
                    154: *> \verbatim
                    155: *>          IU is INTEGER
1.14      bertrand  156: *>          If RANGE='I', the index of the
                    157: *>          largest eigenvalue to be returned.
1.8       bertrand  158: *>          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
                    159: *>          Not referenced if RANGE = 'A' or 'V'.
                    160: *> \endverbatim
                    161: *>
                    162: *> \param[in] ABSTOL
                    163: *> \verbatim
                    164: *>          ABSTOL is DOUBLE PRECISION
                    165: *>          The absolute error tolerance for the eigenvalues.
                    166: *>          An approximate eigenvalue is accepted as converged
                    167: *>          when it is determined to lie in an interval [a,b]
                    168: *>          of width less than or equal to
                    169: *>
                    170: *>                  ABSTOL + EPS *   max( |a|,|b| ) ,
                    171: *>
                    172: *>          where EPS is the machine precision.  If ABSTOL is less than
                    173: *>          or equal to zero, then  EPS*|T|  will be used in its place,
                    174: *>          where |T| is the 1-norm of the tridiagonal matrix obtained
                    175: *>          by reducing A to tridiagonal form.
                    176: *>
                    177: *>          See "Computing Small Singular Values of Bidiagonal Matrices
                    178: *>          with Guaranteed High Relative Accuracy," by Demmel and
                    179: *>          Kahan, LAPACK Working Note #3.
                    180: *>
                    181: *>          If high relative accuracy is important, set ABSTOL to
                    182: *>          DLAMCH( 'Safe minimum' ).  Doing so will guarantee that
                    183: *>          eigenvalues are computed to high relative accuracy when
                    184: *>          possible in future releases.  The current code does not
                    185: *>          make any guarantees about high relative accuracy, but
                    186: *>          future releases will. See J. Barlow and J. Demmel,
                    187: *>          "Computing Accurate Eigensystems of Scaled Diagonally
                    188: *>          Dominant Matrices", LAPACK Working Note #7, for a discussion
                    189: *>          of which matrices define their eigenvalues to high relative
                    190: *>          accuracy.
                    191: *> \endverbatim
                    192: *>
                    193: *> \param[out] M
                    194: *> \verbatim
                    195: *>          M is INTEGER
                    196: *>          The total number of eigenvalues found.  0 <= M <= N.
                    197: *>          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
                    198: *> \endverbatim
                    199: *>
                    200: *> \param[out] W
                    201: *> \verbatim
                    202: *>          W is DOUBLE PRECISION array, dimension (N)
                    203: *>          The first M elements contain the selected eigenvalues in
                    204: *>          ascending order.
                    205: *> \endverbatim
                    206: *>
                    207: *> \param[out] Z
                    208: *> \verbatim
                    209: *>          Z is DOUBLE PRECISION array, dimension (LDZ, max(1,M) )
                    210: *>          If JOBZ = 'V', then if INFO = 0, the first M columns of Z
                    211: *>          contain the orthonormal eigenvectors of the matrix A
                    212: *>          corresponding to the selected eigenvalues, with the i-th
                    213: *>          column of Z holding the eigenvector associated with W(i).
                    214: *>          Note: the user must ensure that at least max(1,M) columns are
                    215: *>          supplied in the array Z; if RANGE = 'V', the exact value of M
                    216: *>          is not known in advance and an upper bound must be used.
                    217: *> \endverbatim
                    218: *>
                    219: *> \param[in] LDZ
                    220: *> \verbatim
                    221: *>          LDZ is INTEGER
                    222: *>          The leading dimension of the array Z.  LDZ >= 1, and if
                    223: *>          JOBZ = 'V', LDZ >= max(1,N).
                    224: *> \endverbatim
                    225: *>
                    226: *> \param[out] ISUPPZ
                    227: *> \verbatim
                    228: *>          ISUPPZ is INTEGER array, dimension ( 2*max(1,M) )
                    229: *>          The support of the eigenvectors in Z, i.e., the indices
                    230: *>          indicating the nonzero elements in Z. The i-th eigenvector
                    231: *>          is nonzero only in elements ISUPPZ( 2*i-1 ) through
                    232: *>          ISUPPZ( 2*i ).
                    233: *>          Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1
                    234: *> \endverbatim
                    235: *>
                    236: *> \param[out] WORK
                    237: *> \verbatim
                    238: *>          WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
                    239: *>          On exit, if INFO = 0, WORK(1) returns the optimal (and
                    240: *>          minimal) LWORK.
                    241: *> \endverbatim
                    242: *>
                    243: *> \param[in] LWORK
                    244: *> \verbatim
                    245: *>          LWORK is INTEGER
                    246: *>          The dimension of the array WORK.  LWORK >= max(1,20*N).
                    247: *>
                    248: *>          If LWORK = -1, then a workspace query is assumed; the routine
                    249: *>          only calculates the optimal sizes of the WORK and IWORK
                    250: *>          arrays, returns these values as the first entries of the WORK
                    251: *>          and IWORK arrays, and no error message related to LWORK or
                    252: *>          LIWORK is issued by XERBLA.
                    253: *> \endverbatim
                    254: *>
                    255: *> \param[out] IWORK
                    256: *> \verbatim
                    257: *>          IWORK is INTEGER array, dimension (MAX(1,LIWORK))
                    258: *>          On exit, if INFO = 0, IWORK(1) returns the optimal (and
                    259: *>          minimal) LIWORK.
                    260: *> \endverbatim
                    261: *>
                    262: *> \param[in] LIWORK
                    263: *> \verbatim
                    264: *>          LIWORK is INTEGER
                    265: *>          The dimension of the array IWORK.  LIWORK >= max(1,10*N).
                    266: *>
                    267: *>          If LIWORK = -1, then a workspace query is assumed; the
                    268: *>          routine only calculates the optimal sizes of the WORK and
                    269: *>          IWORK arrays, returns these values as the first entries of
                    270: *>          the WORK and IWORK arrays, and no error message related to
                    271: *>          LWORK or LIWORK is issued by XERBLA.
                    272: *> \endverbatim
                    273: *>
                    274: *> \param[out] INFO
                    275: *> \verbatim
                    276: *>          INFO is INTEGER
                    277: *>          = 0:  successful exit
                    278: *>          < 0:  if INFO = -i, the i-th argument had an illegal value
                    279: *>          > 0:  Internal error
                    280: *> \endverbatim
                    281: *
                    282: *  Authors:
                    283: *  ========
                    284: *
1.16      bertrand  285: *> \author Univ. of Tennessee
                    286: *> \author Univ. of California Berkeley
                    287: *> \author Univ. of Colorado Denver
                    288: *> \author NAG Ltd.
1.8       bertrand  289: *
                    290: *> \ingroup doubleOTHEReigen
                    291: *
                    292: *> \par Contributors:
                    293: *  ==================
                    294: *>
                    295: *>     Inderjit Dhillon, IBM Almaden, USA \n
                    296: *>     Osni Marques, LBNL/NERSC, USA \n
                    297: *>     Ken Stanley, Computer Science Division, University of
                    298: *>       California at Berkeley, USA \n
                    299: *>
                    300: *  =====================================================================
1.1       bertrand  301:       SUBROUTINE DSTEVR( JOBZ, RANGE, N, D, E, VL, VU, IL, IU, ABSTOL,
                    302:      $                   M, W, Z, LDZ, ISUPPZ, WORK, LWORK, IWORK,
                    303:      $                   LIWORK, INFO )
                    304: *
1.19    ! bertrand  305: *  -- LAPACK driver routine --
1.1       bertrand  306: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                    307: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
                    308: *
                    309: *     .. Scalar Arguments ..
                    310:       CHARACTER          JOBZ, RANGE
                    311:       INTEGER            IL, INFO, IU, LDZ, LIWORK, LWORK, M, N
                    312:       DOUBLE PRECISION   ABSTOL, VL, VU
                    313: *     ..
                    314: *     .. Array Arguments ..
                    315:       INTEGER            ISUPPZ( * ), IWORK( * )
                    316:       DOUBLE PRECISION   D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
                    317: *     ..
                    318: *
                    319: *  =====================================================================
                    320: *
                    321: *     .. Parameters ..
                    322:       DOUBLE PRECISION   ZERO, ONE, TWO
                    323:       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0 )
                    324: *     ..
                    325: *     .. Local Scalars ..
                    326:       LOGICAL            ALLEIG, INDEIG, TEST, LQUERY, VALEIG, WANTZ,
                    327:      $                   TRYRAC
                    328:       CHARACTER          ORDER
                    329:       INTEGER            I, IEEEOK, IMAX, INDIBL, INDIFL, INDISP,
                    330:      $                   INDIWO, ISCALE, ITMP1, J, JJ, LIWMIN, LWMIN,
                    331:      $                   NSPLIT
                    332:       DOUBLE PRECISION   BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, SMLNUM,
                    333:      $                   TMP1, TNRM, VLL, VUU
                    334: *     ..
                    335: *     .. External Functions ..
                    336:       LOGICAL            LSAME
                    337:       INTEGER            ILAENV
                    338:       DOUBLE PRECISION   DLAMCH, DLANST
                    339:       EXTERNAL           LSAME, ILAENV, DLAMCH, DLANST
                    340: *     ..
                    341: *     .. External Subroutines ..
                    342:       EXTERNAL           DCOPY, DSCAL, DSTEBZ, DSTEMR, DSTEIN, DSTERF,
                    343:      $                   DSWAP, XERBLA
                    344: *     ..
                    345: *     .. Intrinsic Functions ..
                    346:       INTRINSIC          MAX, MIN, SQRT
                    347: *     ..
                    348: *     .. Executable Statements ..
                    349: *
                    350: *
                    351: *     Test the input parameters.
                    352: *
                    353:       IEEEOK = ILAENV( 10, 'DSTEVR', 'N', 1, 2, 3, 4 )
                    354: *
                    355:       WANTZ = LSAME( JOBZ, 'V' )
                    356:       ALLEIG = LSAME( RANGE, 'A' )
                    357:       VALEIG = LSAME( RANGE, 'V' )
                    358:       INDEIG = LSAME( RANGE, 'I' )
                    359: *
                    360:       LQUERY = ( ( LWORK.EQ.-1 ) .OR. ( LIWORK.EQ.-1 ) )
                    361:       LWMIN = MAX( 1, 20*N )
                    362:       LIWMIN = MAX( 1, 10*N )
                    363: *
                    364: *
                    365:       INFO = 0
                    366:       IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
                    367:          INFO = -1
                    368:       ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
                    369:          INFO = -2
                    370:       ELSE IF( N.LT.0 ) THEN
                    371:          INFO = -3
                    372:       ELSE
                    373:          IF( VALEIG ) THEN
                    374:             IF( N.GT.0 .AND. VU.LE.VL )
                    375:      $         INFO = -7
                    376:          ELSE IF( INDEIG ) THEN
                    377:             IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
                    378:                INFO = -8
                    379:             ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
                    380:                INFO = -9
                    381:             END IF
                    382:          END IF
                    383:       END IF
                    384:       IF( INFO.EQ.0 ) THEN
                    385:          IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
                    386:             INFO = -14
                    387:          END IF
                    388:       END IF
                    389: *
                    390:       IF( INFO.EQ.0 ) THEN
                    391:          WORK( 1 ) = LWMIN
                    392:          IWORK( 1 ) = LIWMIN
                    393: *
                    394:          IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
                    395:             INFO = -17
                    396:          ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
                    397:             INFO = -19
                    398:          END IF
                    399:       END IF
                    400: *
                    401:       IF( INFO.NE.0 ) THEN
                    402:          CALL XERBLA( 'DSTEVR', -INFO )
                    403:          RETURN
                    404:       ELSE IF( LQUERY ) THEN
                    405:          RETURN
                    406:       END IF
                    407: *
                    408: *     Quick return if possible
                    409: *
                    410:       M = 0
                    411:       IF( N.EQ.0 )
                    412:      $   RETURN
                    413: *
                    414:       IF( N.EQ.1 ) THEN
                    415:          IF( ALLEIG .OR. INDEIG ) THEN
                    416:             M = 1
                    417:             W( 1 ) = D( 1 )
                    418:          ELSE
                    419:             IF( VL.LT.D( 1 ) .AND. VU.GE.D( 1 ) ) THEN
                    420:                M = 1
                    421:                W( 1 ) = D( 1 )
                    422:             END IF
                    423:          END IF
                    424:          IF( WANTZ )
                    425:      $      Z( 1, 1 ) = ONE
                    426:          RETURN
                    427:       END IF
                    428: *
                    429: *     Get machine constants.
                    430: *
                    431:       SAFMIN = DLAMCH( 'Safe minimum' )
                    432:       EPS = DLAMCH( 'Precision' )
                    433:       SMLNUM = SAFMIN / EPS
                    434:       BIGNUM = ONE / SMLNUM
                    435:       RMIN = SQRT( SMLNUM )
                    436:       RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
                    437: *
                    438: *
                    439: *     Scale matrix to allowable range, if necessary.
                    440: *
                    441:       ISCALE = 0
1.13      bertrand  442:       IF( VALEIG ) THEN
                    443:          VLL = VL
                    444:          VUU = VU
                    445:       END IF
1.1       bertrand  446: *
                    447:       TNRM = DLANST( 'M', N, D, E )
                    448:       IF( TNRM.GT.ZERO .AND. TNRM.LT.RMIN ) THEN
                    449:          ISCALE = 1
                    450:          SIGMA = RMIN / TNRM
                    451:       ELSE IF( TNRM.GT.RMAX ) THEN
                    452:          ISCALE = 1
                    453:          SIGMA = RMAX / TNRM
                    454:       END IF
                    455:       IF( ISCALE.EQ.1 ) THEN
                    456:          CALL DSCAL( N, SIGMA, D, 1 )
                    457:          CALL DSCAL( N-1, SIGMA, E( 1 ), 1 )
                    458:          IF( VALEIG ) THEN
                    459:             VLL = VL*SIGMA
                    460:             VUU = VU*SIGMA
                    461:          END IF
                    462:       END IF
                    463: 
                    464: *     Initialize indices into workspaces.  Note: These indices are used only
                    465: *     if DSTERF or DSTEMR fail.
                    466: 
                    467: *     IWORK(INDIBL:INDIBL+M-1) corresponds to IBLOCK in DSTEBZ and
                    468: *     stores the block indices of each of the M<=N eigenvalues.
                    469:       INDIBL = 1
                    470: *     IWORK(INDISP:INDISP+NSPLIT-1) corresponds to ISPLIT in DSTEBZ and
                    471: *     stores the starting and finishing indices of each block.
                    472:       INDISP = INDIBL + N
                    473: *     IWORK(INDIFL:INDIFL+N-1) stores the indices of eigenvectors
                    474: *     that corresponding to eigenvectors that fail to converge in
                    475: *     DSTEIN.  This information is discarded; if any fail, the driver
                    476: *     returns INFO > 0.
                    477:       INDIFL = INDISP + N
                    478: *     INDIWO is the offset of the remaining integer workspace.
                    479:       INDIWO = INDISP + N
                    480: *
                    481: *     If all eigenvalues are desired, then
                    482: *     call DSTERF or DSTEMR.  If this fails for some eigenvalue, then
                    483: *     try DSTEBZ.
                    484: *
                    485: *
                    486:       TEST = .FALSE.
                    487:       IF( INDEIG ) THEN
                    488:          IF( IL.EQ.1 .AND. IU.EQ.N ) THEN
                    489:             TEST = .TRUE.
                    490:          END IF
                    491:       END IF
                    492:       IF( ( ALLEIG .OR. TEST ) .AND. IEEEOK.EQ.1 ) THEN
                    493:          CALL DCOPY( N-1, E( 1 ), 1, WORK( 1 ), 1 )
                    494:          IF( .NOT.WANTZ ) THEN
                    495:             CALL DCOPY( N, D, 1, W, 1 )
                    496:             CALL DSTERF( N, W, WORK, INFO )
                    497:          ELSE
                    498:             CALL DCOPY( N, D, 1, WORK( N+1 ), 1 )
                    499:             IF (ABSTOL .LE. TWO*N*EPS) THEN
                    500:                TRYRAC = .TRUE.
                    501:             ELSE
                    502:                TRYRAC = .FALSE.
                    503:             END IF
                    504:             CALL DSTEMR( JOBZ, 'A', N, WORK( N+1 ), WORK, VL, VU, IL,
                    505:      $                   IU, M, W, Z, LDZ, N, ISUPPZ, TRYRAC,
                    506:      $                   WORK( 2*N+1 ), LWORK-2*N, IWORK, LIWORK, INFO )
                    507: *
                    508:          END IF
                    509:          IF( INFO.EQ.0 ) THEN
                    510:             M = N
                    511:             GO TO 10
                    512:          END IF
                    513:          INFO = 0
                    514:       END IF
                    515: *
                    516: *     Otherwise, call DSTEBZ and, if eigenvectors are desired, DSTEIN.
                    517: *
                    518:       IF( WANTZ ) THEN
                    519:          ORDER = 'B'
                    520:       ELSE
                    521:          ORDER = 'E'
                    522:       END IF
                    523: 
                    524:       CALL DSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTOL, D, E, M,
                    525:      $             NSPLIT, W, IWORK( INDIBL ), IWORK( INDISP ), WORK,
                    526:      $             IWORK( INDIWO ), INFO )
                    527: *
                    528:       IF( WANTZ ) THEN
                    529:          CALL DSTEIN( N, D, E, M, W, IWORK( INDIBL ), IWORK( INDISP ),
                    530:      $                Z, LDZ, WORK, IWORK( INDIWO ), IWORK( INDIFL ),
                    531:      $                INFO )
                    532:       END IF
                    533: *
                    534: *     If matrix was scaled, then rescale eigenvalues appropriately.
                    535: *
                    536:    10 CONTINUE
                    537:       IF( ISCALE.EQ.1 ) THEN
                    538:          IF( INFO.EQ.0 ) THEN
                    539:             IMAX = M
                    540:          ELSE
                    541:             IMAX = INFO - 1
                    542:          END IF
                    543:          CALL DSCAL( IMAX, ONE / SIGMA, W, 1 )
                    544:       END IF
                    545: *
                    546: *     If eigenvalues are not in order, then sort them, along with
                    547: *     eigenvectors.
                    548: *
                    549:       IF( WANTZ ) THEN
                    550:          DO 30 J = 1, M - 1
                    551:             I = 0
                    552:             TMP1 = W( J )
                    553:             DO 20 JJ = J + 1, M
                    554:                IF( W( JJ ).LT.TMP1 ) THEN
                    555:                   I = JJ
                    556:                   TMP1 = W( JJ )
                    557:                END IF
                    558:    20       CONTINUE
                    559: *
                    560:             IF( I.NE.0 ) THEN
                    561:                ITMP1 = IWORK( I )
                    562:                W( I ) = W( J )
                    563:                IWORK( I ) = IWORK( J )
                    564:                W( J ) = TMP1
                    565:                IWORK( J ) = ITMP1
                    566:                CALL DSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
                    567:             END IF
                    568:    30    CONTINUE
                    569:       END IF
                    570: *
                    571: *      Causes problems with tests 19 & 20:
                    572: *      IF (wantz .and. INDEIG ) Z( 1,1) = Z(1,1) / 1.002 + .002
                    573: *
                    574: *
                    575:       WORK( 1 ) = LWMIN
                    576:       IWORK( 1 ) = LIWMIN
                    577:       RETURN
                    578: *
                    579: *     End of DSTEVR
                    580: *
                    581:       END

CVSweb interface <joel.bertrand@systella.fr>