LAPACK 3.3.0
|
00001 SUBROUTINE DSPGV( ITYPE, JOBZ, UPLO, N, AP, BP, W, Z, LDZ, WORK, 00002 $ 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 AP( * ), BP( * ), W( * ), WORK( * ), 00015 $ Z( LDZ, * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * DSPGV computes all the eigenvalues and, optionally, the eigenvectors 00022 * of a real generalized symmetric-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 symmetric, 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) DOUBLE PRECISION array, dimension 00048 * (N*(N+1)/2) 00049 * On entry, the upper or lower triangle of the symmetric matrix 00050 * A, packed columnwise in a linear array. The j-th column of A 00051 * is stored in the array AP as follows: 00052 * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; 00053 * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. 00054 * 00055 * On exit, the contents of AP are destroyed. 00056 * 00057 * BP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) 00058 * On entry, the upper or lower triangle of the symmetric matrix 00059 * B, packed columnwise in a linear array. The j-th column of B 00060 * is stored in the array BP as follows: 00061 * if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j; 00062 * if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n. 00063 * 00064 * On exit, the triangular factor U or L from the Cholesky 00065 * factorization B = U**T*U or B = L*L**T, in the same storage 00066 * format as B. 00067 * 00068 * W (output) DOUBLE PRECISION array, dimension (N) 00069 * If INFO = 0, the eigenvalues in ascending order. 00070 * 00071 * Z (output) DOUBLE PRECISION array, dimension (LDZ, N) 00072 * If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of 00073 * eigenvectors. The eigenvectors are normalized as follows: 00074 * if ITYPE = 1 or 2, Z**T*B*Z = I; 00075 * if ITYPE = 3, Z**T*inv(B)*Z = I. 00076 * If JOBZ = 'N', then Z is not referenced. 00077 * 00078 * LDZ (input) INTEGER 00079 * The leading dimension of the array Z. LDZ >= 1, and if 00080 * JOBZ = 'V', LDZ >= max(1,N). 00081 * 00082 * WORK (workspace) DOUBLE PRECISION array, dimension (3*N) 00083 * 00084 * INFO (output) INTEGER 00085 * = 0: successful exit 00086 * < 0: if INFO = -i, the i-th argument had an illegal value 00087 * > 0: DPPTRF or DSPEV returned an error code: 00088 * <= N: if INFO = i, DSPEV failed to converge; 00089 * i off-diagonal elements of an intermediate 00090 * tridiagonal form did not converge to zero. 00091 * > N: if INFO = n + i, for 1 <= i <= n, then the leading 00092 * minor of order i of B is not positive definite. 00093 * The factorization of B could not be completed and 00094 * no eigenvalues or eigenvectors were computed. 00095 * 00096 * ===================================================================== 00097 * 00098 * .. Local Scalars .. 00099 LOGICAL UPPER, WANTZ 00100 CHARACTER TRANS 00101 INTEGER J, NEIG 00102 * .. 00103 * .. External Functions .. 00104 LOGICAL LSAME 00105 EXTERNAL LSAME 00106 * .. 00107 * .. External Subroutines .. 00108 EXTERNAL DPPTRF, DSPEV, DSPGST, DTPMV, DTPSV, XERBLA 00109 * .. 00110 * .. Executable Statements .. 00111 * 00112 * Test the input parameters. 00113 * 00114 WANTZ = LSAME( JOBZ, 'V' ) 00115 UPPER = LSAME( UPLO, 'U' ) 00116 * 00117 INFO = 0 00118 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN 00119 INFO = -1 00120 ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN 00121 INFO = -2 00122 ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN 00123 INFO = -3 00124 ELSE IF( N.LT.0 ) THEN 00125 INFO = -4 00126 ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN 00127 INFO = -9 00128 END IF 00129 IF( INFO.NE.0 ) THEN 00130 CALL XERBLA( 'DSPGV ', -INFO ) 00131 RETURN 00132 END IF 00133 * 00134 * Quick return if possible 00135 * 00136 IF( N.EQ.0 ) 00137 $ RETURN 00138 * 00139 * Form a Cholesky factorization of B. 00140 * 00141 CALL DPPTRF( UPLO, N, BP, INFO ) 00142 IF( INFO.NE.0 ) THEN 00143 INFO = N + INFO 00144 RETURN 00145 END IF 00146 * 00147 * Transform problem to standard eigenvalue problem and solve. 00148 * 00149 CALL DSPGST( ITYPE, UPLO, N, AP, BP, INFO ) 00150 CALL DSPEV( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, INFO ) 00151 * 00152 IF( WANTZ ) THEN 00153 * 00154 * Backtransform eigenvectors to the original problem. 00155 * 00156 NEIG = N 00157 IF( INFO.GT.0 ) 00158 $ NEIG = INFO - 1 00159 IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN 00160 * 00161 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x; 00162 * backtransform eigenvectors: x = inv(L)'*y or inv(U)*y 00163 * 00164 IF( UPPER ) THEN 00165 TRANS = 'N' 00166 ELSE 00167 TRANS = 'T' 00168 END IF 00169 * 00170 DO 10 J = 1, NEIG 00171 CALL DTPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ), 00172 $ 1 ) 00173 10 CONTINUE 00174 * 00175 ELSE IF( ITYPE.EQ.3 ) THEN 00176 * 00177 * For B*A*x=(lambda)*x; 00178 * backtransform eigenvectors: x = L*y or U'*y 00179 * 00180 IF( UPPER ) THEN 00181 TRANS = 'T' 00182 ELSE 00183 TRANS = 'N' 00184 END IF 00185 * 00186 DO 20 J = 1, NEIG 00187 CALL DTPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ), 00188 $ 1 ) 00189 20 CONTINUE 00190 END IF 00191 END IF 00192 RETURN 00193 * 00194 * End of DSPGV 00195 * 00196 END