LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
ssbevx.f
Go to the documentation of this file.
00001 *> \brief <b> SSBEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b>
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download SSBEVX + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssbevx.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssbevx.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssbevx.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE SSBEVX( JOBZ, RANGE, UPLO, N, KD, AB, LDAB, Q, LDQ, VL,
00022 *                          VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, IWORK,
00023 *                          IFAIL, INFO )
00024 * 
00025 *       .. Scalar Arguments ..
00026 *       CHARACTER          JOBZ, RANGE, UPLO
00027 *       INTEGER            IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N
00028 *       REAL               ABSTOL, VL, VU
00029 *       ..
00030 *       .. Array Arguments ..
00031 *       INTEGER            IFAIL( * ), IWORK( * )
00032 *       REAL               AB( LDAB, * ), Q( LDQ, * ), W( * ), WORK( * ),
00033 *      $                   Z( LDZ, * )
00034 *       ..
00035 *  
00036 *
00037 *> \par Purpose:
00038 *  =============
00039 *>
00040 *> \verbatim
00041 *>
00042 *> SSBEVX computes selected eigenvalues and, optionally, eigenvectors
00043 *> of a real symmetric band matrix A.  Eigenvalues and eigenvectors can
00044 *> be selected by specifying either a range of values or a range of
00045 *> indices for the desired eigenvalues.
00046 *> \endverbatim
00047 *
00048 *  Arguments:
00049 *  ==========
00050 *
00051 *> \param[in] JOBZ
00052 *> \verbatim
00053 *>          JOBZ is CHARACTER*1
00054 *>          = 'N':  Compute eigenvalues only;
00055 *>          = 'V':  Compute eigenvalues and eigenvectors.
00056 *> \endverbatim
00057 *>
00058 *> \param[in] RANGE
00059 *> \verbatim
00060 *>          RANGE is CHARACTER*1
00061 *>          = 'A': all eigenvalues will be found;
00062 *>          = 'V': all eigenvalues in the half-open interval (VL,VU]
00063 *>                 will be found;
00064 *>          = 'I': the IL-th through IU-th eigenvalues will be found.
00065 *> \endverbatim
00066 *>
00067 *> \param[in] UPLO
00068 *> \verbatim
00069 *>          UPLO is CHARACTER*1
00070 *>          = 'U':  Upper triangle of A is stored;
00071 *>          = 'L':  Lower triangle of A is stored.
00072 *> \endverbatim
00073 *>
00074 *> \param[in] N
00075 *> \verbatim
00076 *>          N is INTEGER
00077 *>          The order of the matrix A.  N >= 0.
00078 *> \endverbatim
00079 *>
00080 *> \param[in] KD
00081 *> \verbatim
00082 *>          KD is INTEGER
00083 *>          The number of superdiagonals of the matrix A if UPLO = 'U',
00084 *>          or the number of subdiagonals if UPLO = 'L'.  KD >= 0.
00085 *> \endverbatim
00086 *>
00087 *> \param[in,out] AB
00088 *> \verbatim
00089 *>          AB is REAL array, dimension (LDAB, N)
00090 *>          On entry, the upper or lower triangle of the symmetric band
00091 *>          matrix A, stored in the first KD+1 rows of the array.  The
00092 *>          j-th column of A is stored in the j-th column of the array AB
00093 *>          as follows:
00094 *>          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
00095 *>          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
00096 *>
00097 *>          On exit, AB is overwritten by values generated during the
00098 *>          reduction to tridiagonal form.  If UPLO = 'U', the first
00099 *>          superdiagonal and the diagonal of the tridiagonal matrix T
00100 *>          are returned in rows KD and KD+1 of AB, and if UPLO = 'L',
00101 *>          the diagonal and first subdiagonal of T are returned in the
00102 *>          first two rows of AB.
00103 *> \endverbatim
00104 *>
00105 *> \param[in] LDAB
00106 *> \verbatim
00107 *>          LDAB is INTEGER
00108 *>          The leading dimension of the array AB.  LDAB >= KD + 1.
00109 *> \endverbatim
00110 *>
00111 *> \param[out] Q
00112 *> \verbatim
00113 *>          Q is REAL array, dimension (LDQ, N)
00114 *>          If JOBZ = 'V', the N-by-N orthogonal matrix used in the
00115 *>                         reduction to tridiagonal form.
00116 *>          If JOBZ = 'N', the array Q is not referenced.
00117 *> \endverbatim
00118 *>
00119 *> \param[in] LDQ
00120 *> \verbatim
00121 *>          LDQ is INTEGER
00122 *>          The leading dimension of the array Q.  If JOBZ = 'V', then
00123 *>          LDQ >= max(1,N).
00124 *> \endverbatim
00125 *>
00126 *> \param[in] VL
00127 *> \verbatim
00128 *>          VL is REAL
00129 *> \endverbatim
00130 *>
00131 *> \param[in] VU
00132 *> \verbatim
00133 *>          VU is REAL
00134 *>          If RANGE='V', the lower and upper bounds of the interval to
00135 *>          be searched for eigenvalues. VL < VU.
00136 *>          Not referenced if RANGE = 'A' or 'I'.
00137 *> \endverbatim
00138 *>
00139 *> \param[in] IL
00140 *> \verbatim
00141 *>          IL is INTEGER
00142 *> \endverbatim
00143 *>
00144 *> \param[in] IU
00145 *> \verbatim
00146 *>          IU is INTEGER
00147 *>          If RANGE='I', the indices (in ascending order) of the
00148 *>          smallest and largest eigenvalues to be returned.
00149 *>          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
00150 *>          Not referenced if RANGE = 'A' or 'V'.
00151 *> \endverbatim
00152 *>
00153 *> \param[in] ABSTOL
00154 *> \verbatim
00155 *>          ABSTOL is REAL
00156 *>          The absolute error tolerance for the eigenvalues.
00157 *>          An approximate eigenvalue is accepted as converged
00158 *>          when it is determined to lie in an interval [a,b]
00159 *>          of width less than or equal to
00160 *>
00161 *>                  ABSTOL + EPS *   max( |a|,|b| ) ,
00162 *>
00163 *>          where EPS is the machine precision.  If ABSTOL is less than
00164 *>          or equal to zero, then  EPS*|T|  will be used in its place,
00165 *>          where |T| is the 1-norm of the tridiagonal matrix obtained
00166 *>          by reducing AB to tridiagonal form.
00167 *>
00168 *>          Eigenvalues will be computed most accurately when ABSTOL is
00169 *>          set to twice the underflow threshold 2*SLAMCH('S'), not zero.
00170 *>          If this routine returns with INFO>0, indicating that some
00171 *>          eigenvectors did not converge, try setting ABSTOL to
00172 *>          2*SLAMCH('S').
00173 *>
00174 *>          See "Computing Small Singular Values of Bidiagonal Matrices
00175 *>          with Guaranteed High Relative Accuracy," by Demmel and
00176 *>          Kahan, LAPACK Working Note #3.
00177 *> \endverbatim
00178 *>
00179 *> \param[out] M
00180 *> \verbatim
00181 *>          M is INTEGER
00182 *>          The total number of eigenvalues found.  0 <= M <= N.
00183 *>          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
00184 *> \endverbatim
00185 *>
00186 *> \param[out] W
00187 *> \verbatim
00188 *>          W is REAL array, dimension (N)
00189 *>          The first M elements contain the selected eigenvalues in
00190 *>          ascending order.
00191 *> \endverbatim
00192 *>
00193 *> \param[out] Z
00194 *> \verbatim
00195 *>          Z is REAL array, dimension (LDZ, max(1,M))
00196 *>          If JOBZ = 'V', then if INFO = 0, the first M columns of Z
00197 *>          contain the orthonormal eigenvectors of the matrix A
00198 *>          corresponding to the selected eigenvalues, with the i-th
00199 *>          column of Z holding the eigenvector associated with W(i).
00200 *>          If an eigenvector fails to converge, then that column of Z
00201 *>          contains the latest approximation to the eigenvector, and the
00202 *>          index of the eigenvector is returned in IFAIL.
00203 *>          If JOBZ = 'N', then Z is not referenced.
00204 *>          Note: the user must ensure that at least max(1,M) columns are
00205 *>          supplied in the array Z; if RANGE = 'V', the exact value of M
00206 *>          is not known in advance and an upper bound must be used.
00207 *> \endverbatim
00208 *>
00209 *> \param[in] LDZ
00210 *> \verbatim
00211 *>          LDZ is INTEGER
00212 *>          The leading dimension of the array Z.  LDZ >= 1, and if
00213 *>          JOBZ = 'V', LDZ >= max(1,N).
00214 *> \endverbatim
00215 *>
00216 *> \param[out] WORK
00217 *> \verbatim
00218 *>          WORK is REAL array, dimension (7*N)
00219 *> \endverbatim
00220 *>
00221 *> \param[out] IWORK
00222 *> \verbatim
00223 *>          IWORK is INTEGER array, dimension (5*N)
00224 *> \endverbatim
00225 *>
00226 *> \param[out] IFAIL
00227 *> \verbatim
00228 *>          IFAIL is INTEGER array, dimension (N)
00229 *>          If JOBZ = 'V', then if INFO = 0, the first M elements of
00230 *>          IFAIL are zero.  If INFO > 0, then IFAIL contains the
00231 *>          indices of the eigenvectors that failed to converge.
00232 *>          If JOBZ = 'N', then IFAIL is not referenced.
00233 *> \endverbatim
00234 *>
00235 *> \param[out] INFO
00236 *> \verbatim
00237 *>          INFO is INTEGER
00238 *>          = 0:  successful exit.
00239 *>          < 0:  if INFO = -i, the i-th argument had an illegal value.
00240 *>          > 0:  if INFO = i, then i eigenvectors failed to converge.
00241 *>                Their indices are stored in array IFAIL.
00242 *> \endverbatim
00243 *
00244 *  Authors:
00245 *  ========
00246 *
00247 *> \author Univ. of Tennessee 
00248 *> \author Univ. of California Berkeley 
00249 *> \author Univ. of Colorado Denver 
00250 *> \author NAG Ltd. 
00251 *
00252 *> \date November 2011
00253 *
00254 *> \ingroup realOTHEReigen
00255 *
00256 *  =====================================================================
00257       SUBROUTINE SSBEVX( JOBZ, RANGE, UPLO, N, KD, AB, LDAB, Q, LDQ, VL,
00258      $                   VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, IWORK,
00259      $                   IFAIL, INFO )
00260 *
00261 *  -- LAPACK driver routine (version 3.4.0) --
00262 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00263 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00264 *     November 2011
00265 *
00266 *     .. Scalar Arguments ..
00267       CHARACTER          JOBZ, RANGE, UPLO
00268       INTEGER            IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N
00269       REAL               ABSTOL, VL, VU
00270 *     ..
00271 *     .. Array Arguments ..
00272       INTEGER            IFAIL( * ), IWORK( * )
00273       REAL               AB( LDAB, * ), Q( LDQ, * ), W( * ), WORK( * ),
00274      $                   Z( LDZ, * )
00275 *     ..
00276 *
00277 *  =====================================================================
00278 *
00279 *     .. Parameters ..
00280       REAL               ZERO, ONE
00281       PARAMETER          ( ZERO = 0.0E0, ONE = 1.0E0 )
00282 *     ..
00283 *     .. Local Scalars ..
00284       LOGICAL            ALLEIG, INDEIG, LOWER, TEST, VALEIG, WANTZ
00285       CHARACTER          ORDER
00286       INTEGER            I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL,
00287      $                   INDISP, INDIWO, INDWRK, ISCALE, ITMP1, J, JJ,
00288      $                   NSPLIT
00289       REAL               ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
00290      $                   SIGMA, SMLNUM, TMP1, VLL, VUU
00291 *     ..
00292 *     .. External Functions ..
00293       LOGICAL            LSAME
00294       REAL               SLAMCH, SLANSB
00295       EXTERNAL           LSAME, SLAMCH, SLANSB
00296 *     ..
00297 *     .. External Subroutines ..
00298       EXTERNAL           SCOPY, SGEMV, SLACPY, SLASCL, SSBTRD, SSCAL,
00299      $                   SSTEBZ, SSTEIN, SSTEQR, SSTERF, SSWAP, XERBLA
00300 *     ..
00301 *     .. Intrinsic Functions ..
00302       INTRINSIC          MAX, MIN, SQRT
00303 *     ..
00304 *     .. Executable Statements ..
00305 *
00306 *     Test the input parameters.
00307 *
00308       WANTZ = LSAME( JOBZ, 'V' )
00309       ALLEIG = LSAME( RANGE, 'A' )
00310       VALEIG = LSAME( RANGE, 'V' )
00311       INDEIG = LSAME( RANGE, 'I' )
00312       LOWER = LSAME( UPLO, 'L' )
00313 *
00314       INFO = 0
00315       IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00316          INFO = -1
00317       ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
00318          INFO = -2
00319       ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN
00320          INFO = -3
00321       ELSE IF( N.LT.0 ) THEN
00322          INFO = -4
00323       ELSE IF( KD.LT.0 ) THEN
00324          INFO = -5
00325       ELSE IF( LDAB.LT.KD+1 ) THEN
00326          INFO = -7
00327       ELSE IF( WANTZ .AND. LDQ.LT.MAX( 1, N ) ) THEN
00328          INFO = -9
00329       ELSE
00330          IF( VALEIG ) THEN
00331             IF( N.GT.0 .AND. VU.LE.VL )
00332      $         INFO = -11
00333          ELSE IF( INDEIG ) THEN
00334             IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
00335                INFO = -12
00336             ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
00337                INFO = -13
00338             END IF
00339          END IF
00340       END IF
00341       IF( INFO.EQ.0 ) THEN
00342          IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) )
00343      $     INFO = -18
00344       END IF
00345 *
00346       IF( INFO.NE.0 ) THEN
00347          CALL XERBLA( 'SSBEVX', -INFO )
00348          RETURN
00349       END IF
00350 *
00351 *     Quick return if possible
00352 *
00353       M = 0
00354       IF( N.EQ.0 )
00355      $   RETURN
00356 *
00357       IF( N.EQ.1 ) THEN
00358          M = 1
00359          IF( LOWER ) THEN
00360             TMP1 = AB( 1, 1 )
00361          ELSE
00362             TMP1 = AB( KD+1, 1 )
00363          END IF
00364          IF( VALEIG ) THEN
00365             IF( .NOT.( VL.LT.TMP1 .AND. VU.GE.TMP1 ) )
00366      $         M = 0
00367          END IF
00368          IF( M.EQ.1 ) THEN
00369             W( 1 ) = TMP1
00370             IF( WANTZ )
00371      $         Z( 1, 1 ) = ONE
00372          END IF
00373          RETURN
00374       END IF
00375 *
00376 *     Get machine constants.
00377 *
00378       SAFMIN = SLAMCH( 'Safe minimum' )
00379       EPS = SLAMCH( 'Precision' )
00380       SMLNUM = SAFMIN / EPS
00381       BIGNUM = ONE / SMLNUM
00382       RMIN = SQRT( SMLNUM )
00383       RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
00384 *
00385 *     Scale matrix to allowable range, if necessary.
00386 *
00387       ISCALE = 0
00388       ABSTLL = ABSTOL
00389       IF ( VALEIG ) THEN
00390          VLL = VL
00391          VUU = VU
00392       ELSE
00393          VLL = ZERO
00394          VUU = ZERO
00395       ENDIF
00396       ANRM = SLANSB( 'M', UPLO, N, KD, AB, LDAB, WORK )
00397       IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
00398          ISCALE = 1
00399          SIGMA = RMIN / ANRM
00400       ELSE IF( ANRM.GT.RMAX ) THEN
00401          ISCALE = 1
00402          SIGMA = RMAX / ANRM
00403       END IF
00404       IF( ISCALE.EQ.1 ) THEN
00405          IF( LOWER ) THEN
00406             CALL SLASCL( 'B', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO )
00407          ELSE
00408             CALL SLASCL( 'Q', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO )
00409          END IF
00410          IF( ABSTOL.GT.0 )
00411      $      ABSTLL = ABSTOL*SIGMA
00412          IF( VALEIG ) THEN
00413             VLL = VL*SIGMA
00414             VUU = VU*SIGMA
00415          END IF
00416       END IF
00417 *
00418 *     Call SSBTRD to reduce symmetric band matrix to tridiagonal form.
00419 *
00420       INDD = 1
00421       INDE = INDD + N
00422       INDWRK = INDE + N
00423       CALL SSBTRD( JOBZ, UPLO, N, KD, AB, LDAB, WORK( INDD ),
00424      $             WORK( INDE ), Q, LDQ, WORK( INDWRK ), IINFO )
00425 *
00426 *     If all eigenvalues are desired and ABSTOL is less than or equal
00427 *     to zero, then call SSTERF or SSTEQR.  If this fails for some
00428 *     eigenvalue, then try SSTEBZ.
00429 *
00430       TEST = .FALSE.
00431       IF (INDEIG) THEN
00432          IF (IL.EQ.1 .AND. IU.EQ.N) THEN
00433             TEST = .TRUE.
00434          END IF
00435       END IF
00436       IF ((ALLEIG .OR. TEST) .AND. (ABSTOL.LE.ZERO)) THEN
00437          CALL SCOPY( N, WORK( INDD ), 1, W, 1 )
00438          INDEE = INDWRK + 2*N
00439          IF( .NOT.WANTZ ) THEN
00440             CALL SCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
00441             CALL SSTERF( N, W, WORK( INDEE ), INFO )
00442          ELSE
00443             CALL SLACPY( 'A', N, N, Q, LDQ, Z, LDZ )
00444             CALL SCOPY( N-1, WORK( INDE ), 1, WORK( INDEE ), 1 )
00445             CALL SSTEQR( JOBZ, N, W, WORK( INDEE ), Z, LDZ,
00446      $                   WORK( INDWRK ), INFO )
00447             IF( INFO.EQ.0 ) THEN
00448                DO 10 I = 1, N
00449                   IFAIL( I ) = 0
00450    10          CONTINUE
00451             END IF
00452          END IF
00453          IF( INFO.EQ.0 ) THEN
00454             M = N
00455             GO TO 30
00456          END IF
00457          INFO = 0
00458       END IF
00459 *
00460 *     Otherwise, call SSTEBZ and, if eigenvectors are desired, SSTEIN.
00461 *
00462       IF( WANTZ ) THEN
00463          ORDER = 'B'
00464       ELSE
00465          ORDER = 'E'
00466       END IF
00467       INDIBL = 1
00468       INDISP = INDIBL + N
00469       INDIWO = INDISP + N
00470       CALL SSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL,
00471      $             WORK( INDD ), WORK( INDE ), M, NSPLIT, W,
00472      $             IWORK( INDIBL ), IWORK( INDISP ), WORK( INDWRK ),
00473      $             IWORK( INDIWO ), INFO )
00474 *
00475       IF( WANTZ ) THEN
00476          CALL SSTEIN( N, WORK( INDD ), WORK( INDE ), M, W,
00477      $                IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
00478      $                WORK( INDWRK ), IWORK( INDIWO ), IFAIL, INFO )
00479 *
00480 *        Apply orthogonal matrix used in reduction to tridiagonal
00481 *        form to eigenvectors returned by SSTEIN.
00482 *
00483          DO 20 J = 1, M
00484             CALL SCOPY( N, Z( 1, J ), 1, WORK( 1 ), 1 )
00485             CALL SGEMV( 'N', N, N, ONE, Q, LDQ, WORK, 1, ZERO,
00486      $                  Z( 1, J ), 1 )
00487    20    CONTINUE
00488       END IF
00489 *
00490 *     If matrix was scaled, then rescale eigenvalues appropriately.
00491 *
00492    30 CONTINUE
00493       IF( ISCALE.EQ.1 ) THEN
00494          IF( INFO.EQ.0 ) THEN
00495             IMAX = M
00496          ELSE
00497             IMAX = INFO - 1
00498          END IF
00499          CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
00500       END IF
00501 *
00502 *     If eigenvalues are not in order, then sort them, along with
00503 *     eigenvectors.
00504 *
00505       IF( WANTZ ) THEN
00506          DO 50 J = 1, M - 1
00507             I = 0
00508             TMP1 = W( J )
00509             DO 40 JJ = J + 1, M
00510                IF( W( JJ ).LT.TMP1 ) THEN
00511                   I = JJ
00512                   TMP1 = W( JJ )
00513                END IF
00514    40       CONTINUE
00515 *
00516             IF( I.NE.0 ) THEN
00517                ITMP1 = IWORK( INDIBL+I-1 )
00518                W( I ) = W( J )
00519                IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
00520                W( J ) = TMP1
00521                IWORK( INDIBL+J-1 ) = ITMP1
00522                CALL SSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
00523                IF( INFO.NE.0 ) THEN
00524                   ITMP1 = IFAIL( I )
00525                   IFAIL( I ) = IFAIL( J )
00526                   IFAIL( J ) = ITMP1
00527                END IF
00528             END IF
00529    50    CONTINUE
00530       END IF
00531 *
00532       RETURN
00533 *
00534 *     End of SSBEVX
00535 *
00536       END
 All Files Functions