LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
chegv.f
Go to the documentation of this file.
00001 *> \brief \b CHEGST
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CHEGV + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chegv.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chegv.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chegv.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CHEGV( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK,
00022 *                         LWORK, RWORK, INFO )
00023 * 
00024 *       .. Scalar Arguments ..
00025 *       CHARACTER          JOBZ, UPLO
00026 *       INTEGER            INFO, ITYPE, LDA, LDB, LWORK, N
00027 *       ..
00028 *       .. Array Arguments ..
00029 *       REAL               RWORK( * ), W( * )
00030 *       COMPLEX            A( LDA, * ), B( LDB, * ), WORK( * )
00031 *       ..
00032 *  
00033 *
00034 *> \par Purpose:
00035 *  =============
00036 *>
00037 *> \verbatim
00038 *>
00039 *> CHEGV computes all the eigenvalues, and optionally, the eigenvectors
00040 *> of a complex generalized Hermitian-definite eigenproblem, of the form
00041 *> A*x=(lambda)*B*x,  A*Bx=(lambda)*x,  or B*A*x=(lambda)*x.
00042 *> Here A and B are assumed to be Hermitian and B is also
00043 *> positive definite.
00044 *> \endverbatim
00045 *
00046 *  Arguments:
00047 *  ==========
00048 *
00049 *> \param[in] ITYPE
00050 *> \verbatim
00051 *>          ITYPE is INTEGER
00052 *>          Specifies the problem type to be solved:
00053 *>          = 1:  A*x = (lambda)*B*x
00054 *>          = 2:  A*B*x = (lambda)*x
00055 *>          = 3:  B*A*x = (lambda)*x
00056 *> \endverbatim
00057 *>
00058 *> \param[in] JOBZ
00059 *> \verbatim
00060 *>          JOBZ is CHARACTER*1
00061 *>          = 'N':  Compute eigenvalues only;
00062 *>          = 'V':  Compute eigenvalues and eigenvectors.
00063 *> \endverbatim
00064 *>
00065 *> \param[in] UPLO
00066 *> \verbatim
00067 *>          UPLO is CHARACTER*1
00068 *>          = 'U':  Upper triangles of A and B are stored;
00069 *>          = 'L':  Lower triangles of A and B are stored.
00070 *> \endverbatim
00071 *>
00072 *> \param[in] N
00073 *> \verbatim
00074 *>          N is INTEGER
00075 *>          The order of the matrices A and B.  N >= 0.
00076 *> \endverbatim
00077 *>
00078 *> \param[in,out] A
00079 *> \verbatim
00080 *>          A is COMPLEX array, dimension (LDA, N)
00081 *>          On entry, the Hermitian matrix A.  If UPLO = 'U', the
00082 *>          leading N-by-N upper triangular part of A contains the
00083 *>          upper triangular part of the matrix A.  If UPLO = 'L',
00084 *>          the leading N-by-N lower triangular part of A contains
00085 *>          the lower triangular part of the matrix A.
00086 *>
00087 *>          On exit, if JOBZ = 'V', then if INFO = 0, A contains the
00088 *>          matrix Z of eigenvectors.  The eigenvectors are normalized
00089 *>          as follows:
00090 *>          if ITYPE = 1 or 2, Z**H*B*Z = I;
00091 *>          if ITYPE = 3, Z**H*inv(B)*Z = I.
00092 *>          If JOBZ = 'N', then on exit the upper triangle (if UPLO='U')
00093 *>          or the lower triangle (if UPLO='L') of A, including the
00094 *>          diagonal, is destroyed.
00095 *> \endverbatim
00096 *>
00097 *> \param[in] LDA
00098 *> \verbatim
00099 *>          LDA is INTEGER
00100 *>          The leading dimension of the array A.  LDA >= max(1,N).
00101 *> \endverbatim
00102 *>
00103 *> \param[in,out] B
00104 *> \verbatim
00105 *>          B is COMPLEX array, dimension (LDB, N)
00106 *>          On entry, the Hermitian positive definite matrix B.
00107 *>          If UPLO = 'U', the leading N-by-N upper triangular part of B
00108 *>          contains the upper triangular part of the matrix B.
00109 *>          If UPLO = 'L', the leading N-by-N lower triangular part of B
00110 *>          contains the lower triangular part of the matrix B.
00111 *>
00112 *>          On exit, if INFO <= N, the part of B containing the matrix is
00113 *>          overwritten by the triangular factor U or L from the Cholesky
00114 *>          factorization B = U**H*U or B = L*L**H.
00115 *> \endverbatim
00116 *>
00117 *> \param[in] LDB
00118 *> \verbatim
00119 *>          LDB is INTEGER
00120 *>          The leading dimension of the array B.  LDB >= max(1,N).
00121 *> \endverbatim
00122 *>
00123 *> \param[out] W
00124 *> \verbatim
00125 *>          W is REAL array, dimension (N)
00126 *>          If INFO = 0, the eigenvalues in ascending order.
00127 *> \endverbatim
00128 *>
00129 *> \param[out] WORK
00130 *> \verbatim
00131 *>          WORK is COMPLEX array, dimension (MAX(1,LWORK))
00132 *>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00133 *> \endverbatim
00134 *>
00135 *> \param[in] LWORK
00136 *> \verbatim
00137 *>          LWORK is INTEGER
00138 *>          The length of the array WORK.  LWORK >= max(1,2*N-1).
00139 *>          For optimal efficiency, LWORK >= (NB+1)*N,
00140 *>          where NB is the blocksize for CHETRD returned by ILAENV.
00141 *>
00142 *>          If LWORK = -1, then a workspace query is assumed; the routine
00143 *>          only calculates the optimal size of the WORK array, returns
00144 *>          this value as the first entry of the WORK array, and no error
00145 *>          message related to LWORK is issued by XERBLA.
00146 *> \endverbatim
00147 *>
00148 *> \param[out] RWORK
00149 *> \verbatim
00150 *>          RWORK is REAL array, dimension (max(1, 3*N-2))
00151 *> \endverbatim
00152 *>
00153 *> \param[out] INFO
00154 *> \verbatim
00155 *>          INFO is INTEGER
00156 *>          = 0:  successful exit
00157 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00158 *>          > 0:  CPOTRF or CHEEV returned an error code:
00159 *>             <= N:  if INFO = i, CHEEV failed to converge;
00160 *>                    i off-diagonal elements of an intermediate
00161 *>                    tridiagonal form did not converge to zero;
00162 *>             > N:   if INFO = N + i, for 1 <= i <= N, then the leading
00163 *>                    minor of order i of B is not positive definite.
00164 *>                    The factorization of B could not be completed and
00165 *>                    no eigenvalues or eigenvectors were computed.
00166 *> \endverbatim
00167 *
00168 *  Authors:
00169 *  ========
00170 *
00171 *> \author Univ. of Tennessee 
00172 *> \author Univ. of California Berkeley 
00173 *> \author Univ. of Colorado Denver 
00174 *> \author NAG Ltd. 
00175 *
00176 *> \date November 2011
00177 *
00178 *> \ingroup complexHEeigen
00179 *
00180 *  =====================================================================
00181       SUBROUTINE CHEGV( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK,
00182      $                  LWORK, RWORK, INFO )
00183 *
00184 *  -- LAPACK driver routine (version 3.4.0) --
00185 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00186 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00187 *     November 2011
00188 *
00189 *     .. Scalar Arguments ..
00190       CHARACTER          JOBZ, UPLO
00191       INTEGER            INFO, ITYPE, LDA, LDB, LWORK, N
00192 *     ..
00193 *     .. Array Arguments ..
00194       REAL               RWORK( * ), W( * )
00195       COMPLEX            A( LDA, * ), B( LDB, * ), WORK( * )
00196 *     ..
00197 *
00198 *  =====================================================================
00199 *
00200 *     .. Parameters ..
00201       COMPLEX            ONE
00202       PARAMETER          ( ONE = ( 1.0E+0, 0.0E+0 ) )
00203 *     ..
00204 *     .. Local Scalars ..
00205       LOGICAL            LQUERY, UPPER, WANTZ
00206       CHARACTER          TRANS
00207       INTEGER            LWKOPT, NB, NEIG
00208 *     ..
00209 *     .. External Functions ..
00210       LOGICAL            LSAME
00211       INTEGER            ILAENV
00212       EXTERNAL           ILAENV, LSAME
00213 *     ..
00214 *     .. External Subroutines ..
00215       EXTERNAL           CHEEV, CHEGST, CPOTRF, CTRMM, CTRSM, XERBLA
00216 *     ..
00217 *     .. Intrinsic Functions ..
00218       INTRINSIC          MAX
00219 *     ..
00220 *     .. Executable Statements ..
00221 *
00222 *     Test the input parameters.
00223 *
00224       WANTZ = LSAME( JOBZ, 'V' )
00225       UPPER = LSAME( UPLO, 'U' )
00226       LQUERY = ( LWORK.EQ. -1 )
00227 *
00228       INFO = 0
00229       IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00230          INFO = -1
00231       ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00232          INFO = -2
00233       ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
00234          INFO = -3
00235       ELSE IF( N.LT.0 ) THEN
00236          INFO = -4
00237       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00238          INFO = -6
00239       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00240          INFO = -8
00241       END IF
00242 *
00243       IF( INFO.EQ.0 ) THEN
00244          NB = ILAENV( 1, 'CHETRD', UPLO, N, -1, -1, -1 )
00245          LWKOPT = MAX( 1, ( NB + 1 )*N )
00246          WORK( 1 ) = LWKOPT
00247 *
00248          IF( LWORK.LT.MAX( 1, 2*N-1 ) .AND. .NOT.LQUERY ) THEN
00249             INFO = -11
00250          END IF
00251       END IF
00252 *
00253       IF( INFO.NE.0 ) THEN
00254          CALL XERBLA( 'CHEGV ', -INFO )
00255          RETURN
00256       ELSE IF( LQUERY ) THEN
00257          RETURN
00258       END IF
00259 *
00260 *     Quick return if possible
00261 *
00262       IF( N.EQ.0 )
00263      $   RETURN
00264 *
00265 *     Form a Cholesky factorization of B.
00266 *
00267       CALL CPOTRF( UPLO, N, B, LDB, INFO )
00268       IF( INFO.NE.0 ) THEN
00269          INFO = N + INFO
00270          RETURN
00271       END IF
00272 *
00273 *     Transform problem to standard eigenvalue problem and solve.
00274 *
00275       CALL CHEGST( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
00276       CALL CHEEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK, INFO )
00277 *
00278       IF( WANTZ ) THEN
00279 *
00280 *        Backtransform eigenvectors to the original problem.
00281 *
00282          NEIG = N
00283          IF( INFO.GT.0 )
00284      $      NEIG = INFO - 1
00285          IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
00286 *
00287 *           For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
00288 *           backtransform eigenvectors: x = inv(L)**H*y or inv(U)*y
00289 *
00290             IF( UPPER ) THEN
00291                TRANS = 'N'
00292             ELSE
00293                TRANS = 'C'
00294             END IF
00295 *
00296             CALL CTRSM( 'Left', UPLO, TRANS, 'Non-unit', N, NEIG, ONE,
00297      $                  B, LDB, A, LDA )
00298 *
00299          ELSE IF( ITYPE.EQ.3 ) THEN
00300 *
00301 *           For B*A*x=(lambda)*x;
00302 *           backtransform eigenvectors: x = L*y or U**H*y
00303 *
00304             IF( UPPER ) THEN
00305                TRANS = 'C'
00306             ELSE
00307                TRANS = 'N'
00308             END IF
00309 *
00310             CALL CTRMM( 'Left', UPLO, TRANS, 'Non-unit', N, NEIG, ONE,
00311      $                  B, LDB, A, LDA )
00312          END IF
00313       END IF
00314 *
00315       WORK( 1 ) = LWKOPT
00316 *
00317       RETURN
00318 *
00319 *     End of CHEGV
00320 *
00321       END
 All Files Functions