chpgv.c
Go to the documentation of this file.
00001 /* chpgv.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 chpgv_(integer *itype, char *jobz, char *uplo, integer *
00021         n, complex *ap, complex *bp, real *w, complex *z__, integer *ldz, 
00022         complex *work, real *rwork, 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 chpev_(char *, char *, integer *, complex *, 
00031             real *, complex *, integer *, complex *, real *, integer *);
00032     char trans[1];
00033     extern /* Subroutine */ int ctpmv_(char *, char *, char *, integer *, 
00034             complex *, complex *, integer *);
00035     logical upper;
00036     extern /* Subroutine */ int ctpsv_(char *, char *, char *, integer *, 
00037             complex *, complex *, integer *);
00038     logical wantz;
00039     extern /* Subroutine */ int xerbla_(char *, integer *), chpgst_(
00040             integer *, char *, integer *, complex *, complex *, integer *), cpptrf_(char *, integer *, complex *, integer *);
00041 
00042 
00043 /*  -- LAPACK driver routine (version 3.2) -- */
00044 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00045 /*     November 2006 */
00046 
00047 /*     .. Scalar Arguments .. */
00048 /*     .. */
00049 /*     .. Array Arguments .. */
00050 /*     .. */
00051 
00052 /*  Purpose */
00053 /*  ======= */
00054 
00055 /*  CHPGV computes all the eigenvalues and, optionally, the eigenvectors */
00056 /*  of a complex generalized Hermitian-definite eigenproblem, of the form */
00057 /*  A*x=(lambda)*B*x,  A*Bx=(lambda)*x,  or B*A*x=(lambda)*x. */
00058 /*  Here A and B are assumed to be Hermitian, stored in packed format, */
00059 /*  and B is also positive definite. */
00060 
00061 /*  Arguments */
00062 /*  ========= */
00063 
00064 /*  ITYPE   (input) INTEGER */
00065 /*          Specifies the problem type to be solved: */
00066 /*          = 1:  A*x = (lambda)*B*x */
00067 /*          = 2:  A*B*x = (lambda)*x */
00068 /*          = 3:  B*A*x = (lambda)*x */
00069 
00070 /*  JOBZ    (input) CHARACTER*1 */
00071 /*          = 'N':  Compute eigenvalues only; */
00072 /*          = 'V':  Compute eigenvalues and eigenvectors. */
00073 
00074 /*  UPLO    (input) CHARACTER*1 */
00075 /*          = 'U':  Upper triangles of A and B are stored; */
00076 /*          = 'L':  Lower triangles of A and B are stored. */
00077 
00078 /*  N       (input) INTEGER */
00079 /*          The order of the matrices A and B.  N >= 0. */
00080 
00081 /*  AP      (input/output) COMPLEX array, dimension (N*(N+1)/2) */
00082 /*          On entry, the upper or lower triangle of the Hermitian matrix */
00083 /*          A, packed columnwise in a linear array.  The j-th column of A */
00084 /*          is stored in the array AP as follows: */
00085 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00086 /*          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. */
00087 
00088 /*          On exit, the contents of AP are destroyed. */
00089 
00090 /*  BP      (input/output) COMPLEX array, dimension (N*(N+1)/2) */
00091 /*          On entry, the upper or lower triangle of the Hermitian matrix */
00092 /*          B, packed columnwise in a linear array.  The j-th column of B */
00093 /*          is stored in the array BP as follows: */
00094 /*          if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j; */
00095 /*          if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n. */
00096 
00097 /*          On exit, the triangular factor U or L from the Cholesky */
00098 /*          factorization B = U**H*U or B = L*L**H, in the same storage */
00099 /*          format as B. */
00100 
00101 /*  W       (output) REAL array, dimension (N) */
00102 /*          If INFO = 0, the eigenvalues in ascending order. */
00103 
00104 /*  Z       (output) COMPLEX array, dimension (LDZ, N) */
00105 /*          If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of */
00106 /*          eigenvectors.  The eigenvectors are normalized as follows: */
00107 /*          if ITYPE = 1 or 2, Z**H*B*Z = I; */
00108 /*          if ITYPE = 3, Z**H*inv(B)*Z = I. */
00109 /*          If JOBZ = 'N', then Z is not referenced. */
00110 
00111 /*  LDZ     (input) INTEGER */
00112 /*          The leading dimension of the array Z.  LDZ >= 1, and if */
00113 /*          JOBZ = 'V', LDZ >= max(1,N). */
00114 
00115 /*  WORK    (workspace) COMPLEX array, dimension (max(1, 2*N-1)) */
00116 
00117 /*  RWORK   (workspace) REAL array, dimension (max(1, 3*N-2)) */
00118 
00119 /*  INFO    (output) INTEGER */
00120 /*          = 0:  successful exit */
00121 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00122 /*          > 0:  CPPTRF or CHPEV returned an error code: */
00123 /*             <= N:  if INFO = i, CHPEV failed to converge; */
00124 /*                    i off-diagonal elements of an intermediate */
00125 /*                    tridiagonal form did not convergeto 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 /*  ===================================================================== */
00132 
00133 /*     .. Local Scalars .. */
00134 /*     .. */
00135 /*     .. External Functions .. */
00136 /*     .. */
00137 /*     .. External Subroutines .. */
00138 /*     .. */
00139 /*     .. Executable Statements .. */
00140 
00141 /*     Test the input parameters. */
00142 
00143     /* Parameter adjustments */
00144     --ap;
00145     --bp;
00146     --w;
00147     z_dim1 = *ldz;
00148     z_offset = 1 + z_dim1;
00149     z__ -= z_offset;
00150     --work;
00151     --rwork;
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_("CHPGV ", &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     cpptrf_(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     chpgst_(itype, uplo, n, &ap[1], &bp[1], info);
00192     chpev_(jobz, uplo, n, &ap[1], &w[1], &z__[z_offset], ldz, &work[1], &
00193             rwork[1], info);
00194 
00195     if (wantz) {
00196 
00197 /*        Backtransform eigenvectors to the original problem. */
00198 
00199         neig = *n;
00200         if (*info > 0) {
00201             neig = *info - 1;
00202         }
00203         if (*itype == 1 || *itype == 2) {
00204 
00205 /*           For A*x=(lambda)*B*x and A*B*x=(lambda)*x; */
00206 /*           backtransform eigenvectors: x = inv(L)'*y or inv(U)*y */
00207 
00208             if (upper) {
00209                 *(unsigned char *)trans = 'N';
00210             } else {
00211                 *(unsigned char *)trans = 'C';
00212             }
00213 
00214             i__1 = neig;
00215             for (j = 1; j <= i__1; ++j) {
00216                 ctpsv_(uplo, trans, "Non-unit", n, &bp[1], &z__[j * z_dim1 + 
00217                         1], &c__1);
00218 /* L10: */
00219             }
00220 
00221         } else if (*itype == 3) {
00222 
00223 /*           For B*A*x=(lambda)*x; */
00224 /*           backtransform eigenvectors: x = L*y or U'*y */
00225 
00226             if (upper) {
00227                 *(unsigned char *)trans = 'C';
00228             } else {
00229                 *(unsigned char *)trans = 'N';
00230             }
00231 
00232             i__1 = neig;
00233             for (j = 1; j <= i__1; ++j) {
00234                 ctpmv_(uplo, trans, "Non-unit", n, &bp[1], &z__[j * z_dim1 + 
00235                         1], &c__1);
00236 /* L20: */
00237             }
00238         }
00239     }
00240     return 0;
00241 
00242 /*     End of CHPGV */
00243 
00244 } /* chpgv_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:29