00001 /* dspgv.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Table of constant values */ 00017 00018 static integer c__1 = 1; 00019 00020 /* Subroutine */ int dspgv_(integer *itype, char *jobz, char *uplo, integer * 00021 n, doublereal *ap, doublereal *bp, doublereal *w, doublereal *z__, 00022 integer *ldz, doublereal *work, integer *info) 00023 { 00024 /* System generated locals */ 00025 integer z_dim1, z_offset, i__1; 00026 00027 /* Local variables */ 00028 integer j, neig; 00029 extern logical lsame_(char *, char *); 00030 extern /* Subroutine */ int dspev_(char *, char *, integer *, doublereal * 00031 , doublereal *, doublereal *, integer *, doublereal *, integer *); 00032 char trans[1]; 00033 logical upper; 00034 extern /* Subroutine */ int dtpmv_(char *, char *, char *, integer *, 00035 doublereal *, doublereal *, integer *), 00036 dtpsv_(char *, char *, char *, integer *, doublereal *, 00037 doublereal *, integer *); 00038 logical wantz; 00039 extern /* Subroutine */ int xerbla_(char *, integer *), dpptrf_( 00040 char *, integer *, doublereal *, integer *), dspgst_( 00041 integer *, char *, integer *, doublereal *, doublereal *, integer 00042 *); 00043 00044 00045 /* -- LAPACK driver routine (version 3.2) -- */ 00046 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00047 /* November 2006 */ 00048 00049 /* .. Scalar Arguments .. */ 00050 /* .. */ 00051 /* .. Array Arguments .. */ 00052 /* .. */ 00053 00054 /* Purpose */ 00055 /* ======= */ 00056 00057 /* DSPGV computes all the eigenvalues and, optionally, the eigenvectors */ 00058 /* of a real generalized symmetric-definite eigenproblem, of the form */ 00059 /* A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. */ 00060 /* Here A and B are assumed to be symmetric, stored in packed format, */ 00061 /* and B is also positive definite. */ 00062 00063 /* Arguments */ 00064 /* ========= */ 00065 00066 /* ITYPE (input) INTEGER */ 00067 /* Specifies the problem type to be solved: */ 00068 /* = 1: A*x = (lambda)*B*x */ 00069 /* = 2: A*B*x = (lambda)*x */ 00070 /* = 3: B*A*x = (lambda)*x */ 00071 00072 /* JOBZ (input) CHARACTER*1 */ 00073 /* = 'N': Compute eigenvalues only; */ 00074 /* = 'V': Compute eigenvalues and eigenvectors. */ 00075 00076 /* UPLO (input) CHARACTER*1 */ 00077 /* = 'U': Upper triangles of A and B are stored; */ 00078 /* = 'L': Lower triangles of A and B are stored. */ 00079 00080 /* N (input) INTEGER */ 00081 /* The order of the matrices A and B. N >= 0. */ 00082 00083 /* AP (input/output) DOUBLE PRECISION array, dimension */ 00084 /* (N*(N+1)/2) */ 00085 /* On entry, the upper or lower triangle of the symmetric matrix */ 00086 /* A, packed columnwise in a linear array. The j-th column of A */ 00087 /* is stored in the array AP as follows: */ 00088 /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ 00089 /* if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. */ 00090 00091 /* On exit, the contents of AP are destroyed. */ 00092 00093 /* BP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */ 00094 /* On entry, the upper or lower triangle of the symmetric matrix */ 00095 /* B, packed columnwise in a linear array. The j-th column of B */ 00096 /* is stored in the array BP as follows: */ 00097 /* if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j; */ 00098 /* if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n. */ 00099 00100 /* On exit, the triangular factor U or L from the Cholesky */ 00101 /* factorization B = U**T*U or B = L*L**T, in the same storage */ 00102 /* format as B. */ 00103 00104 /* W (output) DOUBLE PRECISION array, dimension (N) */ 00105 /* If INFO = 0, the eigenvalues in ascending order. */ 00106 00107 /* Z (output) DOUBLE PRECISION array, dimension (LDZ, N) */ 00108 /* If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of */ 00109 /* eigenvectors. The eigenvectors are normalized as follows: */ 00110 /* if ITYPE = 1 or 2, Z**T*B*Z = I; */ 00111 /* if ITYPE = 3, Z**T*inv(B)*Z = I. */ 00112 /* If JOBZ = 'N', then Z is not referenced. */ 00113 00114 /* LDZ (input) INTEGER */ 00115 /* The leading dimension of the array Z. LDZ >= 1, and if */ 00116 /* JOBZ = 'V', LDZ >= max(1,N). */ 00117 00118 /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N) */ 00119 00120 /* INFO (output) INTEGER */ 00121 /* = 0: successful exit */ 00122 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00123 /* > 0: DPPTRF or DSPEV returned an error code: */ 00124 /* <= N: if INFO = i, DSPEV failed to converge; */ 00125 /* i off-diagonal elements of an intermediate */ 00126 /* tridiagonal form did not converge to zero. */ 00127 /* > N: if INFO = n + i, for 1 <= i <= n, then the leading */ 00128 /* minor of order i of B is not positive definite. */ 00129 /* The factorization of B could not be completed and */ 00130 /* no eigenvalues or eigenvectors were computed. */ 00131 00132 /* ===================================================================== */ 00133 00134 /* .. Local Scalars .. */ 00135 /* .. */ 00136 /* .. External Functions .. */ 00137 /* .. */ 00138 /* .. External Subroutines .. */ 00139 /* .. */ 00140 /* .. Executable Statements .. */ 00141 00142 /* Test the input parameters. */ 00143 00144 /* Parameter adjustments */ 00145 --ap; 00146 --bp; 00147 --w; 00148 z_dim1 = *ldz; 00149 z_offset = 1 + z_dim1; 00150 z__ -= z_offset; 00151 --work; 00152 00153 /* Function Body */ 00154 wantz = lsame_(jobz, "V"); 00155 upper = lsame_(uplo, "U"); 00156 00157 *info = 0; 00158 if (*itype < 1 || *itype > 3) { 00159 *info = -1; 00160 } else if (! (wantz || lsame_(jobz, "N"))) { 00161 *info = -2; 00162 } else if (! (upper || lsame_(uplo, "L"))) { 00163 *info = -3; 00164 } else if (*n < 0) { 00165 *info = -4; 00166 } else if (*ldz < 1 || wantz && *ldz < *n) { 00167 *info = -9; 00168 } 00169 if (*info != 0) { 00170 i__1 = -(*info); 00171 xerbla_("DSPGV ", &i__1); 00172 return 0; 00173 } 00174 00175 /* Quick return if possible */ 00176 00177 if (*n == 0) { 00178 return 0; 00179 } 00180 00181 /* Form a Cholesky factorization of B. */ 00182 00183 dpptrf_(uplo, n, &bp[1], info); 00184 if (*info != 0) { 00185 *info = *n + *info; 00186 return 0; 00187 } 00188 00189 /* Transform problem to standard eigenvalue problem and solve. */ 00190 00191 dspgst_(itype, uplo, n, &ap[1], &bp[1], info); 00192 dspev_(jobz, uplo, n, &ap[1], &w[1], &z__[z_offset], ldz, &work[1], info); 00193 00194 if (wantz) { 00195 00196 /* Backtransform eigenvectors to the original problem. */ 00197 00198 neig = *n; 00199 if (*info > 0) { 00200 neig = *info - 1; 00201 } 00202 if (*itype == 1 || *itype == 2) { 00203 00204 /* For A*x=(lambda)*B*x and A*B*x=(lambda)*x; */ 00205 /* backtransform eigenvectors: x = inv(L)'*y or inv(U)*y */ 00206 00207 if (upper) { 00208 *(unsigned char *)trans = 'N'; 00209 } else { 00210 *(unsigned char *)trans = 'T'; 00211 } 00212 00213 i__1 = neig; 00214 for (j = 1; j <= i__1; ++j) { 00215 dtpsv_(uplo, trans, "Non-unit", n, &bp[1], &z__[j * z_dim1 + 00216 1], &c__1); 00217 /* L10: */ 00218 } 00219 00220 } else if (*itype == 3) { 00221 00222 /* For B*A*x=(lambda)*x; */ 00223 /* backtransform eigenvectors: x = L*y or U'*y */ 00224 00225 if (upper) { 00226 *(unsigned char *)trans = 'T'; 00227 } else { 00228 *(unsigned char *)trans = 'N'; 00229 } 00230 00231 i__1 = neig; 00232 for (j = 1; j <= i__1; ++j) { 00233 dtpmv_(uplo, trans, "Non-unit", n, &bp[1], &z__[j * z_dim1 + 00234 1], &c__1); 00235 /* L20: */ 00236 } 00237 } 00238 } 00239 return 0; 00240 00241 /* End of DSPGV */ 00242 00243 } /* dspgv_ */