Annotation of rpl/lapack/lapack/dstemr.f, revision 1.23

1.9       bertrand    1: *> \brief \b DSTEMR
                      2: *
                      3: *  =========== DOCUMENTATION ===========
                      4: *
1.18      bertrand    5: * Online html documentation available at
                      6: *            http://www.netlib.org/lapack/explore-html/
1.9       bertrand    7: *
                      8: *> \htmlonly
1.18      bertrand    9: *> Download DSTEMR + dependencies
                     10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dstemr.f">
                     11: *> [TGZ]</a>
                     12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dstemr.f">
                     13: *> [ZIP]</a>
                     14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dstemr.f">
1.9       bertrand   15: *> [TXT]</a>
1.18      bertrand   16: *> \endhtmlonly
1.9       bertrand   17: *
                     18: *  Definition:
                     19: *  ===========
                     20: *
                     21: *       SUBROUTINE DSTEMR( JOBZ, RANGE, N, D, E, VL, VU, IL, IU,
                     22: *                          M, W, Z, LDZ, NZC, ISUPPZ, TRYRAC, WORK, LWORK,
                     23: *                          IWORK, LIWORK, INFO )
1.18      bertrand   24: *
1.9       bertrand   25: *       .. Scalar Arguments ..
                     26: *       CHARACTER          JOBZ, RANGE
                     27: *       LOGICAL            TRYRAC
                     28: *       INTEGER            IL, INFO, IU, LDZ, NZC, LIWORK, LWORK, M, N
                     29: *       DOUBLE PRECISION VL, VU
                     30: *       ..
                     31: *       .. Array Arguments ..
                     32: *       INTEGER            ISUPPZ( * ), IWORK( * )
                     33: *       DOUBLE PRECISION   D( * ), E( * ), W( * ), WORK( * )
                     34: *       DOUBLE PRECISION   Z( LDZ, * )
                     35: *       ..
1.18      bertrand   36: *
1.9       bertrand   37: *
                     38: *> \par Purpose:
                     39: *  =============
                     40: *>
                     41: *> \verbatim
                     42: *>
                     43: *> DSTEMR computes selected eigenvalues and, optionally, eigenvectors
                     44: *> of a real symmetric tridiagonal matrix T. Any such unreduced matrix has
                     45: *> a well defined set of pairwise different real eigenvalues, the corresponding
                     46: *> real eigenvectors are pairwise orthogonal.
                     47: *>
                     48: *> The spectrum may be computed either completely or partially by specifying
                     49: *> either an interval (VL,VU] or a range of indices IL:IU for the desired
                     50: *> eigenvalues.
                     51: *>
                     52: *> Depending on the number of desired eigenvalues, these are computed either
                     53: *> by bisection or the dqds algorithm. Numerically orthogonal eigenvectors are
                     54: *> computed by the use of various suitable L D L^T factorizations near clusters
                     55: *> of close eigenvalues (referred to as RRRs, Relatively Robust
                     56: *> Representations). An informal sketch of the algorithm follows.
                     57: *>
                     58: *> For each unreduced block (submatrix) of T,
                     59: *>    (a) Compute T - sigma I  = L D L^T, so that L and D
                     60: *>        define all the wanted eigenvalues to high relative accuracy.
                     61: *>        This means that small relative changes in the entries of D and L
                     62: *>        cause only small relative changes in the eigenvalues and
                     63: *>        eigenvectors. The standard (unfactored) representation of the
                     64: *>        tridiagonal matrix T does not have this property in general.
                     65: *>    (b) Compute the eigenvalues to suitable accuracy.
                     66: *>        If the eigenvectors are desired, the algorithm attains full
                     67: *>        accuracy of the computed eigenvalues only right before
                     68: *>        the corresponding vectors have to be computed, see steps c) and d).
                     69: *>    (c) For each cluster of close eigenvalues, select a new
                     70: *>        shift close to the cluster, find a new factorization, and refine
                     71: *>        the shifted eigenvalues to suitable accuracy.
                     72: *>    (d) For each eigenvalue with a large enough relative separation compute
                     73: *>        the corresponding eigenvector by forming a rank revealing twisted
                     74: *>        factorization. Go back to (c) for any clusters that remain.
                     75: *>
                     76: *> For more details, see:
                     77: *> - Inderjit S. Dhillon and Beresford N. Parlett: "Multiple representations
                     78: *>   to compute orthogonal eigenvectors of symmetric tridiagonal matrices,"
                     79: *>   Linear Algebra and its Applications, 387(1), pp. 1-28, August 2004.
                     80: *> - Inderjit Dhillon and Beresford Parlett: "Orthogonal Eigenvectors and
                     81: *>   Relative Gaps," SIAM Journal on Matrix Analysis and Applications, Vol. 25,
                     82: *>   2004.  Also LAPACK Working Note 154.
                     83: *> - Inderjit Dhillon: "A new O(n^2) algorithm for the symmetric
                     84: *>   tridiagonal eigenvalue/eigenvector problem",
                     85: *>   Computer Science Division Technical Report No. UCB/CSD-97-971,
                     86: *>   UC Berkeley, May 1997.
                     87: *>
                     88: *> Further Details
                     89: *> 1.DSTEMR works only on machines which follow IEEE-754
                     90: *> floating-point standard in their handling of infinities and NaNs.
                     91: *> This permits the use of efficient inner loops avoiding a check for
                     92: *> zero divisors.
                     93: *> \endverbatim
                     94: *
                     95: *  Arguments:
                     96: *  ==========
                     97: *
                     98: *> \param[in] JOBZ
                     99: *> \verbatim
                    100: *>          JOBZ is CHARACTER*1
                    101: *>          = 'N':  Compute eigenvalues only;
                    102: *>          = 'V':  Compute eigenvalues and eigenvectors.
                    103: *> \endverbatim
                    104: *>
                    105: *> \param[in] RANGE
                    106: *> \verbatim
                    107: *>          RANGE is CHARACTER*1
                    108: *>          = 'A': all eigenvalues will be found.
                    109: *>          = 'V': all eigenvalues in the half-open interval (VL,VU]
                    110: *>                 will be found.
                    111: *>          = 'I': the IL-th through IU-th eigenvalues will be found.
                    112: *> \endverbatim
                    113: *>
                    114: *> \param[in] N
                    115: *> \verbatim
                    116: *>          N is INTEGER
                    117: *>          The order of the matrix.  N >= 0.
                    118: *> \endverbatim
                    119: *>
                    120: *> \param[in,out] D
                    121: *> \verbatim
                    122: *>          D is DOUBLE PRECISION array, dimension (N)
                    123: *>          On entry, the N diagonal elements of the tridiagonal matrix
                    124: *>          T. On exit, D is overwritten.
                    125: *> \endverbatim
                    126: *>
                    127: *> \param[in,out] E
                    128: *> \verbatim
                    129: *>          E is DOUBLE PRECISION array, dimension (N)
                    130: *>          On entry, the (N-1) subdiagonal elements of the tridiagonal
                    131: *>          matrix T in elements 1 to N-1 of E. E(N) need not be set on
                    132: *>          input, but is used internally as workspace.
                    133: *>          On exit, E is overwritten.
                    134: *> \endverbatim
                    135: *>
                    136: *> \param[in] VL
                    137: *> \verbatim
                    138: *>          VL is DOUBLE PRECISION
