LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
ssbevd.f
Go to the documentation of this file.
00001 *> \brief <b> SSBEVD 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 SSBEVD + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssbevd.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssbevd.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssbevd.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE SSBEVD( JOBZ, UPLO, N, KD, AB, LDAB, W, Z, LDZ, WORK,
00022 *                          LWORK, IWORK, LIWORK, INFO )
00023 * 
00024 *       .. Scalar Arguments ..
00025 *       CHARACTER          JOBZ, UPLO
00026 *       INTEGER            INFO, KD, LDAB, LDZ, LIWORK, LWORK, N
00027 *       ..
00028 *       .. Array Arguments ..
00029 *       INTEGER            IWORK( * )
00030 *       REAL               AB( LDAB, * ), W( * ), WORK( * ), Z( LDZ, * )
00031 *       ..
00032 *  
00033 *
00034 *> \par Purpose:
00035 *  =============
00036 *>
00037 *> \verbatim
00038 *>
00039 *> SSBEVD computes all the eigenvalues and, optionally, eigenvectors of
00040 *> a real symmetric band matrix A. If eigenvectors are desired, it uses
00041 *> a divide and conquer algorithm.
00042 *>
00043 *> The divide and conquer algorithm makes very mild assumptions about
00044 *> floating point arithmetic. It will work on machines with a guard
00045 *> digit in add/subtract, or on those binary machines without guard
00046 *> digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
00047 *> Cray-2. It could conceivably fail on hexadecimal or decimal machines
00048 *> without guard digits, but we know of none.
00049 *> \endverbatim
00050 *
00051 *  Arguments:
00052 *  ==========
00053 *
00054 *> \param[in] JOBZ
00055 *> \verbatim
00056 *>          JOBZ is CHARACTER*1
00057 *>          = 'N':  Compute eigenvalues only;
00058 *>          = 'V':  Compute eigenvalues and eigenvectors.
00059 *> \endverbatim
00060 *>
00061 *> \param[in] UPLO
00062 *> \verbatim
00063 *>          UPLO is CHARACTER*1
00064 *>          = 'U':  Upper triangle of A is stored;
00065 *>          = 'L':  Lower triangle of A is stored.
00066 *> \endverbatim
00067 *>
00068 *> \param[in] N
00069 *> \verbatim
00070 *>          N is INTEGER
00071 *>          The order of the matrix A.  N >= 0.
00072 *> \endverbatim
00073 *>
00074 *> \param[in] KD
00075 *> \verbatim
00076 *>          KD is INTEGER
00077 *>          The number of superdiagonals of the matrix A if UPLO = 'U',
00078 *>          or the number of subdiagonals if UPLO = 'L'.  KD >= 0.
00079 *> \endverbatim
00080 *>
00081 *> \param[in,out] AB
00082 *> \verbatim
00083 *>          AB is REAL array, dimension (LDAB, N)
00084 *>          On entry, the upper or lower triangle of the symmetric band
00085 *>          matrix A, stored in the first KD+1 rows of the array.  The
00086 *>          j-th column of A is stored in the j-th column of the array AB
00087 *>          as follows:
00088 *>          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
00089 *>          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
00090 *>
00091 *>          On exit, AB is overwritten by values generated during the
00092 *>          reduction to tridiagonal form.  If UPLO = 'U', the first
00093 *>          superdiagonal and the diagonal of the tridiagonal matrix T
00094 *>          are returned in rows KD and KD+1 of AB, and if UPLO = 'L',
00095 *>          the diagonal and first subdiagonal of T are returned in the
00096 *>          first two rows of AB.
00097 *> \endverbatim
00098 *>
00099 *> \param[in] LDAB
00100 *> \verbatim
00101 *>          LDAB is INTEGER
00102 *>          The leading dimension of the array AB.  LDAB >= KD + 1.
00103 *> \endverbatim
00104 *>
00105 *> \param[out] W
00106 *> \verbatim
00107 *>          W is REAL array, dimension (N)
00108 *>          If INFO = 0, the eigenvalues in ascending order.
00109 *> \endverbatim
00110 *>
00111 *> \param[out] Z
00112 *> \verbatim
00113 *>          Z is REAL array, dimension (LDZ, N)
00114 *>          If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
00115 *>          eigenvectors of the matrix A, with the i-th column of Z
00116 *>          holding the eigenvector associated with W(i).
00117 *>          If JOBZ = 'N', then Z is not referenced.
00118 *> \endverbatim
00119 *>
00120 *> \param[in] LDZ
00121 *> \verbatim
00122 *>          LDZ is INTEGER
00123 *>          The leading dimension of the array Z.  LDZ >= 1, and if
00124 *>          JOBZ = 'V', LDZ >= max(1,N).
00125 *> \endverbatim
00126 *>
00127 *> \param[out] WORK
00128 *> \verbatim
00129 *>          WORK is REAL array,
00130 *>                                         dimension (LWORK)
00131 *>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00132 *> \endverbatim
00133 *>
00134 *> \param[in] LWORK
00135 *> \verbatim
00136 *>          LWORK is INTEGER
00137 *>          The dimension of the array WORK.
00138 *>          IF N <= 1,                LWORK must be at least 1.
00139 *>          If JOBZ  = 'N' and N > 2, LWORK must be at least 2*N.
00140 *>          If JOBZ  = 'V' and N > 2, LWORK must be at least
00141 *>                         ( 1 + 5*N + 2*N**2 ).
00142 *>
00143 *>          If LWORK = -1, then a workspace query is assumed; the routine
00144 *>          only calculates the optimal sizes of the WORK and IWORK
00145 *>          arrays, returns these values as the first entries of the WORK
00146 *>          and IWORK arrays, and no error message related to LWORK or
00147 *>          LIWORK is issued by XERBLA.
00148 *> \endverbatim
00149 *>
00150 *> \param[out] IWORK
00151 *> \verbatim
00152 *>          IWORK is INTEGER array, dimension (MAX(1,LIWORK))
00153 *>          On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
00154 *> \endverbatim
00155 *>
00156 *> \param[in] LIWORK
00157 *> \verbatim
00158 *>          LIWORK is INTEGER
00159 *>          The dimension of the array LIWORK.
00160 *>          If JOBZ  = 'N' or N <= 1, LIWORK must be at least 1.
00161 *>          If JOBZ  = 'V' and N > 2, LIWORK must be at least 3 + 5*N.
00162 *>
00163 *>          If LIWORK = -1, then a workspace query is assumed; the
00164 *>          routine only calculates the optimal sizes of the WORK and
00165 *>          IWORK arrays, returns these values as the first entries of
00166 *>          the WORK and IWORK arrays, and no error message related to
00167 *>          LWORK or LIWORK is issued by XERBLA.
00168 *> \endverbatim
00169 *>
00170 *> \param[out] INFO
00171 *> \verbatim
00172 *>          INFO is INTEGER
00173 *>          = 0:  successful exit
00174 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00175 *>          > 0:  if INFO = i, the algorithm failed to converge; i
00176 *>                off-diagonal elements of an intermediate tridiagonal
00177 *>                form did not converge to zero.
00178 *> \endverbatim
00179 *
00180 *  Authors:
00181 *  ========
00182 *
00183 *> \author Univ. of Tennessee 
00184 *> \author Univ. of California Berkeley 
00185 *> \author Univ. of Colorado Denver 
00186 *> \author NAG Ltd. 
00187 *
00188 *> \date November 2011
00189 *
00190 *> \ingroup realOTHEReigen
00191 *
00192 *  =====================================================================
00193       SUBROUTINE SSBEVD( JOBZ, UPLO, N, KD, AB, LDAB, W, Z, LDZ, WORK,
00194      $                   LWORK, IWORK, LIWORK, INFO )
00195 *
00196 *  -- LAPACK driver routine (version 3.4.0) --
00197 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00198 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00199 *     November 2011
00200 *
00201 *     .. Scalar Arguments ..
00202       CHARACTER          JOBZ, UPLO
00203       INTEGER            INFO, KD, LDAB, LDZ, LIWORK, LWORK, N
00204 *     ..
00205 *     .. Array Arguments ..
00206       INTEGER            IWORK( * )
00207       REAL               AB( LDAB, * ), W( * ), WORK( * ), Z( LDZ, * )
00208 *     ..
00209 *
00210 *  =====================================================================
00211 *
00212 *     .. Parameters ..
00213       REAL               ZERO, ONE
00214       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00215 *     ..
00216 *     .. Local Scalars ..
00217       LOGICAL            LOWER, LQUERY, WANTZ
00218       INTEGER            IINFO, INDE, INDWK2, INDWRK, ISCALE, LIWMIN,
00219      $                   LLWRK2, LWMIN
00220       REAL               ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
00221      $                   SMLNUM
00222 *     ..
00223 *     .. External Functions ..
00224       LOGICAL            LSAME
00225       REAL               SLAMCH, SLANSB
00226       EXTERNAL           LSAME, SLAMCH, SLANSB
00227 *     ..
00228 *     .. External Subroutines ..
00229       EXTERNAL           SGEMM, SLACPY, SLASCL, SSBTRD, SSCAL, SSTEDC,
00230      $                   SSTERF, XERBLA
00231 *     ..
00232 *     .. Intrinsic Functions ..
00233       INTRINSIC          SQRT
00234 *     ..
00235 *     .. Executable Statements ..
00236 *
00237 *     Test the input parameters.
00238 *
00239       WANTZ = LSAME( JOBZ, 'V' )
00240       LOWER = LSAME( UPLO, 'L' )
00241       LQUERY = ( LWORK.EQ.-1 .OR. LIWORK.EQ.-1 )
00242 *
00243       INFO = 0
00244       IF( N.LE.1 ) THEN
00245          LIWMIN = 1
00246          LWMIN = 1
00247       ELSE
00248          IF( WANTZ ) THEN
00249             LIWMIN = 3 + 5*N
00250             LWMIN = 1 + 5*N + 2*N**2
00251          ELSE
00252             LIWMIN = 1
00253             LWMIN = 2*N
00254          END IF
00255       END IF
00256       IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00257          INFO = -1
00258       ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN
00259          INFO = -2
00260       ELSE IF( N.LT.0 ) THEN
00261          INFO = -3
00262       ELSE IF( KD.LT.0 ) THEN
00263          INFO = -4
00264       ELSE IF( LDAB.LT.KD+1 ) THEN
00265          INFO = -6
00266       ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
00267          INFO = -9
00268       END IF
00269 *
00270       IF( INFO.EQ.0 ) THEN
00271          WORK( 1 ) = LWMIN
00272          IWORK( 1 ) = LIWMIN
00273 *
00274          IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
00275             INFO = -11
00276          ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
00277             INFO = -13
00278          END IF
00279       END IF
00280 *
00281       IF( INFO.NE.0 ) THEN
00282          CALL XERBLA( 'SSBEVD', -INFO )
00283          RETURN
00284       ELSE IF( LQUERY ) THEN
00285          RETURN 
00286       END IF
00287 *
00288 *     Quick return if possible
00289 *
00290       IF( N.EQ.0 )
00291      $   RETURN 
00292 *
00293       IF( N.EQ.1 ) THEN
00294          W( 1 ) = AB( 1, 1 )
00295          IF( WANTZ )
00296      $      Z( 1, 1 ) = ONE
00297          RETURN 
00298       END IF
00299 *
00300 *     Get machine constants.
00301 *
00302       SAFMIN = SLAMCH( 'Safe minimum' )
00303       EPS = SLAMCH( 'Precision' )
00304       SMLNUM = SAFMIN / EPS
00305       BIGNUM = ONE / SMLNUM
00306       RMIN = SQRT( SMLNUM )
00307       RMAX = SQRT( BIGNUM )
00308 *
00309 *     Scale matrix to allowable range, if necessary.
00310 *
00311       ANRM = SLANSB( 'M', UPLO, N, KD, AB, LDAB, WORK )
00312       ISCALE = 0
00313       IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
00314          ISCALE = 1
00315          SIGMA = RMIN / ANRM
00316       ELSE IF( ANRM.GT.RMAX ) THEN
00317          ISCALE = 1
00318          SIGMA = RMAX / ANRM
00319       END IF
00320       IF( ISCALE.EQ.1 ) THEN
00321          IF( LOWER ) THEN
00322             CALL SLASCL( 'B', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO )
00323          ELSE
00324             CALL SLASCL( 'Q', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO )
00325          END IF
00326       END IF
00327 *
00328 *     Call SSBTRD to reduce symmetric band matrix to tridiagonal form.
00329 *
00330       INDE = 1
00331       INDWRK = INDE + N
00332       INDWK2 = INDWRK + N*N
00333       LLWRK2 = LWORK - INDWK2 + 1
00334       CALL SSBTRD( JOBZ, UPLO, N, KD, AB, LDAB, W, WORK( INDE ), Z, LDZ,
00335      $             WORK( INDWRK ), IINFO )
00336 *
00337 *     For eigenvalues only, call SSTERF.  For eigenvectors, call SSTEDC.
00338 *
00339       IF( .NOT.WANTZ ) THEN
00340          CALL SSTERF( N, W, WORK( INDE ), INFO )
00341       ELSE
00342          CALL SSTEDC( 'I', N, W, WORK( INDE ), WORK( INDWRK ), N,
00343      $                WORK( INDWK2 ), LLWRK2, IWORK, LIWORK, INFO )
00344          CALL SGEMM( 'N', 'N', N, N, N, ONE, Z, LDZ, WORK( INDWRK ), N,
00345      $               ZERO, WORK( INDWK2 ), N )
00346          CALL SLACPY( 'A', N, N, WORK( INDWK2 ), N, Z, LDZ )
00347       END IF
00348 *
00349 *     If matrix was scaled, then rescale eigenvalues appropriately.
00350 *
00351       IF( ISCALE.EQ.1 )
00352      $   CALL SSCAL( N, ONE / SIGMA, W, 1 )
00353 *
00354       WORK( 1 ) = LWMIN
00355       IWORK( 1 ) = LIWMIN
00356       RETURN
00357 *
00358 *     End of SSBEVD
00359 *
00360       END
 All Files Functions