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