1.16      bertrand  139: *>
                    140: *>          If RANGE='V', the lower bound of the interval to
                    141: *>          be searched for eigenvalues. VL < VU.
                    142: *>          Not referenced if RANGE = 'A' or 'I'.
1.9       bertrand  143: *> \endverbatim
                    144: *>
                    145: *> \param[in] VU
                    146: *> \verbatim
                    147: *>          VU is DOUBLE PRECISION
                    148: *>
1.16      bertrand  149: *>          If RANGE='V', the upper bound of the interval to
1.9       bertrand  150: *>          be searched for eigenvalues. VL < VU.
                    151: *>          Not referenced if RANGE = 'A' or 'I'.
                    152: *> \endverbatim
                    153: *>
                    154: *> \param[in] IL
                    155: *> \verbatim
                    156: *>          IL is INTEGER
1.16      bertrand  157: *>
                    158: *>          If RANGE='I', the index of the
                    159: *>          smallest eigenvalue to be returned.
                    160: *>          1 <= IL <= IU <= N, if N > 0.
                    161: *>          Not referenced if RANGE = 'A' or 'V'.
1.9       bertrand  162: *> \endverbatim
                    163: *>
                    164: *> \param[in] IU
                    165: *> \verbatim
                    166: *>          IU is INTEGER
                    167: *>
1.16      bertrand  168: *>          If RANGE='I', the index of the
                    169: *>          largest eigenvalue to be returned.
