LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
chpgvx.f
Go to the documentation of this file.
00001 *> \brief \b CHPGST
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CHPGVX + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chpgvx.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chpgvx.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chpgvx.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CHPGVX( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
00022 *                          IL, IU, ABSTOL, M, W, Z, LDZ, WORK, RWORK,
00023 *                          IWORK, IFAIL, INFO )
00024 * 
00025 *       .. Scalar Arguments ..
00026 *       CHARACTER          JOBZ, RANGE, UPLO
00027 *       INTEGER            IL, INFO, ITYPE, IU, LDZ, M, N
00028 *       REAL               ABSTOL, VL, VU
00029 *       ..
00030 *       .. Array Arguments ..
00031 *       INTEGER            IFAIL( * ), IWORK( * )
00032 *       REAL               RWORK( * ), W( * )
00033 *       COMPLEX            AP( * ), BP( * ), WORK( * ), Z( LDZ, * )
00034 *       ..
00035 *  
00036 *
00037 *> \par Purpose:
00038 *  =============
00039 *>
00040 *> \verbatim
00041 *>
00042 *> CHPGVX computes selected eigenvalues and, optionally, eigenvectors
00043 *> of a complex generalized Hermitian-definite eigenproblem, of the form
00044 *> A*x=(lambda)*B*x,  A*Bx=(lambda)*x,  or B*A*x=(lambda)*x.  Here A and
00045 *> B are assumed to be Hermitian, stored in packed format, and B is also
00046 *> positive definite.  Eigenvalues and eigenvectors can be selected by
00047 *> specifying either a range of values or a range of indices for the
00048 *> 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] AP
00093 *> \verbatim
00094 *>          AP is COMPLEX array, dimension (N*(N+1)/2)
00095 *>          On entry, the upper or lower triangle of the Hermitian matrix
00096 *>          A, packed columnwise in a linear array.  The j-th column of A
00097 *>          is stored in the array AP as follows:
00098 *>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00099 *>          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
00100 *>
00101 *>          On exit, the contents of AP are destroyed.
00102 *> \endverbatim
00103 *>
00104 *> \param[in,out] BP
00105 *> \verbatim
00106 *>          BP is COMPLEX array, dimension (N*(N+1)/2)
00107 *>          On entry, the upper or lower triangle of the Hermitian matrix
00108 *>          B, packed columnwise in a linear array.  The j-th column of B
00109 *>          is stored in the array BP as follows:
00110 *>          if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j;
00111 *>          if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n.
00112 *>
00113 *>          On exit, the triangular factor U or L from the Cholesky
00114 *>          factorization B = U**H*U or B = L*L**H, in the same storage
00115 *>          format as B.
00116 *> \endverbatim
00117 *>
00118 *> \param[in] VL
00119 *> \verbatim
00120 *>          VL is REAL
00121 *> \endverbatim
00122 *>
00123 *> \param[in] VU
00124 *> \verbatim
00125 *>          VU is REAL
00126 *>
00127 *>          If RANGE='V', the lower and upper bounds of the interval to
00128 *>          be searched for eigenvalues. VL < VU.
00129 *>          Not referenced if RANGE = 'A' or 'I'.
00130 *> \endverbatim
00131 *>
00132 *> \param[in] IL
00133 *> \verbatim
00134 *>          IL is INTEGER
00135 *> \endverbatim
00136 *>
00137 *> \param[in] IU
00138 *> \verbatim
00139 *>          IU is INTEGER
00140 *>
00141 *>          If RANGE='I', the indices (in ascending order) of the
00142 *>          smallest and largest eigenvalues to be returned.
00143 *>          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
00144 *>          Not referenced if RANGE = 'A' or 'V'.
00145 *> \endverbatim
00146 *>
00147 *> \param[in] ABSTOL
00148 *> \verbatim
00149 *>          ABSTOL is REAL
00150 *>          The absolute error tolerance for the eigenvalues.
00151 *>          An approximate eigenvalue is accepted as converged
00152 *>          when it is determined to lie in an interval [a,b]
00153 *>          of width less than or equal to
00154 *>
00155 *>                  ABSTOL + EPS *   max( |a|,|b| ) ,
00156 *>
00157 *>          where EPS is the machine precision.  If ABSTOL is less than
00158 *>          or equal to zero, then  EPS*|T|  will be used in its place,
00159 *>          where |T| is the 1-norm of the tridiagonal matrix obtained
00160 *>          by reducing AP to tridiagonal form.
00161 *>
00162 *>          Eigenvalues will be computed most accurately when ABSTOL is
00163 *>          set to twice the underflow threshold 2*SLAMCH('S'), not zero.
00164 *>          If this routine returns with INFO>0, indicating that some
00165 *>          eigenvectors did not converge, try setting ABSTOL to
00166 *>          2*SLAMCH('S').
00167 *> \endverbatim
00168 *>
00169 *> \param[out] M
00170 *> \verbatim
00171 *>          M is INTEGER
00172 *>          The total number of eigenvalues found.  0 <= M <= N.
00173 *>          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
00174 *> \endverbatim
00175 *>
00176 *> \param[out] W
00177 *> \verbatim
00178 *>          W is REAL array, dimension (N)
00179 *>          On normal exit, the first M elements contain the selected
00180 *>          eigenvalues in ascending order.
00181 *> \endverbatim
00182 *>
00183 *> \param[out] Z
00184 *> \verbatim
00185 *>          Z is COMPLEX array, dimension (LDZ, N)
00186 *>          If JOBZ = 'N', then Z is not referenced.
00187 *>          If JOBZ = 'V', then if INFO = 0, the first M columns of Z
00188 *>          contain the orthonormal eigenvectors of the matrix A
00189 *>          corresponding to the selected eigenvalues, with the i-th
00190 *>          column of Z holding the eigenvector associated with W(i).
00191 *>          The eigenvectors are normalized as follows:
00192 *>          if ITYPE = 1 or 2, Z**H*B*Z = I;
00193 *>          if ITYPE = 3, Z**H*inv(B)*Z = I.
00194 *>
00195 *>          If an eigenvector fails to converge, then that column of Z
00196 *>          contains the latest approximation to the eigenvector, and the
00197 *>          index of the eigenvector is returned in IFAIL.
00198 *>          Note: the user must ensure that at least max(1,M) columns are
00199 *>          supplied in the array Z; if RANGE = 'V', the exact value of M
00200 *>          is not known in advance and an upper bound must be used.
00201 *> \endverbatim
00202 *>
00203 *> \param[in] LDZ
00204 *> \verbatim
00205 *>          LDZ is INTEGER
00206 *>          The leading dimension of the array Z.  LDZ >= 1, and if
00207 *>          JOBZ = 'V', LDZ >= max(1,N).
00208 *> \endverbatim
00209 *>
00210 *> \param[out] WORK
00211 *> \verbatim
00212 *>          WORK is COMPLEX array, dimension (2*N)
00213 *> \endverbatim
00214 *>
00215 *> \param[out] RWORK
00216 *> \verbatim
00217 *>          RWORK is REAL array, dimension (7*N)
00218 *> \endverbatim
00219 *>
00220 *> \param[out] IWORK
00221 *> \verbatim
00222 *>          IWORK is INTEGER array, dimension (5*N)
00223 *> \endverbatim
00224 *>
00225 *> \param[out] IFAIL
00226 *> \verbatim
00227 *>          IFAIL is INTEGER array, dimension (N)
00228 *>          If JOBZ = 'V', then if INFO = 0, the first M elements of
00229 *>          IFAIL are zero.  If INFO > 0, then IFAIL contains the
00230 *>          indices of the eigenvectors that failed to converge.
00231 *>          If JOBZ = 'N', then IFAIL is not referenced.
00232 *> \endverbatim
00233 *>
00234 *> \param[out] INFO
00235 *> \verbatim
00236 *>          INFO is INTEGER
00237 *>          = 0:  successful exit
00238 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00239 *>          > 0:  CPPTRF or CHPEVX returned an error code:
00240 *>             <= N:  if INFO = i, CHPEVX failed to converge;
00241 *>                    i eigenvectors failed to converge.  Their indices
00242 *>                    are stored in array IFAIL.
00243 *>             > N:   if INFO = N + i, for 1 <= i <= n, then the leading
00244 *>                    minor of order i of B is not positive definite.
00245 *>                    The factorization of B could not be completed and
00246 *>                    no eigenvalues or eigenvectors were computed.
00247 *> \endverbatim
00248 *
00249 *  Authors:
00250 *  ========
00251 *
00252 *> \author Univ. of Tennessee 
00253 *> \author Univ. of California Berkeley 
00254 *> \author Univ. of Colorado Denver 
00255 *> \author NAG Ltd. 
00256 *
00257 *> \date November 2011
00258 *
00259 *> \ingroup complexOTHEReigen
00260 *
00261 *> \par Contributors:
00262 *  ==================
00263 *>
00264 *>     Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
00265 *
00266 *  =====================================================================
00267       SUBROUTINE CHPGVX( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
00268      $                   IL, IU, ABSTOL, M, W, Z, LDZ, WORK, RWORK,
00269      $                   IWORK, IFAIL, INFO )
00270 *
00271 *  -- LAPACK driver routine (version 3.4.0) --
00272 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00273 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00274 *     November 2011
00275 *
00276 *     .. Scalar Arguments ..
00277       CHARACTER          JOBZ, RANGE, UPLO
00278       INTEGER            IL, INFO, ITYPE, IU, LDZ, M, N
00279       REAL               ABSTOL, VL, VU
00280 *     ..
00281 *     .. Array Arguments ..
00282       INTEGER            IFAIL( * ), IWORK( * )
00283       REAL               RWORK( * ), W( * )
00284       COMPLEX            AP( * ), BP( * ), WORK( * ), Z( LDZ, * )
00285 *     ..
00286 *
00287 *  =====================================================================
00288 *
00289 *     .. Local Scalars ..
00290       LOGICAL            ALLEIG, INDEIG, UPPER, VALEIG, WANTZ
00291       CHARACTER          TRANS
00292       INTEGER            J
00293 *     ..
00294 *     .. External Functions ..
00295       LOGICAL            LSAME
00296       EXTERNAL           LSAME
00297 *     ..
00298 *     .. External Subroutines ..
00299       EXTERNAL           CHPEVX, CHPGST, CPPTRF, CTPMV, CTPSV, XERBLA
00300 *     ..
00301 *     .. Intrinsic Functions ..
00302       INTRINSIC          MIN
00303 *     ..
00304 *     .. Executable Statements ..
00305 *
00306 *     Test the input parameters.
00307 *
00308       WANTZ = LSAME( JOBZ, 'V' )
00309       UPPER = LSAME( UPLO, 'U' )
00310       ALLEIG = LSAME( RANGE, 'A' )
00311       VALEIG = LSAME( RANGE, 'V' )
00312       INDEIG = LSAME( RANGE, 'I' )
00313 *
00314       INFO = 0
00315       IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00316          INFO = -1
00317       ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00318          INFO = -2
00319       ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
00320          INFO = -3
00321       ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
00322          INFO = -4
00323       ELSE IF( N.LT.0 ) THEN
00324          INFO = -5
00325       ELSE 
00326          IF( VALEIG ) THEN
00327             IF( N.GT.0 .AND. VU.LE.VL ) THEN
00328                INFO = -9
00329             END IF
00330          ELSE IF( INDEIG ) THEN
00331             IF( IL.LT.1 ) THEN
00332                INFO = -10
00333             ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
00334                INFO = -11
00335             END IF
00336          END IF
00337       END IF
00338       IF( INFO.EQ.0 ) THEN
00339          IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
00340             INFO = -16
00341          END IF
00342       END IF
00343 *
00344       IF( INFO.NE.0 ) THEN
00345          CALL XERBLA( 'CHPGVX', -INFO )
00346          RETURN
00347       END IF
00348 *
00349 *     Quick return if possible
00350 *
00351       IF( N.EQ.0 )
00352      $   RETURN
00353 *
00354 *     Form a Cholesky factorization of B.
00355 *
00356       CALL CPPTRF( UPLO, N, BP, INFO )
00357       IF( INFO.NE.0 ) THEN
00358          INFO = N + INFO
00359          RETURN
00360       END IF
00361 *
00362 *     Transform problem to standard eigenvalue problem and solve.
00363 *
00364       CALL CHPGST( ITYPE, UPLO, N, AP, BP, INFO )
00365       CALL CHPEVX( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU, ABSTOL, M,
00366      $             W, Z, LDZ, WORK, RWORK, IWORK, IFAIL, INFO )
00367 *
00368       IF( WANTZ ) THEN
00369 *
00370 *        Backtransform eigenvectors to the original problem.
00371 *
00372          IF( INFO.GT.0 )
00373      $      M = INFO - 1
00374          IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
00375 *
00376 *           For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
00377 *           backtransform eigenvectors: x = inv(L)**H*y or inv(U)*y
00378 *
00379             IF( UPPER ) THEN
00380                TRANS = 'N'
00381             ELSE
00382                TRANS = 'C'
00383             END IF
00384 *
00385             DO 10 J = 1, M
00386                CALL CTPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00387      $                     1 )
00388    10       CONTINUE
00389 *
00390          ELSE IF( ITYPE.EQ.3 ) THEN
00391 *
00392 *           For B*A*x=(lambda)*x;
00393 *           backtransform eigenvectors: x = L*y or U**H*y
00394 *
00395             IF( UPPER ) THEN
00396                TRANS = 'C'
00397             ELSE
00398                TRANS = 'N'
00399             END IF
00400 *
00401             DO 20 J = 1, M
00402                CALL CTPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00403      $                     1 )
00404    20       CONTINUE
00405          END IF
00406       END IF
00407 *
00408       RETURN
00409 *
00410 *     End of CHPGVX
00411 *
00412       END
 All Files Functions