LAPACK 3.3.0

dspgvd.f

Go to the documentation of this file.
00001       SUBROUTINE DSPGVD( ITYPE, JOBZ, UPLO, N, AP, BP, W, Z, LDZ, WORK,
00002      $                   LWORK, IWORK, LIWORK, 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, LIWORK, LWORK, N
00012 *     ..
00013 *     .. Array Arguments ..
00014       INTEGER            IWORK( * )
00015       DOUBLE PRECISION   AP( * ), BP( * ), W( * ), WORK( * ),
00016      $                   Z( LDZ, * )
00017 *     ..
00018 *
00019 *  Purpose
00020 *  =======
00021 *
00022 *  DSPGVD computes all the eigenvalues, and optionally, the eigenvectors
00023 *  of a real generalized symmetric-definite eigenproblem, of the form
00024 *  A*x=(lambda)*B*x,  A*Bx=(lambda)*x,  or B*A*x=(lambda)*x.  Here A and
00025 *  B are assumed to be symmetric, stored in packed format, and B is also
00026 *  positive definite.
00027 *  If eigenvectors are desired, it uses a divide and conquer algorithm.
00028 *
00029 *  The divide and conquer algorithm makes very mild assumptions about
00030 *  floating point arithmetic. It will work on machines with a guard
00031 *  digit in add/subtract, or on those binary machines without guard
00032 *  digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
00033 *  Cray-2. It could conceivably fail on hexadecimal or decimal machines
00034 *  without guard digits, but we know of none.
00035 *
00036 *  Arguments
00037 *  =========
00038 *
00039 *  ITYPE   (input) INTEGER
00040 *          Specifies the problem type to be solved:
00041 *          = 1:  A*x = (lambda)*B*x
00042 *          = 2:  A*B*x = (lambda)*x
00043 *          = 3:  B*A*x = (lambda)*x
00044 *
00045 *  JOBZ    (input) CHARACTER*1
00046 *          = 'N':  Compute eigenvalues only;
00047 *          = 'V':  Compute eigenvalues and eigenvectors.
00048 *
00049 *  UPLO    (input) CHARACTER*1
00050 *          = 'U':  Upper triangles of A and B are stored;
00051 *          = 'L':  Lower triangles of A and B are stored.
00052 *
00053 *  N       (input) INTEGER
00054 *          The order of the matrices A and B.  N >= 0.
00055 *
00056 *  AP      (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
00057 *          On entry, the upper or lower triangle of the symmetric matrix
00058 *          A, packed columnwise in a linear array.  The j-th column of A
00059 *          is stored in the array AP as follows:
00060 *          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00061 *          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
00062 *
00063 *          On exit, the contents of AP are destroyed.
00064 *
00065 *  BP      (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
00066 *          On entry, the upper or lower triangle of the symmetric matrix
00067 *          B, packed columnwise in a linear array.  The j-th column of B
00068 *          is stored in the array BP as follows:
00069 *          if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j;
00070 *          if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n.
00071 *
00072 *          On exit, the triangular factor U or L from the Cholesky
00073 *          factorization B = U**T*U or B = L*L**T, in the same storage
00074 *          format as B.
00075 *
00076 *  W       (output) DOUBLE PRECISION array, dimension (N)
00077 *          If INFO = 0, the eigenvalues in ascending order.
00078 *
00079 *  Z       (output) DOUBLE PRECISION array, dimension (LDZ, N)
00080 *          If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of
00081 *          eigenvectors.  The eigenvectors are normalized as follows:
00082 *          if ITYPE = 1 or 2, Z**T*B*Z = I;
00083 *          if ITYPE = 3, Z**T*inv(B)*Z = I.
00084 *          If JOBZ = 'N', then Z is not referenced.
00085 *
00086 *  LDZ     (input) INTEGER
00087 *          The leading dimension of the array Z.  LDZ >= 1, and if
00088 *          JOBZ = 'V', LDZ >= max(1,N).
00089 *
00090 *  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
00091 *          On exit, if INFO = 0, WORK(1) returns the required LWORK.
00092 *
00093 *  LWORK   (input) INTEGER
00094 *          The dimension of the array WORK.
00095 *          If N <= 1,               LWORK >= 1.
00096 *          If JOBZ = 'N' and N > 1, LWORK >= 2*N.
00097 *          If JOBZ = 'V' and N > 1, LWORK >= 1 + 6*N + 2*N**2.
00098 *
00099 *          If LWORK = -1, then a workspace query is assumed; the routine
00100 *          only calculates the required sizes of the WORK and IWORK
00101 *          arrays, returns these values as the first entries of the WORK
00102 *          and IWORK arrays, and no error message related to LWORK or
00103 *          LIWORK is issued by XERBLA.
00104 *
00105 *  IWORK   (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
00106 *          On exit, if INFO = 0, IWORK(1) returns the required LIWORK.
00107 *
00108 *  LIWORK  (input) INTEGER
00109 *          The dimension of the array IWORK.
00110 *          If JOBZ  = 'N' or N <= 1, LIWORK >= 1.
00111 *          If JOBZ  = 'V' and N > 1, LIWORK >= 3 + 5*N.
00112 *
00113 *          If LIWORK = -1, then a workspace query is assumed; the
00114 *          routine only calculates the required sizes of the WORK and
00115 *          IWORK arrays, returns these values as the first entries of
00116 *          the WORK and IWORK arrays, and no error message related to
00117 *          LWORK or LIWORK is issued by XERBLA.
00118 *
00119 *  INFO    (output) INTEGER
00120 *          = 0:  successful exit
00121 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00122 *          > 0:  DPPTRF or DSPEVD returned an error code:
00123 *             <= N:  if INFO = i, DSPEVD failed to converge;
00124 *                    i off-diagonal elements of an intermediate
00125 *                    tridiagonal form did not converge to zero;
00126 *             > N:   if INFO = N + i, for 1 <= i <= N, then the leading
00127 *                    minor of order i of B is not positive definite.
00128 *                    The factorization of B could not be completed and
00129 *                    no eigenvalues or eigenvectors were computed.
00130 *
00131 *  Further Details
00132 *  ===============
00133 *
00134 *  Based on contributions by
00135 *     Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
00136 *
00137 *  =====================================================================
00138 *
00139 *     .. Parameters ..
00140       DOUBLE PRECISION   TWO
00141       PARAMETER          ( TWO = 2.0D+0 )
00142 *     ..
00143 *     .. Local Scalars ..
00144       LOGICAL            LQUERY, UPPER, WANTZ
00145       CHARACTER          TRANS
00146       INTEGER            J, LIWMIN, LWMIN, NEIG
00147 *     ..
00148 *     .. External Functions ..
00149       LOGICAL            LSAME
00150       EXTERNAL           LSAME
00151 *     ..
00152 *     .. External Subroutines ..
00153       EXTERNAL           DPPTRF, DSPEVD, DSPGST, DTPMV, DTPSV, XERBLA
00154 *     ..
00155 *     .. Intrinsic Functions ..
00156       INTRINSIC          DBLE, MAX
00157 *     ..
00158 *     .. Executable Statements ..
00159 *
00160 *     Test the input parameters.
00161 *
00162       WANTZ = LSAME( JOBZ, 'V' )
00163       UPPER = LSAME( UPLO, 'U' )
00164       LQUERY = ( LWORK.EQ.-1 .OR. LIWORK.EQ.-1 )
00165 *
00166       INFO = 0
00167       IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00168          INFO = -1
00169       ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00170          INFO = -2
00171       ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
00172          INFO = -3
00173       ELSE IF( N.LT.0 ) THEN
00174          INFO = -4
00175       ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
00176          INFO = -9
00177       END IF
00178 *
00179       IF( INFO.EQ.0 ) THEN
00180          IF( N.LE.1 ) THEN
00181             LIWMIN = 1
00182             LWMIN = 1
00183          ELSE
00184             IF( WANTZ ) THEN
00185                LIWMIN = 3 + 5*N
00186                LWMIN = 1 + 6*N + 2*N**2
00187             ELSE
00188                LIWMIN = 1
00189                LWMIN = 2*N
00190             END IF
00191          END IF
00192          WORK( 1 ) = LWMIN
00193          IWORK( 1 ) = LIWMIN
00194 *
00195          IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
00196             INFO = -11
00197          ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
00198             INFO = -13
00199          END IF
00200       END IF
00201 *
00202       IF( INFO.NE.0 ) THEN
00203          CALL XERBLA( 'DSPGVD', -INFO )
00204          RETURN
00205       ELSE IF( LQUERY ) THEN
00206          RETURN
00207       END IF
00208 *
00209 *     Quick return if possible
00210 *
00211       IF( N.EQ.0 )
00212      $   RETURN
00213 *
00214 *     Form a Cholesky factorization of BP.
00215 *
00216       CALL DPPTRF( UPLO, N, BP, INFO )
00217       IF( INFO.NE.0 ) THEN
00218          INFO = N + INFO
00219          RETURN
00220       END IF
00221 *
00222 *     Transform problem to standard eigenvalue problem and solve.
00223 *
00224       CALL DSPGST( ITYPE, UPLO, N, AP, BP, INFO )
00225       CALL DSPEVD( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, LWORK, IWORK,
00226      $             LIWORK, INFO )
00227       LWMIN = MAX( DBLE( LWMIN ), DBLE( WORK( 1 ) ) )
00228       LIWMIN = MAX( DBLE( LIWMIN ), DBLE( IWORK( 1 ) ) )
00229 *
00230       IF( WANTZ ) THEN
00231 *
00232 *        Backtransform eigenvectors to the original problem.
00233 *
00234          NEIG = N
00235          IF( INFO.GT.0 )
00236      $      NEIG = INFO - 1
00237          IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
00238 *
00239 *           For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
00240 *           backtransform eigenvectors: x = inv(L)'*y or inv(U)*y
00241 *
00242             IF( UPPER ) THEN
00243                TRANS = 'N'
00244             ELSE
00245                TRANS = 'T'
00246             END IF
00247 *
00248             DO 10 J = 1, NEIG
00249                CALL DTPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00250      $                     1 )
00251    10       CONTINUE
00252 *
00253          ELSE IF( ITYPE.EQ.3 ) THEN
00254 *
00255 *           For B*A*x=(lambda)*x;
00256 *           backtransform eigenvectors: x = L*y or U'*y
00257 *
00258             IF( UPPER ) THEN
00259                TRANS = 'T'
00260             ELSE
00261                TRANS = 'N'
00262             END IF
00263 *
00264             DO 20 J = 1, NEIG
00265                CALL DTPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00266      $                     1 )
00267    20       CONTINUE
00268          END IF
00269       END IF
00270 *
00271       WORK( 1 ) = LWMIN
00272       IWORK( 1 ) = LIWMIN
00273 *
00274       RETURN
00275 *
00276 *     End of DSPGVD
00277 *
00278       END
 All Files Functions