1.9       bertrand  170: *>          1 <= IL <= IU <= N, if N > 0.
                    171: *>          Not referenced if RANGE = 'A' or 'V'.
                    172: *> \endverbatim
                    173: *>
                    174: *> \param[out] M
                    175: *> \verbatim
                    176: *>          M is INTEGER
                    177: *>          The total number of eigenvalues found.  0 <= M <= N.
                    178: *>          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
                    179: *> \endverbatim
                    180: *>
                    181: *> \param[out] W
                    182: *> \verbatim
                    183: *>          W is DOUBLE PRECISION array, dimension (N)
                    184: *>          The first M elements contain the selected eigenvalues in
                    185: *>          ascending order.
                    186: *> \endverbatim
                    187: *>
                    188: *> \param[out] Z
                    189: *> \verbatim
                    190: *>          Z is DOUBLE PRECISION array, dimension (LDZ, max(1,M) )
                    191: *>          If JOBZ = 'V', and if INFO = 0, then the first M columns of Z
                    192: *>          contain the orthonormal eigenvectors of the matrix T
                    193: *>          corresponding to the selected eigenvalues, with the i-th
                    194: *>          column of Z holding the eigenvector associated with W(i).
                    195: *>          If JOBZ = 'N', then Z is not referenced.
                    196: *>          Note: the user must ensure that at least max(1,M) columns are
                    197: *>          supplied in the array Z; if RANGE = 'V', the exact value of M
                    198: *>          is not known in advance and can be computed with a workspace
                    199: *>          query by setting NZC = -1, see below.
                    200: *> \endverbatim
                    201: *>
                    202: *> \param[in] LDZ
                    203: *> \verbatim
                    204: *>          LDZ is INTEGER
                    205: *>          The leading dimension of the array Z.  LDZ >= 1, and if
                    206: *>          JOBZ = 'V', then LDZ >= max(1,N).
                    207: *> \endverbatim
                    208: *>
                    209: *> \param[in] NZC
                    210: *> \verbatim
                    211: *>          NZC is INTEGER
                    212: *>          The number of eigenvectors to be held in the array Z.
                    213: *>          If RANGE = 'A', then NZC >= max(1,N).
                    214: *>          If RANGE = 'V', then NZC >= the number of eigenvalues in (VL,VU].
                    215: *>          If RANGE = 'I', then NZC >= IU-IL+1.
                    216: *>          If NZC = -1, then a workspace query is assumed; the
                    217: *>          routine calculates the number of columns of the array Z that
                    218: *>          are needed to hold the eigenvectors.
                    219: *>          This value is returned as the first entry of the Z array, and
                    220: *>          no error message related to NZC is issued by XERBLA.
                    221: *> \endverbatim
                    222: *>
                    223: *> \param[out] ISUPPZ
                    224: *> \verbatim
1.20      bertrand  225: *>          ISUPPZ is INTEGER array, dimension ( 2*max(1,M) )
1.9       bertrand  226: *>          The support of the eigenvectors in Z, i.e., the indices
                    227: *>          indicating the nonzero elements in Z. The i-th computed eigenvector
                    228: *>          is nonzero only in elements ISUPPZ( 2*i-1 ) through
                    229: *>          ISUPPZ( 2*i ). This is relevant in the case when the matrix
                    230: *>          is split. ISUPPZ is only accessed when JOBZ is 'V' and N > 0.
                    231: *> \endverbatim
                    232: *>
                    233: *> \param[in,out] TRYRAC
                    234: *> \verbatim
                    235: *>          TRYRAC is LOGICAL
1.22      bertrand  236: *>          If TRYRAC = .TRUE., indicates that the code should check whether
1.9       bertrand  237: *>          the tridiagonal matrix defines its eigenvalues to high relative
                    238: *>          accuracy.  If so, the code uses relative-accuracy preserving
                    239: *>          algorithms that might be (a bit) slower depending on the matrix.
                    240: *>          If the matrix does not define its eigenvalues to high relative
                    241: *>          accuracy, the code can uses possibly faster algorithms.
1.22      bertrand  242: *>          If TRYRAC = .FALSE., the code is not required to guarantee
1.9       bertrand  243: *>          relatively accurate eigenvalues and can use the fastest possible
                    244: *>          techniques.
                    245: *>          On exit, a .TRUE. TRYRAC will be set to .FALSE. if the matrix
                    246: *>          does not define its eigenvalues to high relative accuracy.
                    247: *> \endverbatim
                    248: *>
                    249: *> \param[out] WORK
                    250: *> \verbatim
                    251: *>          WORK is DOUBLE PRECISION array, dimension (LWORK)
                    252: *>          On exit, if INFO = 0, WORK(1) returns the optimal
                    253: *>          (and minimal) LWORK.
                    254: *> \endverbatim
                    255: *>
                    256: *> \param[in] LWORK
                    257: *> \verbatim
                    258: *>          LWORK is INTEGER
                    259: *>          The dimension of the array WORK. LWORK >= max(1,18*N)
                    260: *>          if JOBZ = 'V', and LWORK >= max(1,12*N) if JOBZ = 'N'.
                    261: *>          If LWORK = -1, then a workspace query is assumed; the routine
                    262: *>          only calculates the optimal size of the WORK array, returns
                    263: *>          this value as the first entry of the WORK array, and no error
                    264: *>          message related to LWORK is issued by XERBLA.
                    265: *> \endverbatim
                    266: *>
                    267: *> \param[out] IWORK
                    268: *> \verbatim
                    269: *>          IWORK is INTEGER array, dimension (LIWORK)
                    270: *>          On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
                    271: *> \endverbatim
                    272: *>
                    273: *> \param[in] LIWORK
                    274: *> \verbatim
                    275: *>          LIWORK is INTEGER
                    276: *>          The dimension of the array IWORK.  LIWORK >= max(1,10*N)
                    277: *>          if the eigenvectors are desired, and LIWORK >= max(1,8*N)
                    278: *>          if only the eigenvalues are to be computed.
                    279: *>          If LIWORK = -1, then a workspace query is assumed; the
                    280: *>          routine only calculates the optimal size of the IWORK array,
                    281: *>          returns this value as the first entry of the IWORK array, and
                    282: *>          no error message related to LIWORK is issued by XERBLA.
                    283: *> \endverbatim
                    284: *>
                    285: *> \param[out] INFO
                    286: *> \verbatim
                    287: *>          INFO is INTEGER
                    288: *>          On exit, INFO
                    289: *>          = 0:  successful exit
                    290: *>          < 0:  if INFO = -i, the i-th argument had an illegal value
                    291: *>          > 0:  if INFO = 1X, internal error in DLARRE,
                    292: *>                if INFO = 2X, internal error in DLARRV.
                    293: *>                Here, the digit X = ABS( IINFO ) < 10, where IINFO is
                    294: *>                the nonzero error code returned by DLARRE or
                    295: *>                DLARRV, respectively.
                    296: *> \endverbatim
                    297: *
                    298: *  Authors:
                    299: *  ========
                    300: *
