LAPACK 3.3.0

chpgvx.f

Go to the documentation of this file.
00001       SUBROUTINE CHPGVX( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
00002      $                   IL, IU, ABSTOL, M, W, Z, LDZ, WORK, RWORK,
00003      $                   IWORK, IFAIL, INFO )
00004 *
00005 *  -- LAPACK driver routine (version 3.2) --
00006 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00007 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00008 *     November 2006
00009 *
00010 *     .. Scalar Arguments ..
00011       CHARACTER          JOBZ, RANGE, UPLO
00012       INTEGER            IL, INFO, ITYPE, IU, LDZ, M, N
00013       REAL               ABSTOL, VL, VU
00014 *     ..
00015 *     .. Array Arguments ..
00016       INTEGER            IFAIL( * ), IWORK( * )
00017       REAL               RWORK( * ), W( * )
00018       COMPLEX            AP( * ), BP( * ), WORK( * ), Z( LDZ, * )
00019 *     ..
00020 *
00021 *  Purpose
00022 *  =======
00023 *
00024 *  CHPGVX computes selected eigenvalues and, optionally, eigenvectors
00025 *  of a complex generalized Hermitian-definite eigenproblem, of the form
00026 *  A*x=(lambda)*B*x,  A*Bx=(lambda)*x,  or B*A*x=(lambda)*x.  Here A and
00027 *  B are assumed to be Hermitian, stored in packed format, and B is also
00028 *  positive definite.  Eigenvalues and eigenvectors can be selected by
00029 *  specifying either a range of values or a range of indices for the
00030 *  desired eigenvalues.
00031 *
00032 *  Arguments
00033 *  =========
00034 *
00035 *  ITYPE   (input) INTEGER
00036 *          Specifies the problem type to be solved:
00037 *          = 1:  A*x = (lambda)*B*x
00038 *          = 2:  A*B*x = (lambda)*x
00039 *          = 3:  B*A*x = (lambda)*x
00040 *
00041 *  JOBZ    (input) CHARACTER*1
00042 *          = 'N':  Compute eigenvalues only;
00043 *          = 'V':  Compute eigenvalues and eigenvectors.
00044 *
00045 *  RANGE   (input) CHARACTER*1
00046 *          = 'A': all eigenvalues will be found;
00047 *          = 'V': all eigenvalues in the half-open interval (VL,VU]
00048 *                 will be found;
00049 *          = 'I': the IL-th through IU-th eigenvalues will be found.
00050 *
00051 *  UPLO    (input) CHARACTER*1
00052 *          = 'U':  Upper triangles of A and B are stored;
00053 *          = 'L':  Lower triangles of A and B are stored.
00054 *
00055 *  N       (input) INTEGER
00056 *          The order of the matrices A and B.  N >= 0.
00057 *
00058 *  AP      (input/output) COMPLEX array, dimension (N*(N+1)/2)
00059 *          On entry, the upper or lower triangle of the Hermitian matrix
00060 *          A, packed columnwise in a linear array.  The j-th column of A
00061 *          is stored in the array AP as follows:
00062 *          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00063 *          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
00064 *
00065 *          On exit, the contents of AP are destroyed.
00066 *
00067 *  BP      (input/output) COMPLEX array, dimension (N*(N+1)/2)
00068 *          On entry, the upper or lower triangle of the Hermitian matrix
00069 *          B, packed columnwise in a linear array.  The j-th column of B
00070 *          is stored in the array BP as follows:
00071 *          if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j;
00072 *          if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n.
00073 *
00074 *          On exit, the triangular factor U or L from the Cholesky
00075 *          factorization B = U**H*U or B = L*L**H, in the same storage
00076 *          format as B.
00077 *
00078 *  VL      (input) REAL
00079 *  VU      (input) REAL
00080 *          If RANGE='V', the lower and upper bounds of the interval to
00081 *          be searched for eigenvalues. VL < VU.
00082 *          Not referenced if RANGE = 'A' or 'I'.
00083 *
00084 *  IL      (input) INTEGER
00085 *  IU      (input) INTEGER
00086 *          If RANGE='I', the indices (in ascending order) of the
00087 *          smallest and largest eigenvalues to be returned.
00088 *          1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
00089 *          Not referenced if RANGE = 'A' or 'V'.
00090 *
00091 *  ABSTOL  (input) REAL
00092 *          The absolute error tolerance for the eigenvalues.
00093 *          An approximate eigenvalue is accepted as converged
00094 *          when it is determined to lie in an interval [a,b]
00095 *          of width less than or equal to
00096 *
00097 *                  ABSTOL + EPS *   max( |a|,|b| ) ,
00098 *
00099 *          where EPS is the machine precision.  If ABSTOL is less than
00100 *          or equal to zero, then  EPS*|T|  will be used in its place,
00101 *          where |T| is the 1-norm of the tridiagonal matrix obtained
00102 *          by reducing AP to tridiagonal form.
00103 *
00104 *          Eigenvalues will be computed most accurately when ABSTOL is
00105 *          set to twice the underflow threshold 2*SLAMCH('S'), not zero.
00106 *          If this routine returns with INFO>0, indicating that some
00107 *          eigenvectors did not converge, try setting ABSTOL to
00108 *          2*SLAMCH('S').
00109 *
00110 *  M       (output) INTEGER
00111 *          The total number of eigenvalues found.  0 <= M <= N.
00112 *          If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
00113 *
00114 *  W       (output) REAL array, dimension (N)
00115 *          On normal exit, the first M elements contain the selected
00116 *          eigenvalues in ascending order.
00117 *
00118 *  Z       (output) COMPLEX array, dimension (LDZ, N)
00119 *          If JOBZ = 'N', then Z is not referenced.
00120 *          If JOBZ = 'V', then if INFO = 0, the first M columns of Z
00121 *          contain the orthonormal eigenvectors of the matrix A
00122 *          corresponding to the selected eigenvalues, with the i-th
00123 *          column of Z holding the eigenvector associated with W(i).
00124 *          The eigenvectors are normalized as follows:
00125 *          if ITYPE = 1 or 2, Z**H*B*Z = I;
00126 *          if ITYPE = 3, Z**H*inv(B)*Z = I.
00127 *
00128 *          If an eigenvector fails to converge, then that column of Z
00129 *          contains the latest approximation to the eigenvector, and the
00130 *          index of the eigenvector is returned in IFAIL.
00131 *          Note: the user must ensure that at least max(1,M) columns are
00132 *          supplied in the array Z; if RANGE = 'V', the exact value of M
00133 *          is not known in advance and an upper bound must be used.
00134 *
00135 *  LDZ     (input) INTEGER
00136 *          The leading dimension of the array Z.  LDZ >= 1, and if
00137 *          JOBZ = 'V', LDZ >= max(1,N).
00138 *
00139 *  WORK    (workspace) COMPLEX array, dimension (2*N)
00140 *
00141 *  RWORK   (workspace) REAL array, dimension (7*N)
00142 *
00143 *  IWORK   (workspace) INTEGER array, dimension (5*N)
00144 *
00145 *  IFAIL   (output) INTEGER array, dimension (N)
00146 *          If JOBZ = 'V', then if INFO = 0, the first M elements of
00147 *          IFAIL are zero.  If INFO > 0, then IFAIL contains the
00148 *          indices of the eigenvectors that failed to converge.
00149 *          If JOBZ = 'N', then IFAIL is not referenced.
00150 *
00151 *  INFO    (output) INTEGER
00152 *          = 0:  successful exit
00153 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00154 *          > 0:  CPPTRF or CHPEVX returned an error code:
00155 *             <= N:  if INFO = i, CHPEVX failed to converge;
00156 *                    i eigenvectors failed to converge.  Their indices
00157 *                    are stored in array IFAIL.
00158 *             > N:   if INFO = N + i, for 1 <= i <= n, then the leading
00159 *                    minor of order i of B is not positive definite.
00160 *                    The factorization of B could not be completed and
00161 *                    no eigenvalues or eigenvectors were computed.
00162 *
00163 *  Further Details
00164 *  ===============
00165 *
00166 *  Based on contributions by
00167 *     Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
00168 *
00169 *  =====================================================================
00170 *
00171 *     .. Local Scalars ..
00172       LOGICAL            ALLEIG, INDEIG, UPPER, VALEIG, WANTZ
00173       CHARACTER          TRANS
00174       INTEGER            J
00175 *     ..
00176 *     .. External Functions ..
00177       LOGICAL            LSAME
00178       EXTERNAL           LSAME
00179 *     ..
00180 *     .. External Subroutines ..
00181       EXTERNAL           CHPEVX, CHPGST, CPPTRF, CTPMV, CTPSV, XERBLA
00182 *     ..
00183 *     .. Intrinsic Functions ..
00184       INTRINSIC          MIN
00185 *     ..
00186 *     .. Executable Statements ..
00187 *
00188 *     Test the input parameters.
00189 *
00190       WANTZ = LSAME( JOBZ, 'V' )
00191       UPPER = LSAME( UPLO, 'U' )
00192       ALLEIG = LSAME( RANGE, 'A' )
00193       VALEIG = LSAME( RANGE, 'V' )
00194       INDEIG = LSAME( RANGE, 'I' )
00195 *
00196       INFO = 0
00197       IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00198          INFO = -1
00199       ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00200          INFO = -2
00201       ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
00202          INFO = -3
00203       ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
00204          INFO = -4
00205       ELSE IF( N.LT.0 ) THEN
00206          INFO = -5
00207       ELSE 
00208          IF( VALEIG ) THEN
00209             IF( N.GT.0 .AND. VU.LE.VL ) THEN
00210                INFO = -9
00211             END IF
00212          ELSE IF( INDEIG ) THEN
00213             IF( IL.LT.1 ) THEN
00214                INFO = -10
00215             ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
00216                INFO = -11
00217             END IF
00218          END IF
00219       END IF
00220       IF( INFO.EQ.0 ) THEN
00221          IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
00222             INFO = -16
00223          END IF
00224       END IF
00225 *
00226       IF( INFO.NE.0 ) THEN
00227          CALL XERBLA( 'CHPGVX', -INFO )
00228          RETURN
00229       END IF
00230 *
00231 *     Quick return if possible
00232 *
00233       IF( N.EQ.0 )
00234      $   RETURN
00235 *
00236 *     Form a Cholesky factorization of B.
00237 *
00238       CALL CPPTRF( UPLO, N, BP, INFO )
00239       IF( INFO.NE.0 ) THEN
00240          INFO = N + INFO
00241          RETURN
00242       END IF
00243 *
00244 *     Transform problem to standard eigenvalue problem and solve.
00245 *
00246       CALL CHPGST( ITYPE, UPLO, N, AP, BP, INFO )
00247       CALL CHPEVX( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU, ABSTOL, M,
00248      $             W, Z, LDZ, WORK, RWORK, IWORK, IFAIL, INFO )
00249 *
00250       IF( WANTZ ) THEN
00251 *
00252 *        Backtransform eigenvectors to the original problem.
00253 *
00254          IF( INFO.GT.0 )
00255      $      M = INFO - 1
00256          IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
00257 *
00258 *           For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
00259 *           backtransform eigenvectors: x = inv(L)'*y or inv(U)*y
00260 *
00261             IF( UPPER ) THEN
00262                TRANS = 'N'
00263             ELSE
00264                TRANS = 'C'
00265             END IF
00266 *
00267             DO 10 J = 1, M
00268                CALL CTPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00269      $                     1 )
00270    10       CONTINUE
00271 *
00272          ELSE IF( ITYPE.EQ.3 ) THEN
00273 *
00274 *           For B*A*x=(lambda)*x;
00275 *           backtransform eigenvectors: x = L*y or U'*y
00276 *
00277             IF( UPPER ) THEN
00278                TRANS = 'C'
00279             ELSE
00280                TRANS = 'N'
00281             END IF
00282 *
00283             DO 20 J = 1, M
00284                CALL CTPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00285      $                     1 )
00286    20       CONTINUE
00287          END IF
00288       END IF
00289 *
00290       RETURN
00291 *
00292 *     End of CHPGVX
00293 *
00294       END
 All Files Functions