File:  [local] / rpl / lapack / lapack / dstemr.f
Revision 1.14: download - view: text, annotated - select for diffs - revision graph
Mon Jan 27 09:24:35 2014 UTC (10 years, 4 months ago) by bertrand
Branches: MAIN
CVS tags: HEAD
Mise à jour de lapack vers la version 3.5.0.

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

CVSweb interface <joel.bertrand@systella.fr>