1.18      bertrand  301: *> \author Univ. of Tennessee
                    302: *> \author Univ. of California Berkeley
                    303: *> \author Univ. of Colorado Denver
                    304: *> \author NAG Ltd.
1.9       bertrand  305: *
                    306: *> \ingroup doubleOTHERcomputational
                    307: *
                    308: *> \par Contributors:
                    309: *  ==================
                    310: *>
                    311: *> Beresford Parlett, University of California, Berkeley, USA \n
                    312: *> Jim Demmel, University of California, Berkeley, USA \n
                    313: *> Inderjit Dhillon, University of Texas, Austin, USA \n
                    314: *> Osni Marques, LBNL/NERSC, USA \n
                    315: *> Christof Voemel, University of California, Berkeley, USA
                    316: *
                    317: *  =====================================================================
1.1       bertrand  318:       SUBROUTINE DSTEMR( JOBZ, RANGE, N, D, E, VL, VU, IL, IU,
                    319:      $                   M, W, Z, LDZ, NZC, ISUPPZ, TRYRAC, WORK, LWORK,
                    320:      $                   IWORK, LIWORK, INFO )
                    321: *
1.23    ! bertrand  322: *  -- LAPACK computational routine --
1.1       bertrand  323: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                    324: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
                    325: *
                    326: *     .. Scalar Arguments ..
                    327:       CHARACTER          JOBZ, RANGE
                    328:       LOGICAL            TRYRAC
                    329:       INTEGER            IL, INFO, IU, LDZ, NZC, LIWORK, LWORK, M, N
                    330:       DOUBLE PRECISION VL, VU
                    331: *     ..
                    332: *     .. Array Arguments ..
                    333:       INTEGER            ISUPPZ( * ), IWORK( * )
                    334:       DOUBLE PRECISION   D( * ), E( * ), W( * ), WORK( * )
                    335:       DOUBLE PRECISION   Z( LDZ, * )
                    336: *     ..
                    337: *
                    338: *  =====================================================================
                    339: *
                    340: *     .. Parameters ..
                    341:       DOUBLE PRECISION   ZERO, ONE, FOUR, MINRGP
                    342:       PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0,
                    343:      $                     FOUR = 4.0D0,
                    344:      $                     MINRGP = 1.0D-3 )
                    345: *     ..
                    346: *     .. Local Scalars ..
                    347:       LOGICAL            ALLEIG, INDEIG, LQUERY, VALEIG, WANTZ, ZQUERY
                    348:       INTEGER            I, IBEGIN, IEND, IFIRST, IIL, IINDBL, IINDW,
                    349:      $                   IINDWK, IINFO, IINSPL, IIU, ILAST, IN, INDD,
                    350:      $                   INDE2, INDERR, INDGP, INDGRS, INDWRK, ITMP,
                    351:      $                   ITMP2, J, JBLK, JJ, LIWMIN, LWMIN, NSPLIT,
                    352:      $                   NZCMIN, OFFSET, WBEGIN, WEND
                    353:       DOUBLE PRECISION   BIGNUM, CS, EPS, PIVMIN, R1, R2, RMAX, RMIN,
                    354:      $                   RTOL1, RTOL2, SAFMIN, SCALE, SMLNUM, SN,
                    355:      $                   THRESH, TMP, TNRM, WL, WU
                    356: *     ..
                    357: *     ..
                    358: *     .. External Functions ..
                    359:       LOGICAL            LSAME
                    360:       DOUBLE PRECISION   DLAMCH, DLANST
                    361:       EXTERNAL           LSAME, DLAMCH, DLANST
                    362: *     ..
                    363: *     .. External Subroutines ..
                    364:       EXTERNAL           DCOPY, DLAE2, DLAEV2, DLARRC, DLARRE, DLARRJ,
                    365:      $                   DLARRR, DLARRV, DLASRT, DSCAL, DSWAP, XERBLA
                    366: *     ..
                    367: *     .. Intrinsic Functions ..
                    368:       INTRINSIC          MAX, MIN, SQRT
                    369: 
                    370: 
                    371: *     ..
                    372: *     .. Executable Statements ..
                    373: *
                    374: *     Test the input parameters.
                    375: *
                    376:       WANTZ = LSAME( JOBZ, 'V' )
                    377:       ALLEIG = LSAME( RANGE, 'A' )
                    378:       VALEIG = LSAME( RANGE, 'V' )
                    379:       INDEIG = LSAME( RANGE, 'I' )
                    380: *
                    381:       LQUERY = ( ( LWORK.EQ.-1 ).OR.( LIWORK.EQ.-1 ) )
                    382:       ZQUERY = ( NZC.EQ.-1 )
                    383: 
                    384: *     DSTEMR needs WORK of size 6*N, IWORK of size 3*N.
                    385: *     In addition, DLARRE needs WORK of size 6*N, IWORK of size 5*N.
                    386: *     Furthermore, DLARRV needs WORK of size 12*N, IWORK of size 7*N.
                    387:       IF( WANTZ ) THEN
                    388:          LWMIN = 18*N
                    389:          LIWMIN = 10*N
                    390:       ELSE
                    391: *        need less workspace if only the eigenvalues are wanted
                    392:          LWMIN = 12*N
                    393:          LIWMIN = 8*N
                    394:       ENDIF
                    395: 
                    396:       WL = ZERO
                    397:       WU = ZERO
                    398:       IIL = 0
                    399:       IIU = 0
