LAPACK 3.3.1
Linear Algebra PACKage

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.3.1) --
00005 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00006 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00007 *  -- April 2011                                                      --
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          IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
00195             INFO = -11
00196          ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
00197             INFO = -13
00198          END IF
00199       END IF
00200 *
00201       IF( INFO.NE.0 ) THEN
00202          CALL XERBLA( 'DSPGVD', -INFO )
00203          RETURN
00204       ELSE IF( LQUERY ) THEN
00205          RETURN
00206       END IF
00207 *
00208 *     Quick return if possible
00209 *
00210       IF( N.EQ.0 )
00211      $   RETURN
00212 *
00213 *     Form a Cholesky factorization of BP.
00214 *
00215       CALL DPPTRF( UPLO, N, BP, INFO )
00216       IF( INFO.NE.0 ) THEN
00217          INFO = N + INFO
00218          RETURN
00219       END IF
00220 *
00221 *     Transform problem to standard eigenvalue problem and solve.
00222 *
00223       CALL DSPGST( ITYPE, UPLO, N, AP, BP, INFO )
00224       CALL DSPEVD( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, LWORK, IWORK,
00225      $             LIWORK, INFO )
00226       LWMIN = MAX( DBLE( LWMIN ), DBLE( WORK( 1 ) ) )
00227       LIWMIN = MAX( DBLE( LIWMIN ), DBLE( IWORK( 1 ) ) )
00228 *
00229       IF( WANTZ ) THEN
00230 *
00231 *        Backtransform eigenvectors to the original problem.
00232 *
00233          NEIG = N
00234          IF( INFO.GT.0 )
00235      $      NEIG = INFO - 1
00236          IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
00237 *
00238 *           For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
00239 *           backtransform eigenvectors: x = inv(L)**T *y or inv(U)*y
00240 *
00241             IF( UPPER ) THEN
00242                TRANS = 'N'
00243             ELSE
00244                TRANS = 'T'
00245             END IF
00246 *
00247             DO 10 J = 1, NEIG
00248                CALL DTPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00249      $                     1 )
00250    10       CONTINUE
00251 *
00252          ELSE IF( ITYPE.EQ.3 ) THEN
00253 *
00254 *           For B*A*x=(lambda)*x;
00255 *           backtransform eigenvectors: x = L*y or U**T *y
00256 *
00257             IF( UPPER ) THEN
00258                TRANS = 'T'
00259             ELSE
00260                TRANS = 'N'
00261             END IF
00262 *
00263             DO 20 J = 1, NEIG
00264                CALL DTPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
00265      $                     1 )
00266    20       CONTINUE
00267          END IF
00268       END IF
00269 *
00270       WORK( 1 ) = LWMIN
00271       IWORK( 1 ) = LIWMIN
00272 *
00273       RETURN
00274 *
00275 *     End of DSPGVD
00276 *
00277       END
 All Files Functions