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