1.14      bertrand  400:       NSPLIT = 0
1.1       bertrand  401: 
                    402:       IF( VALEIG ) THEN
                    403: *        We do not reference VL, VU in the cases RANGE = 'I','A'
                    404: *        The interval (WL, WU] contains all the wanted eigenvalues.
                    405: *        It is either given by the user or computed in DLARRE.
                    406:          WL = VL
                    407:          WU = VU
                    408:       ELSEIF( INDEIG ) THEN
                    409: *        We do not reference IL, IU in the cases RANGE = 'V','A'
                    410:          IIL = IL
                    411:          IIU = IU
                    412:       ENDIF
                    413: *
                    414:       INFO = 0
                    415:       IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
                    416:          INFO = -1
                    417:       ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
                    418:          INFO = -2
                    419:       ELSE IF( N.LT.0 ) THEN
                    420:          INFO = -3
                    421:       ELSE IF( VALEIG .AND. N.GT.0 .AND. WU.LE.WL ) THEN
                    422:          INFO = -7
                    423:       ELSE IF( INDEIG .AND. ( IIL.LT.1 .OR. IIL.GT.N ) ) THEN
                    424:          INFO = -8
                    425:       ELSE IF( INDEIG .AND. ( IIU.LT.IIL .OR. IIU.GT.N ) ) THEN
                    426:          INFO = -9
                    427:       ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
                    428:          INFO = -13
                    429:       ELSE IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
                    430:          INFO = -17
                    431:       ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
                    432:          INFO = -19
                    433:       END IF
                    434: *
                    435: *     Get machine constants.
                    436: *
                    437:       SAFMIN = DLAMCH( 'Safe minimum' )
                    438:       EPS = DLAMCH( 'Precision' )
                    439:       SMLNUM = SAFMIN / EPS
                    440:       BIGNUM = ONE / SMLNUM
                    441:       RMIN = SQRT( SMLNUM )
                    442:       RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
                    443: *
                    444:       IF( INFO.EQ.0 ) THEN
                    445:          WORK( 1 ) = LWMIN
                    446:          IWORK( 1 ) = LIWMIN
                    447: *
                    448:          IF( WANTZ .AND. ALLEIG ) THEN
                    449:             NZCMIN = N
                    450:          ELSE IF( WANTZ .AND. VALEIG ) THEN
                    451:             CALL DLARRC( 'T', N, VL, VU, D, E, SAFMIN,
                    452:      $                            NZCMIN, ITMP, ITMP2, INFO )
                    453:          ELSE IF( WANTZ .AND. INDEIG ) THEN
                    454:             NZCMIN = IIU-IIL+1
                    455:          ELSE
                    456: *           WANTZ .EQ. FALSE.
                    457:             NZCMIN = 0
                    458:          ENDIF
                    459:          IF( ZQUERY .AND. INFO.EQ.0 ) THEN
                    460:             Z( 1,1 ) = NZCMIN
                    461:          ELSE IF( NZC.LT.NZCMIN .AND. .NOT.ZQUERY ) THEN
                    462:             INFO = -14
                    463:          END IF
                    464:       END IF
                    465: 
                    466:       IF( INFO.NE.0 ) THEN
                    467: *
                    468:          CALL XERBLA( 'DSTEMR', -INFO )
                    469: *
                    470:          RETURN
                    471:       ELSE IF( LQUERY .OR. ZQUERY ) THEN
                    472:          RETURN
                    473:       END IF
                    474: *
                    475: *     Handle N = 0, 1, and 2 cases immediately
                    476: *
                    477:       M = 0
                    478:       IF( N.EQ.0 )
                    479:      $   RETURN
                    480: *
                    481:       IF( N.EQ.1 ) THEN
                    482:          IF( ALLEIG .OR. INDEIG ) THEN
                    483:             M = 1
                    484:             W( 1 ) = D( 1 )
                    485:          ELSE
                    486:             IF( WL.LT.D( 1 ) .AND. WU.GE.D( 1 ) ) THEN
                    487:                M = 1
                    488:                W( 1 ) = D( 1 )
                    489:             END IF
                    490:          END IF
                    491:          IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN
                    492:             Z( 1, 1 ) = ONE
                    493:             ISUPPZ(1) = 1
                    494:             ISUPPZ(2) = 1
                    495:          END IF
                    496:          RETURN
                    497:       END IF
                    498: *
                    499:       IF( N.EQ.2 ) THEN
                    500:          IF( .NOT.WANTZ ) THEN
                    501:             CALL DLAE2( D(1), E(1), D(2), R1, R2 )
                    502:          ELSE IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN
                    503:             CALL DLAEV2( D(1), E(1), D(2), R1, R2, CS, SN )
                    504:          END IF
                    505:          IF( ALLEIG.OR.
                    506:      $      (VALEIG.AND.(R2.GT.WL).AND.
                    507:      $                  (R2.LE.WU)).OR.
                    508:      $      (INDEIG.AND.(IIL.EQ.1)) ) THEN
                    509:             M = M+1
                    510:             W( M ) = R2
                    511:             IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN
                    512:                Z( 1, M ) = -SN
                    513:                Z( 2, M ) = CS
                    514: *              Note: At most one of SN and CS can be zero.
                    515:                IF (SN.NE.ZERO) THEN
                    516:                   IF (CS.NE.ZERO) THEN
                    517:                      ISUPPZ(2*M-1) = 1
