LAPACK 3.3.0

zhpgv.f

Go to the documentation of this file.
00001       SUBROUTINE ZHPGV( ITYPE, JOBZ, UPLO, N, AP, BP, W, Z, LDZ, WORK,
00002      $                  RWORK, INFO )
00003 *
00004 *  -- LAPACK driver routine (version 3.2) --
00005 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00006 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00007 *     November 2006
00008 *
00009 *     .. Scalar Arguments ..
00010       CHARACTER          JOBZ, UPLO
00011       INTEGER            INFO, ITYPE, LDZ, N
00012 *     ..
00013 *     .. Array Arguments ..
00014       DOUBLE PRECISION   RWORK( * ), W( * )
00015       COMPLEX*16         AP( * ), BP( * ), WORK( * ), Z( LDZ, * )
00016 *     ..
00017 *
00018 *  Purpose
00019 *  =======
00020 *
00021 *  ZHPGV computes all the eigenvalues and, optionally, the eigenvectors
00022 *  of a complex generalized Hermitian-definite eigenproblem, of the form
00023 *  A*x=(lambda)*B*x,  A*Bx=(lambda)*x,  or B*A*x=(lambda)*x.
00024 *  Here A and B are assumed to be Hermitian, stored in packed format,
00025 *  and B is also positive definite.
00026 *
00027 *  Arguments
00028 *  =========
00029 *
00030 *  ITYPE   (input) INTEGER
00031 *          Specifies the problem type to be solved:
00032 *          = 1:  A*x = (lambda)*B*x
00033 *          = 2:  A*B*x = (lambda)*x
00034 *          = 3:  B*A*x = (lambda)*x
00035 *
00036 *  JOBZ    (input) CHARACTER*1
00037 *          = 'N':  Compute eigenvalues only;
00038 *          = 'V':  Compute eigenvalues and eigenvectors.
00039 *
00040 *  UPLO    (input) CHARACTER*1
00041 *          = 'U':  Upper triangles of A and B are stored;
00042 *          = 'L':  Lower triangles of A and B are stored.
00043 *
00044 *  N       (input) INTEGER
00045 *          The order of the matrices A and B.  N >= 0.
00046 *
00047 *  AP      (input/output) COMPLEX*16 array, dimension (N*(N+1)/2)
00048 *          On entry, the upper or lower triangle of the Hermitian matrix
00049 *          A, packed columnwise in a linear array.  The j-th column of A
00050 *          is stored in the array AP as follows:
00051 *          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00052 *          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
00053 *
00054 *          On exit, the contents of AP are destroyed.
00055 *
00056 *  BP      (input/output) COMPLEX*16 array, dimension (N*(N+1)/2)
00057 *          On entry, the upper or lower triangle of the Hermitian matrix
00058 *          B, packed columnwise in a linear array.  The j-th column of B
00059 *          is stored in the array BP as follows:
00060 *          if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j;
00061 *          if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n.
00062 *
00063 *          On exit, the triangular factor U or L from the Cholesky
00064 *          factorization B = U**H*U or B = L*L**H, in the same storage
00065 *          format as B.
00066 *
00067 *  W       (output) DOUBLE PRECISION array, dimension (N)
00068 *          If INFO = 0, the eigenvalues in ascending order.
00069 *
00070 *  Z       (output) COMPLEX*16 array, dimension (LDZ, N)
00071 *          If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of
00072 *          eigenvectors.  The eigenvectors are normalized as follows:
00073 *          if ITYPE = 1 or 2, Z**H*B*Z = I;
00074 *          if ITYPE = 3, Z**H*inv(B)*Z = I.
00075 *          If JOBZ = 'N', then Z is not referenced.
00076 *
00077 *  LDZ     (input) INTEGER
00078 *          The leading dimension of the array Z.  LDZ >= 1, and if
00079 *          JOBZ = 'V', LDZ >= max(1,N).
00080 *
00081 *  WORK    (workspace) COMPLEX*16 array, dimension (max(1, 2*N-1))
00082 *
00083 *  RWORK   (workspace) DOUBLE PRECISION array, dimension (max(1, 3*N-2))
00084 *
00085 *  INFO    (output) INTEGER
00086 *          = 0:  successful exit
00087 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00088 *          > 0:  ZPPTRF or ZHPEV returned an error code:
00089 *             <= N:  if INFO = i, ZHPEV failed to converge;
00090 *                    i off-diagonal elements of an intermediate
00091 *                    tridiagonal form did not convergeto zero;
00092 *             > N:   if INFO = N + i, for 1 <= i <= n, then the leading
00093 *                    minor of order i of B is not positive definite.
00094 *                    The factorization of B could not be completed and
00095 *                    no eigenvalues or eigenvectors were computed.
00096 *
00097 *  =====================================================================
00098 *
00099 *     .. Local Scalars ..
00100       LOGICAL            UPPER, WANTZ
00101       CHARACTER          TRANS
00102       INTEGER            J, NEIG
00103 *     ..
00104 *     .. External Functions ..
00105       LOGICAL            LSAME
00106       EXTERNAL           LSAME
00107 *     ..
00108 *     .. External Subroutines ..
00109       EXTERNAL           XERBLA, ZHPEV, ZHPGST, ZPPTRF, ZTPMV, ZTPSV
00110 *     ..
00111 *     .. Executable Statements ..
00112 *
00113 *     Test the input parameters.
00114 *
00115       WANTZ = LSAME( JOBZ, 'V' )
00116       UPPER = LSAME( UPLO, 'U' )
00117 *
00118       INFO = 0
00119       IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00120          INFO = -1
00121       ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00122          INFO = -2
00123       ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
00124          INFO = -3
00125       ELSE IF( N.LT.0 ) THEN
00126          INFO = -4
00127       ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
00128          INFO = -9
00129       END IF
00130       IF( INFO.NE.0 ) THEN
00131          CALL XERBLA( 'ZHPGV ', -INFO )
00132          RETURN
00133       END IF
00134 *
00135 *     Quick return if possible
00136 *
00137       IF( N.EQ.0 )
00138      $   RETURN
00139 *
00140 *     Form a Cholesky factorization of B.
00141 *
00142       CALL ZPPTRF( UPLO, N, BP, INFO )
00143       IF( INFO.NE.0 ) THEN
00144          INFO = N + INFO
00145          RETURN
00146       END IF
00147 *
00148 *     Transform problem to standard eigenvalue problem and solve.
00149 *
00150       CALL ZHPGST( ITYPE, UPLO, N, AP, BP, INFO )
00151       CALL ZHPEV( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, RWORK, INFO )
00152 *
00153       IF( WANTZ ) THEN
00154 *
00155 *        Backtransform eigenvectors to the original problem.
00156 *
00157          NEIG = N
00158          IF( INFO.GT.0 )
00159      $      NEIG = INFO - 1
00160          IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
00161 *
00162 *           For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
00163 *           backtransform eigenvectors: x = inv(L)'*y or inv(U)*y
00164 *
00165             IF( UPPER ) THEN
00166                TRANS = 'N'
00167             ELSE
00168                TRANS = 'C'
00169             END IF
00170 *
00171             DO 10 J = 1, NEIG
00172                CALL ZTPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00173      $                     1 )
00174    10       CONTINUE
00175 *
00176          ELSE IF( ITYPE.EQ.3 ) THEN
00177 *
00178 *           For B*A*x=(lambda)*x;
00179 *           backtransform eigenvectors: x = L*y or U'*y
00180 *
00181             IF( UPPER ) THEN
00182                TRANS = 'C'
00183             ELSE
00184                TRANS = 'N'
00185             END IF
00186 *
00187             DO 20 J = 1, NEIG
00188                CALL ZTPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00189      $                     1 )
00190    20       CONTINUE
00191          END IF
00192       END IF
00193       RETURN
00194 *
00195 *     End of ZHPGV
00196 *
00197       END
 All Files Functions