File:  [local] / rpl / lapack / lapack / dspevx.f
Revision 1.11: download - view: text, annotated - select for diffs - revision graph
Fri Dec 14 14:22:39 2012 UTC (11 years, 5 months ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_16, rpl-4_1_15, rpl-4_1_14, rpl-4_1_13, rpl-4_1_12, rpl-4_1_11, HEAD
Mise à jour de lapack.

    1: *> \brief <b> DSPEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b>
    2: *
    3: *  =========== DOCUMENTATION ===========
    4: *
    5: * Online html documentation available at 
    6: *            http://www.netlib.org/lapack/explore-html/ 
    7: *
    8: *> \htmlonly
    9: *> Download DSPEVX + dependencies 
   10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dspevx.f"> 
   11: *> [TGZ]</a> 
   12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dspevx.f"> 
   13: *> [ZIP]</a> 
   14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dspevx.f"> 
   15: *> [TXT]</a>
   16: *> \endhtmlonly 
   17: *
   18: *  Definition:
   19: *  ===========
   20: *
   21: *       SUBROUTINE DSPEVX( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU,
   22: *                          ABSTOL, M, W, Z, LDZ, WORK, IWORK, IFAIL,
   23: *                          INFO )
   24:    25: *       .. Scalar Arguments ..
   26: *       CHARACTER          JOBZ, RANGE, UPLO
   27: *       INTEGER            IL, INFO, IU, LDZ, M, N
   28: *       DOUBLE PRECISION   ABSTOL, VL, VU
   29: *       ..
   30: *       .. Array Arguments ..
   31: *       INTEGER            IFAIL( * ), IWORK( * )
   32: *       DOUBLE PRECISION   AP( * ), W( * ), WORK( * ), Z( LDZ, * )
   33: *       ..
   34: *  
   35: *
   36: *> \par Purpose:
   37: *  =============
   38: *>
   39: *> \verbatim
   40: *>
   41: *> DSPEVX computes selected eigenvalues and, optionally, eigenvectors
   42: *> of a real symmetric matrix A in packed storage.  Eigenvalues/vectors
   43: *> can be selected by specifying either a range of values or a range of
   44: *> indices for the desired eigenvalues.
   45: *> \endverbatim
   46: *
   47: *  Arguments:
   48: *  ==========
   49: *
   50: *> \param[in] JOBZ
   51: *> \verbatim
   52: *>          JOBZ is CHARACTER*1
   53: *>          = 'N':  Compute eigenvalues only;
   54: *>          = 'V':  Compute eigenvalues and eigenvectors.
   55: *> \endverbatim
   56: *>
   57: *> \param[in] RANGE
   58: *> \verbatim
   59: *>          RANGE is CHARACTER*1
   60: *>          = 'A': all eigenvalues will be found;
   61: *>          = 'V': all eigenvalues in the half-open interval (VL,VU]
   62: *>                 will be found;
   63: *>          = 'I': the IL-th through IU-th eigenvalues will be found.
   64: *> \endverbatim
   65: *>
   66: *> \param[in] UPLO
   67: *> \verbatim
   68: *>          UPLO is CHARACTER*1
   69: *>          = 'U':  Upper triangle of A is stored;
   70: *>          = 'L':  Lower triangle of A is stored.
   71: *> \endverbatim
   72: *>
   73: *> \param[in] N
   74: *> \verbatim
   75: *>          N is INTEGER
   76: *>          The order of the matrix A.  N >= 0.
   77: *> \endverbatim
   78: *>
   79: *> \param[in,out] AP
   80: *> \verbatim
   81: *>          AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
   82: *>          On entry, the upper or lower triangle of the symmetric matrix
   83: *>          A, packed columnwise in a linear array.  The j-th column of A
   84: *>          is stored in the array AP as follows:
   85: *>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
   86: *>          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
   87: *>
   88: *>          On exit, AP is overwritten by values generated during the
   89: *>          reduction to tridiagonal form.  If UPLO = 'U', the diagonal
   90: *>          and first superdiagonal of the tridiagonal matrix T overwrite
   91: *>          the corresponding elements of A, and if UPLO = 'L', the
   92: *>          diagonal and first subdiagonal of T overwrite the
   93: *>          corresponding elements of A.
   94: *> \endverbatim
   95: *>
   96: *> \param[in] VL
   97: *> \verbatim
   98: *>          VL is DOUBLE PRECISION
   99: *> \endverbatim
  100: *>
  101: *> \param[in] VU
  102: *> \verbatim
  103: *>          VU is DOUBLE PRECISION
  104: *>          If RANGE='V', the lower and upper bounds of the interval to
  105: *>          be searched for eigenvalues. VL < VU.
  106: *>          Not referenced if RANGE = 'A' or 'I'.
  107: *> \endverbatim
  108: *>
  109: *> \param[in] IL
  110: *> \verbatim
  111: *>          IL is INTEGER
  112: *> \endverbatim
  113: *>
  114: *> \param[in] IU
  115: *> \verbatim
  116: *>          IU is INTEGER
  117: *>          If RANGE='I', the indices (in ascending order) of the
  118: *>          smallest and largest eigenvalues to be returned.
  119: *>          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  120: *>          Not referenced if RANGE = 'A' or 'V'.
  121: *> \endverbatim
  122: *>
  123: *> \param[in] ABSTOL
  124: *> \verbatim
  125: *>          ABSTOL is DOUBLE PRECISION
  126: *>          The absolute error tolerance for the eigenvalues.
  127: *>          An approximate eigenvalue is accepted as converged
  128: *>          when it is determined to lie in an interval [a,b]
  129: *>          of width less than or equal to
  130: *>
  131: *>                  ABSTOL + EPS *   max( |a|,|b| ) ,
  132: *>
  133: *>          where EPS is the machine precision.  If ABSTOL is less than
  134: *>          or equal to zero, then  EPS*|T|  will be used in its place,
  135: *>          where |T| is the 1-norm of the tridiagonal matrix obtained
  136: *>          by reducing AP to tridiagonal form.
  137: *>
  138: *>          Eigenvalues will be computed most accurately when ABSTOL is
  139: *>          set to twice the underflow threshold 2*DLAMCH('S'), not zero.
  140: *>          If this routine returns with INFO>0, indicating that some
  141: *>          eigenvectors did not converge, try setting ABSTOL to
  142: *>          2*DLAMCH('S').
  143: *>
  144: *>          See "Computing Small Singular Values of Bidiagonal Matrices
  145: *>          with Guaranteed High Relative Accuracy," by Demmel and
  146: *>          Kahan, LAPACK Working Note #3.
  147: *> \endverbatim
  148: *>
  149: *> \param[out] M
  150: *> \verbatim
  151: *>          M is INTEGER
  152: *>          The total number of eigenvalues found.  0 <= M <= N.
  153: *>          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  154: *> \endverbatim
  155: *>
  156: *> \param[out] W
  157: *> \verbatim
  158: *>          W is DOUBLE PRECISION array, dimension (N)
  159: *>          If INFO = 0, the selected eigenvalues in ascending order.
  160: *> \endverbatim
  161: *>
  162: *> \param[out] Z
  163: *> \verbatim
  164: *>          Z is DOUBLE PRECISION array, dimension (LDZ, max(1,M))
  165: *>          If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  166: *>          contain the orthonormal eigenvectors of the matrix A
  167: *>          corresponding to the selected eigenvalues, with the i-th
  168: *>          column of Z holding the eigenvector associated with W(i).
  169: *>          If an eigenvector fails to converge, then that column of Z
  170: *>          contains the latest approximation to the eigenvector, and the
  171: *>          index of the eigenvector is returned in IFAIL.
  172: *>          If JOBZ = 'N', then Z is not referenced.
  173: *>          Note: the user must ensure that at least max(1,M) columns are
  174: *>          supplied in the array Z; if RANGE = 'V', the exact value of M
  175: *>          is not known in advance and an upper bound must be used.
  176: *> \endverbatim
  177: *>
  178: *> \param[in] LDZ
  179: *> \verbatim
  180: *>          LDZ is INTEGER
  181: *>          The leading dimension of the array Z.  LDZ >= 1, and if
  182: *>          JOBZ = 'V', LDZ >= max(1,N).
  183: *> \endverbatim
  184: *>
  185: *> \param[out] WORK
  186: *> \verbatim
  187: *>          WORK is DOUBLE PRECISION array, dimension (8*N)
  188: *> \endverbatim
  189: *>
  190: *> \param[out] IWORK
  191: *> \verbatim
  192: *>          IWORK is INTEGER array, dimension (5*N)
  193: *> \endverbatim
  194: *>
  195: *> \param[out] IFAIL
  196: *> \verbatim
  197: *>          IFAIL is INTEGER array, dimension (N)
  198: *>          If JOBZ = 'V', then if INFO = 0, the first M elements of
  199: *>          IFAIL are zero.  If INFO > 0, then IFAIL contains the
  200: *>          indices of the eigenvectors that failed to converge.
  201: *>          If JOBZ = 'N', then IFAIL is not referenced.
  202: *> \endverbatim
  203: *>
  204: *> \param[out] INFO
  205: *> \verbatim
  206: *>          INFO is INTEGER
  207: *>          = 0:  successful exit
  208: *>          < 0:  if INFO = -i, the i-th argument had an illegal value
  209: *>          > 0:  if INFO = i, then i eigenvectors failed to converge.
  210: *>                Their indices are stored in array IFAIL.
  211: *> \endverbatim
  212: *
  213: *  Authors:
  214: *  ========
  215: *
  216: *> \author Univ. of Tennessee 
  217: *> \author Univ. of California Berkeley 
  218: *> \author Univ. of Colorado Denver 
  219: *> \author NAG Ltd. 
  220: *
  221: *> \date November 2011
  222: *
  223: *> \ingroup doubleOTHEReigen
  224: *
  225: *  =====================================================================
  226:       SUBROUTINE DSPEVX( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU,
  227:      $                   ABSTOL, M, W, Z, LDZ, WORK, IWORK, IFAIL,
  228:      $                   INFO )
  229: *
  230: *  -- LAPACK driver routine (version 3.4.0) --
  231: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
  232: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  233: *     November 2011
  234: *
  235: *     .. Scalar Arguments ..
  236:       CHARACTER          JOBZ, RANGE, UPLO
  237:       INTEGER            IL, INFO, IU, LDZ, M, N
  238:       DOUBLE PRECISION   ABSTOL, VL, VU
  239: *     ..
  240: *     .. Array Arguments ..
  241:       INTEGER            IFAIL( * ), IWORK( * )
  242:       DOUBLE PRECISION   AP( * ), W( * ), WORK( * ), Z( LDZ, * )
  243: *     ..
  244: *
  245: *  =====================================================================
  246: *
  247: *     .. Parameters ..
  248:       DOUBLE PRECISION   ZERO, ONE
  249:       PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
  250: *     ..
  251: *     .. Local Scalars ..
  252:       LOGICAL            ALLEIG, INDEIG, TEST, VALEIG, WANTZ
  253:       CHARACTER          ORDER
  254:       INTEGER            I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL,
  255:      $                   INDISP, INDIWO, INDTAU, INDWRK, ISCALE, ITMP1,
  256:      $                   J, JJ, NSPLIT
  257:       DOUBLE PRECISION   ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
  258:      $                   SIGMA, SMLNUM, TMP1, VLL, VUU
  259: *     ..
  260: *     .. External Functions ..
  261:       LOGICAL            LSAME
  262:       DOUBLE PRECISION   DLAMCH, DLANSP
  263:       EXTERNAL           LSAME, DLAMCH, DLANSP
  264: *     ..
  265: *     .. External Subroutines ..
  266:       EXTERNAL           DCOPY, DOPGTR, DOPMTR, DSCAL, DSPTRD, DSTEBZ,
  267:      $                   DSTEIN, DSTEQR, DSTERF, DSWAP, XERBLA
  268: *     ..
  269: *     .. Intrinsic Functions ..
  270:       INTRINSIC          MAX, MIN, SQRT
  271: *     ..
  272: *     .. Executable Statements ..
  273: *
  274: *     Test the input parameters.
  275: *
  276:       WANTZ = LSAME( JOBZ, 'V' )
  277:       ALLEIG = LSAME( RANGE, 'A' )
  278:       VALEIG = LSAME( RANGE, 'V' )
  279:       INDEIG = LSAME( RANGE, 'I' )
  280: *
  281:       INFO = 0
  282:       IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
  283:          INFO = -1
  284:       ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
  285:          INFO = -2
  286:       ELSE IF( .NOT.( LSAME( UPLO, 'L' ) .OR. LSAME( UPLO, 'U' ) ) )
  287:      $          THEN
  288:          INFO = -3
  289:       ELSE IF( N.LT.0 ) THEN
  290:          INFO = -4
  291:       ELSE
  292:          IF( VALEIG ) THEN
  293:             IF( N.GT.0 .AND. VU.LE.VL )
  294:      $         INFO = -7
  295:          ELSE IF( INDEIG ) THEN
  296:             IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
  297:                INFO = -8
  298:             ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
  299:                INFO = -9
  300:             END IF
  301:          END IF
  302:       END IF
  303:       IF( INFO.EQ.0 ) THEN
  304:          IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) )
  305:      $      INFO = -14
  306:       END IF
  307: *
  308:       IF( INFO.NE.0 ) THEN
  309:          CALL XERBLA( 'DSPEVX', -INFO )
  310:          RETURN
  311:       END IF
  312: *
  313: *     Quick return if possible
  314: *
  315:       M = 0
  316:       IF( N.EQ.0 )
  317:      $   RETURN
  318: *
  319:       IF( N.EQ.1 ) THEN
  320:          IF( ALLEIG .OR. INDEIG ) THEN
  321:             M = 1
  322:             W( 1 ) = AP( 1 )
  323:          ELSE
  324:             IF( VL.LT.AP( 1 ) .AND. VU.GE.AP( 1 ) ) THEN
  325:                M = 1
  326:                W( 1 ) = AP( 1 )
  327:             END IF
  328:          END IF
  329:          IF( WANTZ )
  330:      $      Z( 1, 1 ) = ONE
  331:          RETURN
  332:       END IF
  333: *
  334: *     Get machine constants.
  335: *
  336:       SAFMIN = DLAMCH( 'Safe minimum' )
  337:       EPS = DLAMCH( 'Precision' )
  338:       SMLNUM = SAFMIN / EPS
  339:       BIGNUM = ONE / SMLNUM
  340:       RMIN = SQRT( SMLNUM )
  341:       RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
  342: *
  343: *     Scale matrix to allowable range, if necessary.
  344: *
  345:       ISCALE = 0
  346:       ABSTLL = ABSTOL
  347:       IF( VALEIG ) THEN
  348:          VLL = VL
  349:          VUU = VU
  350:       ELSE
  351:          VLL = ZERO
  352:          VUU = ZERO
  353:       END IF
  354:       ANRM = DLANSP( 'M', UPLO, N, AP, WORK )
  355:       IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
  356:          ISCALE = 1
  357:          SIGMA = RMIN / ANRM
  358:       ELSE IF( ANRM.GT.RMAX ) THEN
  359:          ISCALE = 1
  360:          SIGMA = RMAX / ANRM
  361:       END IF
  362:       IF( ISCALE.EQ.1 ) THEN
  363:          CALL DSCAL( ( N*( N+1 ) ) / 2, SIGMA, AP, 1 )
  364:          IF( ABSTOL.GT.0 )
  365:      $      ABSTLL = ABSTOL*SIGMA
  366:          IF( VALEIG ) THEN
  367:             VLL = VL*SIGMA
  368:             VUU = VU*SIGMA
  369:          END IF
  370:       END IF
  371: *
  372: *     Call DSPTRD to reduce symmetric packed matrix to tridiagonal form.
  373: *
  374:       INDTAU = 1
  375:       INDE = INDTAU + N
  376:       INDD = INDE + N
  377:       INDWRK = INDD + N
  378:       CALL DSPTRD( UPLO, N, AP, WORK( INDD ), WORK( INDE ),
  379:      $             WORK( INDTAU ), IINFO )
  380: *
  381: *     If all eigenvalues are desired and ABSTOL is less than or equal
  382: *     to zero, then call DSTERF or DOPGTR and SSTEQR.  If this fails
  383: *     for some eigenvalue, then try DSTEBZ.
  384: *
  385:       TEST = .FALSE.
  386:       IF (INDEIG) THEN
  387:          IF (IL.EQ.1 .AND. IU.EQ.N) THEN
  388:             TEST = .TRUE.
  389:          END IF
  390:       END IF
  391:       IF ((ALLEIG .OR. TEST) .AND. (ABSTOL.LE.ZERO)) THEN
  392:          CALL DCOPY( N, WORK( INDD ), 1, W, 1 )
  393:          INDEE = INDWRK + 2*N
  394:          IF( .NOT.WANTZ ) THEN
  395:             CALL DCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
  396:             CALL DSTERF( N, W, WORK( INDEE ), INFO )
  397:          ELSE
  398:             CALL DOPGTR( UPLO, N, AP, WORK( INDTAU ), Z, LDZ,
  399:      $                   WORK( INDWRK ), IINFO )
  400:             CALL DCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
  401:             CALL DSTEQR( JOBZ, N, W, WORK( INDEE ), Z, LDZ,
  402:      $                   WORK( INDWRK ), INFO )
  403:             IF( INFO.EQ.0 ) THEN
  404:                DO 10 I = 1, N
  405:                   IFAIL( I ) = 0
  406:    10          CONTINUE
  407:             END IF
  408:          END IF
  409:          IF( INFO.EQ.0 ) THEN
  410:             M = N
  411:             GO TO 20
  412:          END IF
  413:          INFO = 0
  414:       END IF
  415: *
  416: *     Otherwise, call DSTEBZ and, if eigenvectors are desired, SSTEIN.
  417: *
  418:       IF( WANTZ ) THEN
  419:          ORDER = 'B'
  420:       ELSE
  421:          ORDER = 'E'
  422:       END IF
  423:       INDIBL = 1
  424:       INDISP = INDIBL + N
  425:       INDIWO = INDISP + N
  426:       CALL DSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL,
  427:      $             WORK( INDD ), WORK( INDE ), M, NSPLIT, W,
  428:      $             IWORK( INDIBL ), IWORK( INDISP ), WORK( INDWRK ),
  429:      $             IWORK( INDIWO ), INFO )
  430: *
  431:       IF( WANTZ ) THEN
  432:          CALL DSTEIN( N, WORK( INDD ), WORK( INDE ), M, W,
  433:      $                IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
  434:      $                WORK( INDWRK ), IWORK( INDIWO ), IFAIL, INFO )
  435: *
  436: *        Apply orthogonal matrix used in reduction to tridiagonal
  437: *        form to eigenvectors returned by DSTEIN.
  438: *
  439:          CALL DOPMTR( 'L', UPLO, 'N', N, M, AP, WORK( INDTAU ), Z, LDZ,
  440:      $                WORK( INDWRK ), IINFO )
  441:       END IF
  442: *
  443: *     If matrix was scaled, then rescale eigenvalues appropriately.
  444: *
  445:    20 CONTINUE
  446:       IF( ISCALE.EQ.1 ) THEN
  447:          IF( INFO.EQ.0 ) THEN
  448:             IMAX = M
  449:          ELSE
  450:             IMAX = INFO - 1
  451:          END IF
  452:          CALL DSCAL( IMAX, ONE / SIGMA, W, 1 )
  453:       END IF
  454: *
  455: *     If eigenvalues are not in order, then sort them, along with
  456: *     eigenvectors.
  457: *
  458:       IF( WANTZ ) THEN
  459:          DO 40 J = 1, M - 1
  460:             I = 0
  461:             TMP1 = W( J )
  462:             DO 30 JJ = J + 1, M
  463:                IF( W( JJ ).LT.TMP1 ) THEN
  464:                   I = JJ
  465:                   TMP1 = W( JJ )
  466:                END IF
  467:    30       CONTINUE
  468: *
  469:             IF( I.NE.0 ) THEN
  470:                ITMP1 = IWORK( INDIBL+I-1 )
  471:                W( I ) = W( J )
  472:                IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
  473:                W( J ) = TMP1
  474:                IWORK( INDIBL+J-1 ) = ITMP1
  475:                CALL DSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
  476:                IF( INFO.NE.0 ) THEN
  477:                   ITMP1 = IFAIL( I )
  478:                   IFAIL( I ) = IFAIL( J )
  479:                   IFAIL( J ) = ITMP1
  480:                END IF
  481:             END IF
  482:    40    CONTINUE
  483:       END IF
  484: *
  485:       RETURN
  486: *
  487: *     End of DSPEVX
  488: *
  489:       END

CVSweb interface <joel.bertrand@systella.fr>