File:  [local] / rpl / lapack / lapack / zstemr.f
Revision 1.23: download - view: text, annotated - select for diffs - revision graph
Mon Aug 7 08:39:37 2023 UTC (8 months, 3 weeks ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_35, rpl-4_1_34, HEAD
Première mise à jour de lapack et blas.

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

CVSweb interface <joel.bertrand@systella.fr>