1.5       bertrand  518:                      ISUPPZ(2*M) = 2
1.1       bertrand  519:                   ELSE
                    520:                      ISUPPZ(2*M-1) = 1
1.5       bertrand  521:                      ISUPPZ(2*M) = 1
1.1       bertrand  522:                   END IF
                    523:                ELSE
                    524:                   ISUPPZ(2*M-1) = 2
                    525:                   ISUPPZ(2*M) = 2
                    526:                END IF
                    527:             ENDIF
                    528:          ENDIF
                    529:          IF( ALLEIG.OR.
                    530:      $      (VALEIG.AND.(R1.GT.WL).AND.
                    531:      $                  (R1.LE.WU)).OR.
                    532:      $      (INDEIG.AND.(IIU.EQ.2)) ) THEN
                    533:             M = M+1
                    534:             W( M ) = R1
                    535:             IF( WANTZ.AND.(.NOT.ZQUERY) ) THEN
                    536:                Z( 1, M ) = CS
                    537:                Z( 2, M ) = SN
                    538: *              Note: At most one of SN and CS can be zero.
                    539:                IF (SN.NE.ZERO) THEN
                    540:                   IF (CS.NE.ZERO) THEN
                    541:                      ISUPPZ(2*M-1) = 1
1.5       bertrand  542:                      ISUPPZ(2*M) = 2
1.1       bertrand  543:                   ELSE
                    544:                      ISUPPZ(2*M-1) = 1
1.5       bertrand  545:                      ISUPPZ(2*M) = 1
1.1       bertrand  546:                   END IF
                    547:                ELSE
                    548:                   ISUPPZ(2*M-1) = 2
                    549:                   ISUPPZ(2*M) = 2
                    550:                END IF
                    551:             ENDIF
                    552:          ENDIF
1.12      bertrand  553: 
                    554:       ELSE
1.1       bertrand  555: 
                    556: *     Continue with general N
                    557: 
