LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
zhegvx.f
Go to the documentation of this file.
00001 *> \brief \b ZHEGST
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download ZHEGVX + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhegvx.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhegvx.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhegvx.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE ZHEGVX( ITYPE, JOBZ, RANGE, UPLO, N, A, LDA, B, LDB,
00022 *                          VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK,
00023 *                          LWORK, RWORK, IWORK, IFAIL, INFO )
00024 * 
00025 *       .. Scalar Arguments ..
00026 *       CHARACTER          JOBZ, RANGE, UPLO
00027 *       INTEGER            IL, INFO, ITYPE, IU, LDA, LDB, LDZ, LWORK, M, N
00028 *       DOUBLE PRECISION   ABSTOL, VL, VU
00029 *       ..
00030 *       .. Array Arguments ..
00031 *       INTEGER            IFAIL( * ), IWORK( * )
00032 *       DOUBLE PRECISION   RWORK( * ), W( * )
00033 *       COMPLEX*16         A( LDA, * ), B( LDB, * ), WORK( * ),
00034 *      $                   Z( LDZ, * )
00035 *       ..
00036 *  
00037 *
00038 *> \par Purpose:
00039 *  =============
00040 *>
00041 *> \verbatim
00042 *>
00043 *> ZHEGVX computes selected eigenvalues, and optionally, eigenvectors
00044 *> of a complex generalized Hermitian-definite eigenproblem, of the form
00045 *> A*x=(lambda)*B*x,  A*Bx=(lambda)*x,  or B*A*x=(lambda)*x.  Here A and
00046 *> B are assumed to be Hermitian and B is also positive definite.
00047 *> Eigenvalues and eigenvectors can be selected by specifying either a
00048 *> range of values or a range of indices for the desired eigenvalues.
00049 *> \endverbatim
00050 *
00051 *  Arguments:
00052 *  ==========
00053 *
00054 *> \param[in] ITYPE
00055 *> \verbatim
00056 *>          ITYPE is INTEGER
00057 *>          Specifies the problem type to be solved:
00058 *>          = 1:  A*x = (lambda)*B*x
00059 *>          = 2:  A*B*x = (lambda)*x
00060 *>          = 3:  B*A*x = (lambda)*x
00061 *> \endverbatim
00062 *>
00063 *> \param[in] JOBZ
00064 *> \verbatim
00065 *>          JOBZ is CHARACTER*1
00066 *>          = 'N':  Compute eigenvalues only;
00067 *>          = 'V':  Compute eigenvalues and eigenvectors.
00068 *> \endverbatim
00069 *>
00070 *> \param[in] RANGE
00071 *> \verbatim
00072 *>          RANGE is CHARACTER*1
00073 *>          = 'A': all eigenvalues will be found.
00074 *>          = 'V': all eigenvalues in the half-open interval (VL,VU]
00075 *>                 will be found.
00076 *>          = 'I': the IL-th through IU-th eigenvalues will be found.
00077 *> \endverbatim
00078 *>
00079 *> \param[in] UPLO
00080 *> \verbatim
00081 *>          UPLO is CHARACTER*1
00082 *>          = 'U':  Upper triangles of A and B are stored;
00083 *>          = 'L':  Lower triangles of A and B are stored.
00084 *> \endverbatim
00085 *>
00086 *> \param[in] N
00087 *> \verbatim
00088 *>          N is INTEGER
00089 *>          The order of the matrices A and B.  N >= 0.
00090 *> \endverbatim
00091 *>
00092 *> \param[in,out] A
00093 *> \verbatim
00094 *>          A is COMPLEX*16 array, dimension (LDA, N)
00095 *>          On entry, the Hermitian matrix A.  If UPLO = 'U', the
00096 *>          leading N-by-N upper triangular part of A contains the
00097 *>          upper triangular part of the matrix A.  If UPLO = 'L',
00098 *>          the leading N-by-N lower triangular part of A contains
00099 *>          the lower triangular part of the matrix A.
00100 *>
00101 *>          On exit,  the lower triangle (if UPLO='L') or the upper
00102 *>          triangle (if UPLO='U') of A, including the diagonal, is
00103 *>          destroyed.
00104 *> \endverbatim
00105 *>
00106 *> \param[in] LDA
00107 *> \verbatim
00108 *>          LDA is INTEGER
00109 *>          The leading dimension of the array A.  LDA >= max(1,N).
00110 *> \endverbatim
00111 *>
00112 *> \param[in,out] B
00113 *> \verbatim
00114 *>          B is COMPLEX*16 array, dimension (LDB, N)
00115 *>          On entry, the Hermitian matrix B.  If UPLO = 'U', the
00116 *>          leading N-by-N upper triangular part of B contains the
00117 *>          upper triangular part of the matrix B.  If UPLO = 'L',
00118 *>          the leading N-by-N lower triangular part of B contains
00119 *>          the lower triangular part of the matrix B.
00120 *>
00121 *>          On exit, if INFO <= N, the part of B containing the matrix is
00122 *>          overwritten by the triangular factor U or L from the Cholesky
00123 *>          factorization B = U**H*U or B = L*L**H.
00124 *> \endverbatim
00125 *>
00126 *> \param[in] LDB
00127 *> \verbatim
00128 *>          LDB is INTEGER
00129 *>          The leading dimension of the array B.  LDB >= max(1,N).
00130 *> \endverbatim
00131 *>
00132 *> \param[in] VL
00133 *> \verbatim
00134 *>          VL is DOUBLE PRECISION
00135 *> \endverbatim
00136 *>
00137 *> \param[in] VU
00138 *> \verbatim
00139 *>          VU is DOUBLE PRECISION
00140 *>
00141 *>          If RANGE='V', the lower and upper bounds of the interval to
00142 *>          be searched for eigenvalues. VL < VU.
00143 *>          Not referenced if RANGE = 'A' or 'I'.
00144 *> \endverbatim
00145 *>
00146 *> \param[in] IL
00147 *> \verbatim
00148 *>          IL is INTEGER
00149 *> \endverbatim
00150 *>
00151 *> \param[in] IU
00152 *> \verbatim
00153 *>          IU is INTEGER
00154 *>
00155 *>          If RANGE='I', the indices (in ascending order) of the
00156 *>          smallest and largest eigenvalues to be returned.
00157 *>          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
00158 *>          Not referenced if RANGE = 'A' or 'V'.
00159 *> \endverbatim
00160 *>
00161 *> \param[in] ABSTOL
00162 *> \verbatim
00163 *>          ABSTOL is DOUBLE PRECISION
00164 *>          The absolute error tolerance for the eigenvalues.
00165 *>          An approximate eigenvalue is accepted as converged
00166 *>          when it is determined to lie in an interval [a,b]
00167 *>          of width less than or equal to
00168 *>
00169 *>                  ABSTOL + EPS *   max( |a|,|b| ) ,
00170 *>
00171 *>          where EPS is the machine precision.  If ABSTOL is less than
00172 *>          or equal to zero, then  EPS*|T|  will be used in its place,
00173 *>          where |T| is the 1-norm of the tridiagonal matrix obtained
00174 *>          by reducing C to tridiagonal form, where C is the symmetric
00175 *>          matrix of the standard symmetric problem to which the
00176 *>          generalized problem is transformed.
00177 *>
00178 *>          Eigenvalues will be computed most accurately when ABSTOL is
00179 *>          set to twice the underflow threshold 2*DLAMCH('S'), not zero.
00180 *>          If this routine returns with INFO>0, indicating that some
00181 *>          eigenvectors did not converge, try setting ABSTOL to
00182 *>          2*DLAMCH('S').
00183 *> \endverbatim
00184 *>
00185 *> \param[out] M
00186 *> \verbatim
00187 *>          M is INTEGER
00188 *>          The total number of eigenvalues found.  0 <= M <= N.
00189 *>          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
00190 *> \endverbatim
00191 *>
00192 *> \param[out] W
00193 *> \verbatim
00194 *>          W is DOUBLE PRECISION array, dimension (N)
00195 *>          The first M elements contain the selected
00196 *>          eigenvalues in ascending order.
00197 *> \endverbatim
00198 *>
00199 *> \param[out] Z
00200 *> \verbatim
00201 *>          Z is COMPLEX*16 array, dimension (LDZ, max(1,M))
00202 *>          If JOBZ = 'N', then Z is not referenced.
00203 *>          If JOBZ = 'V', then if INFO = 0, the first M columns of Z
00204 *>          contain the orthonormal eigenvectors of the matrix A
00205 *>          corresponding to the selected eigenvalues, with the i-th
00206 *>          column of Z holding the eigenvector associated with W(i).
00207 *>          The eigenvectors are normalized as follows:
00208 *>          if ITYPE = 1 or 2, Z**T*B*Z = I;
00209 *>          if ITYPE = 3, Z**T*inv(B)*Z = I.
00210 *>
00211 *>          If an eigenvector fails to converge, then that column of Z
00212 *>          contains the latest approximation to the eigenvector, and the
00213 *>          index of the eigenvector is returned in IFAIL.
00214 *>          Note: the user must ensure that at least max(1,M) columns are
00215 *>          supplied in the array Z; if RANGE = 'V', the exact value of M
00216 *>          is not known in advance and an upper bound must be used.
00217 *> \endverbatim
00218 *>
00219 *> \param[in] LDZ
00220 *> \verbatim
00221 *>          LDZ is INTEGER
00222 *>          The leading dimension of the array Z.  LDZ >= 1, and if
00223 *>          JOBZ = 'V', LDZ >= max(1,N).
00224 *> \endverbatim
00225 *>
00226 *> \param[out] WORK
00227 *> \verbatim
00228 *>          WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
00229 *>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00230 *> \endverbatim
00231 *>
00232 *> \param[in] LWORK
00233 *> \verbatim
00234 *>          LWORK is INTEGER
00235 *>          The length of the array WORK.  LWORK >= max(1,2*N).
00236 *>          For optimal efficiency, LWORK >= (NB+1)*N,
00237 *>          where NB is the blocksize for ZHETRD returned by ILAENV.
00238 *>
00239 *>          If LWORK = -1, then a workspace query is assumed; the routine
00240 *>          only calculates the optimal size of the WORK array, returns
00241 *>          this value as the first entry of the WORK array, and no error
00242 *>          message related to LWORK is issued by XERBLA.
00243 *> \endverbatim
00244 *>
00245 *> \param[out] RWORK
00246 *> \verbatim
00247 *>          RWORK is DOUBLE PRECISION array, dimension (7*N)
00248 *> \endverbatim
00249 *>
00250 *> \param[out] IWORK
00251 *> \verbatim
00252 *>          IWORK is INTEGER array, dimension (5*N)
00253 *> \endverbatim
00254 *>
00255 *> \param[out] IFAIL
00256 *> \verbatim
00257 *>          IFAIL is INTEGER array, dimension (N)
00258 *>          If JOBZ = 'V', then if INFO = 0, the first M elements of
00259 *>          IFAIL are zero.  If INFO > 0, then IFAIL contains the
00260 *>          indices of the eigenvectors that failed to converge.
00261 *>          If JOBZ = 'N', then IFAIL is not referenced.
00262 *> \endverbatim
00263 *>
00264 *> \param[out] INFO
00265 *> \verbatim
00266 *>          INFO is INTEGER
00267 *>          = 0:  successful exit
00268 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00269 *>          > 0:  ZPOTRF or ZHEEVX returned an error code:
00270 *>             <= N:  if INFO = i, ZHEEVX failed to converge;
00271 *>                    i eigenvectors failed to converge.  Their indices
00272 *>                    are stored in array IFAIL.
00273 *>             > N:   if INFO = N + i, for 1 <= i <= N, then the leading
00274 *>                    minor of order i of B is not positive definite.
00275 *>                    The factorization of B could not be completed and
00276 *>                    no eigenvalues or eigenvectors were computed.
00277 *> \endverbatim
00278 *
00279 *  Authors:
00280 *  ========
00281 *
00282 *> \author Univ. of Tennessee 
00283 *> \author Univ. of California Berkeley 
00284 *> \author Univ. of Colorado Denver 
00285 *> \author NAG Ltd. 
00286 *
00287 *> \date November 2011
00288 *
00289 *> \ingroup complex16HEeigen
00290 *
00291 *> \par Contributors:
00292 *  ==================
00293 *>
00294 *>     Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
00295 *
00296 *  =====================================================================
00297       SUBROUTINE ZHEGVX( ITYPE, JOBZ, RANGE, UPLO, N, A, LDA, B, LDB,
00298      $                   VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK,
00299      $                   LWORK, RWORK, IWORK, IFAIL, INFO )
00300 *
00301 *  -- LAPACK driver routine (version 3.4.0) --
00302 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00303 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00304 *     November 2011
00305 *
00306 *     .. Scalar Arguments ..
00307       CHARACTER          JOBZ, RANGE, UPLO
00308       INTEGER            IL, INFO, ITYPE, IU, LDA, LDB, LDZ, LWORK, M, N
00309       DOUBLE PRECISION   ABSTOL, VL, VU
00310 *     ..
00311 *     .. Array Arguments ..
00312       INTEGER            IFAIL( * ), IWORK( * )
00313       DOUBLE PRECISION   RWORK( * ), W( * )
00314       COMPLEX*16         A( LDA, * ), B( LDB, * ), WORK( * ),
00315      $                   Z( LDZ, * )
00316 *     ..
00317 *
00318 *  =====================================================================
00319 *
00320 *     .. Parameters ..
00321       COMPLEX*16         CONE
00322       PARAMETER          ( CONE = ( 1.0D+0, 0.0D+0 ) )
00323 *     ..
00324 *     .. Local Scalars ..
00325       LOGICAL            ALLEIG, INDEIG, LQUERY, UPPER, VALEIG, WANTZ
00326       CHARACTER          TRANS
00327       INTEGER            LWKOPT, NB
00328 *     ..
00329 *     .. External Functions ..
00330       LOGICAL            LSAME
00331       INTEGER            ILAENV
00332       EXTERNAL           LSAME, ILAENV
00333 *     ..
00334 *     .. External Subroutines ..
00335       EXTERNAL           XERBLA, ZHEEVX, ZHEGST, ZPOTRF, ZTRMM, ZTRSM
00336 *     ..
00337 *     .. Intrinsic Functions ..
00338       INTRINSIC          MAX, MIN
00339 *     ..
00340 *     .. Executable Statements ..
00341 *
00342 *     Test the input parameters.
00343 *
00344       WANTZ = LSAME( JOBZ, 'V' )
00345       UPPER = LSAME( UPLO, 'U' )
00346       ALLEIG = LSAME( RANGE, 'A' )
00347       VALEIG = LSAME( RANGE, 'V' )
00348       INDEIG = LSAME( RANGE, 'I' )
00349       LQUERY = ( LWORK.EQ.-1 )
00350 *
00351       INFO = 0
00352       IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00353          INFO = -1
00354       ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00355          INFO = -2
00356       ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
00357          INFO = -3
00358       ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
00359          INFO = -4
00360       ELSE IF( N.LT.0 ) THEN
00361          INFO = -5
00362       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00363          INFO = -7
00364       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00365          INFO = -9
00366       ELSE
00367          IF( VALEIG ) THEN
00368             IF( N.GT.0 .AND. VU.LE.VL )
00369      $         INFO = -11
00370          ELSE IF( INDEIG ) THEN
00371             IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
00372                INFO = -12
00373             ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
00374                INFO = -13
00375             END IF
00376          END IF
00377       END IF
00378       IF (INFO.EQ.0) THEN
00379          IF (LDZ.LT.1 .OR. (WANTZ .AND. LDZ.LT.N)) THEN
00380             INFO = -18
00381          END IF
00382       END IF
00383 *
00384       IF( INFO.EQ.0 ) THEN
00385          NB = ILAENV( 1, 'ZHETRD', UPLO, N, -1, -1, -1 )
00386          LWKOPT = MAX( 1, ( NB + 1 )*N )
00387          WORK( 1 ) = LWKOPT
00388 *
00389          IF( LWORK.LT.MAX( 1, 2*N ) .AND. .NOT.LQUERY ) THEN
00390             INFO = -20
00391          END IF
00392       END IF
00393 *
00394       IF( INFO.NE.0 ) THEN
00395          CALL XERBLA( 'ZHEGVX', -INFO )
00396          RETURN
00397       ELSE IF( LQUERY ) THEN
00398          RETURN
00399       END IF
00400 *
00401 *     Quick return if possible
00402 *
00403       M = 0
00404       IF( N.EQ.0 ) THEN
00405          RETURN
00406       END IF
00407 *
00408 *     Form a Cholesky factorization of B.
00409 *
00410       CALL ZPOTRF( UPLO, N, B, LDB, INFO )
00411       IF( INFO.NE.0 ) THEN
00412          INFO = N + INFO
00413          RETURN
00414       END IF
00415 *
00416 *     Transform problem to standard eigenvalue problem and solve.
00417 *
00418       CALL ZHEGST( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
00419       CALL ZHEEVX( JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU, ABSTOL,
00420      $             M, W, Z, LDZ, WORK, LWORK, RWORK, IWORK, IFAIL,
00421      $             INFO )
00422 *
00423       IF( WANTZ ) THEN
00424 *
00425 *        Backtransform eigenvectors to the original problem.
00426 *
00427          IF( INFO.GT.0 )
00428      $      M = INFO - 1
00429          IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
00430 *
00431 *           For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
00432 *           backtransform eigenvectors: x = inv(L)**H *y or inv(U)*y
00433 *
00434             IF( UPPER ) THEN
00435                TRANS = 'N'
00436             ELSE
00437                TRANS = 'C'
00438             END IF
00439 *
00440             CALL ZTRSM( 'Left', UPLO, TRANS, 'Non-unit', N, M, CONE, B,
00441      $                  LDB, Z, LDZ )
00442 *
00443          ELSE IF( ITYPE.EQ.3 ) THEN
00444 *
00445 *           For B*A*x=(lambda)*x;
00446 *           backtransform eigenvectors: x = L*y or U**H *y
00447 *
00448             IF( UPPER ) THEN
00449                TRANS = 'C'
00450             ELSE
00451                TRANS = 'N'
00452             END IF
00453 *
00454             CALL ZTRMM( 'Left', UPLO, TRANS, 'Non-unit', N, M, CONE, B,
00455      $                  LDB, Z, LDZ )
00456          END IF
00457       END IF
00458 *
00459 *     Set WORK(1) to optimal complex workspace size.
00460 *
00461       WORK( 1 ) = LWKOPT
00462 *
00463       RETURN
00464 *
00465 *     End of ZHEGVX
00466 *
00467       END
 All Files Functions