1.12      bertrand  558:          INDGRS = 1
                    559:          INDERR = 2*N + 1
                    560:          INDGP = 3*N + 1
                    561:          INDD = 4*N + 1
                    562:          INDE2 = 5*N + 1
                    563:          INDWRK = 6*N + 1
                    564: *
                    565:          IINSPL = 1
                    566:          IINDBL = N + 1
                    567:          IINDW = 2*N + 1
                    568:          IINDWK = 3*N + 1
                    569: *
                    570: *        Scale matrix to allowable range, if necessary.
                    571: *        The allowable range is related to the PIVMIN parameter; see the
                    572: *        comments in DLARRD.  The preference for scaling small values
                    573: *        up is heuristic; we expect users' matrices not to be close to the
                    574: *        RMAX threshold.
                    575: *
                    576:          SCALE = ONE
                    577:          TNRM = DLANST( 'M', N, D, E )
                    578:          IF( TNRM.GT.ZERO .AND. TNRM.LT.RMIN ) THEN
                    579:             SCALE = RMIN / TNRM
                    580:          ELSE IF( TNRM.GT.RMAX ) THEN
                    581:             SCALE = RMAX / TNRM
                    582:          END IF
                    583:          IF( SCALE.NE.ONE ) THEN
                    584:             CALL DSCAL( N, SCALE, D, 1 )
                    585:             CALL DSCAL( N-1, SCALE, E, 1 )
                    586:             TNRM = TNRM*SCALE
                    587:             IF( VALEIG ) THEN
                    588: *              If eigenvalues in interval have to be found,
                    589: *              scale (WL, WU] accordingly
                    590:                WL = WL*SCALE
                    591:                WU = WU*SCALE
                    592:             ENDIF
                    593:          END IF
                    594: *
                    595: *        Compute the desired eigenvalues of the tridiagonal after splitting
                    596: *        into smaller subblocks if the corresponding off-diagonal elements
                    597: *        are small
                    598: *        THRESH is the splitting parameter for DLARRE
                    599: *        A negative THRESH forces the old splitting criterion based on the
                    600: *        size of the off-diagonal. A positive THRESH switches to splitting
                    601: *        which preserves relative accuracy.
                    602: *
                    603:          IF( TRYRAC ) THEN
                    604: *           Test whether the matrix warrants the more expensive relative approach.
                    605:             CALL DLARRR( N, D, E, IINFO )
                    606:          ELSE
                    607: *           The user does not care about relative accurately eigenvalues
                    608:             IINFO = -1
                    609:          ENDIF
                    610: *        Set the splitting criterion
                    611:          IF (IINFO.EQ.0) THEN
                    612:             THRESH = EPS
                    613:          ELSE
                    614:             THRESH = -EPS
                    615: *           relative accuracy is desired but T does not guarantee it
                    616:             TRYRAC = .FALSE.
1.1       bertrand  617:          ENDIF
                    618: *
1.12      bertrand  619:          IF( TRYRAC ) THEN
                    620: *           Copy original diagonal, needed to guarantee relative accuracy
                    621:             CALL DCOPY(N,D,1,WORK(INDD),1)
                    622:          ENDIF
                    623: *        Store the squares of the offdiagonal values of T
                    624:          DO 5 J = 1, N-1
                    625:             WORK( INDE2+J-1 ) = E(J)**2
                    626:  5       CONTINUE
                    627: 
                    628: *        Set the tolerance parameters for bisection
                    629:          IF( .NOT.WANTZ ) THEN
                    630: *           DLARRE computes the eigenvalues to full precision.
                    631:             RTOL1 = FOUR * EPS
                    632:             RTOL2 = FOUR * EPS
                    633:          ELSE
                    634: *           DLARRE computes the eigenvalues to less than full precision.
                    635: *           DLARRV will refine the eigenvalue approximations, and we can
                    636: *           need less accurate initial bisection in DLARRE.
                    637: *           Note: these settings do only affect the subset case and DLARRE
                    638:             RTOL1 = SQRT(EPS)
                    639:             RTOL2 = MAX( SQRT(EPS)*5.0D-3, FOUR * EPS )
                    640:          ENDIF
                    641:          CALL DLARRE( RANGE, N, WL, WU, IIL, IIU, D, E,
1.1       bertrand  642:      $             WORK(INDE2), RTOL1, RTOL2, THRESH, NSPLIT,
                    643:      $             IWORK( IINSPL ), M, W, WORK( INDERR ),
                    644:      $             WORK( INDGP ), IWORK( IINDBL ),
                    645:      $             IWORK( IINDW ), WORK( INDGRS ), PIVMIN,
                    646:      $             WORK( INDWRK ), IWORK( IINDWK ), IINFO )
1.12      bertrand  647:          IF( IINFO.NE.0 ) THEN
                    648:             INFO = 10 + ABS( IINFO )
                    649:             RETURN
                    650:          END IF
                    651: *        Note that if RANGE .NE. 'V', DLARRE computes bounds on the desired
                    652: *        part of the spectrum. All desired eigenvalues are contained in
                    653: *        (WL,WU]
1.1       bertrand  654: 
                    655: 
1.12      bertrand  656:          IF( WANTZ ) THEN
1.1       bertrand  657: *
1.12      bertrand  658: *           Compute the desired eigenvectors corresponding to the computed
                    659: *           eigenvalues
1.1       bertrand  660: *
1.12      bertrand  661:             CALL DLARRV( N, WL, WU, D, E,
1.1       bertrand  662:      $                PIVMIN, IWORK( IINSPL ), M,
                    663:      $                1, M, MINRGP, RTOL1, RTOL2,
                    664:      $                W, WORK( INDERR ), WORK( INDGP ), IWORK( IINDBL ),
                    665:      $                IWORK( IINDW ), WORK( INDGRS ), Z, LDZ,
                    666:      $                ISUPPZ, WORK( INDWRK ), IWORK( IINDWK ), IINFO )
1.12      bertrand  667:             IF( IINFO.NE.0 ) THEN
                    668:                INFO = 20 + ABS( IINFO )
                    669:                RETURN
                    670:             END IF
                    671:          ELSE
                    672: *           DLARRE computes eigenvalues of the (shifted) root representation
                    673: *           DLARRV returns the eigenvalues of the unshifted matrix.
                    674: *           However, if the eigenvectors are not desired by the user, we need
                    675: *           to apply the corresponding shifts from DLARRE to obtain the
                    676: *           eigenvalues of the original matrix.
                    677:             DO 20 J = 1, M
                    678:                ITMP = IWORK( IINDBL+J-1 )
                    679:                W( J ) = W( J ) + E( IWORK( IINSPL+ITMP-1 ) )
                    680:  20         CONTINUE
1.1       bertrand  681:          END IF
                    682: *
                    683: 
1.12      bertrand  684:          IF ( TRYRAC ) THEN
                    685: *           Refine computed eigenvalues so that they are relatively accurate
                    686: *           with respect to the original matrix T.
                    687:             IBEGIN = 1
                    688:             WBEGIN = 1
                    689:             DO 39  JBLK = 1, IWORK( IINDBL+M-1 )
                    690:                IEND = IWORK( IINSPL+JBLK-1 )
                    691:                IN = IEND - IBEGIN + 1
                    692:                WEND = WBEGIN - 1
                    693: *              check if any eigenvalues have to be refined in this block
                    694:  36            CONTINUE
                    695:                IF( WEND.LT.M ) THEN
                    696:                   IF( IWORK( IINDBL+WEND ).EQ.JBLK ) THEN
                    697:                      WEND = WEND + 1
                    698:                      GO TO 36
                    699:                   END IF
                    700:                END IF
                    701:                IF( WEND.LT.WBEGIN ) THEN
                    702:                   IBEGIN = IEND + 1
                    703:                   GO TO 39
1.1       bertrand  704:                END IF
                    705: 
1.12      bertrand  706:                OFFSET = IWORK(IINDW+WBEGIN-1)-1
                    707:                IFIRST = IWORK(IINDW+WBEGIN-1)
                    708:                ILAST = IWORK(IINDW+WEND-1)
                    709:                RTOL2 = FOUR * EPS
                    710:                CALL DLARRJ( IN,
1.1       bertrand  711:      $                   WORK(INDD+IBEGIN-1), WORK(INDE2+IBEGIN-1),
                    712:      $                   IFIRST, ILAST, RTOL2, OFFSET, W(WBEGIN),
                    713:      $                   WORK( INDERR+WBEGIN-1 ),
                    714:      $                   WORK( INDWRK ), IWORK( IINDWK ), PIVMIN,
                    715:      $                   TNRM, IINFO )
1.12      bertrand  716:                IBEGIN = IEND + 1
                    717:                WBEGIN = WEND + 1
                    718:  39         CONTINUE
                    719:          ENDIF
1.1       bertrand  720: *
1.12      bertrand  721: *        If matrix was scaled, then rescale eigenvalues appropriately.
1.1       bertrand  722: *
1.12      bertrand  723:          IF( SCALE.NE.ONE ) THEN
                    724:             CALL DSCAL( M, ONE / SCALE, W, 1 )
                    725:          END IF
1.18      bertrand  726: 
1.1       bertrand  727:       END IF
1.18      bertrand  728: 
1.1       bertrand  729: *
                    730: *     If eigenvalues are not in increasing order, then sort them,
                    731: *     possibly along with eigenvectors.
                    732: *
1.12      bertrand  733:       IF( NSPLIT.GT.1 .OR. N.EQ.2 ) THEN
1.1       bertrand  734:          IF( .NOT. WANTZ ) THEN
                    735:             CALL DLASRT( 'I', M, W, IINFO )
                    736:             IF( IINFO.NE.0 ) THEN
                    737:                INFO = 3
                    738:                RETURN
                    739:             END IF
                    740:          ELSE
                    741:             DO 60 J = 1, M - 1
                    742:                I = 0
                    743:                TMP = W( J )
                    744:                DO 50 JJ = J + 1, M
                    745:                   IF( W( JJ ).LT.TMP ) THEN
                    746:                      I = JJ
                    747:                      TMP = W( JJ )
                    748:                   END IF
                    749:  50            CONTINUE
                    750:                IF( I.NE.0 ) THEN
                    751:                   W( I ) = W( J )
                    752:                   W( J ) = TMP
                    753:                   IF( WANTZ ) THEN
                    754:                      CALL DSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
                    755:                      ITMP = ISUPPZ( 2*I-1 )
                    756:                      ISUPPZ( 2*I-1 ) = ISUPPZ( 2*J-1 )
                    757:                      ISUPPZ( 2*J-1 ) = ITMP
                    758:                      ITMP = ISUPPZ( 2*I )
                    759:                      ISUPPZ( 2*I ) = ISUPPZ( 2*J )
                    760:                      ISUPPZ( 2*J ) = ITMP
                    761:                   END IF
                    762:                END IF
                    763:  60         CONTINUE
                    764:          END IF
                    765:       ENDIF
                    766: *
                    767: *
                    768:       WORK( 1 ) = LWMIN
                    769:       IWORK( 1 ) = LIWMIN
                    770:       RETURN
                    771: *
                    772: *     End of DSTEMR
                    773: *
                    774:       END

CVSweb interface <joel.bertrand@systella.fr>