zhpgv.c
Go to the documentation of this file.
00001 /* zhpgv.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 zhpgv_(integer *itype, char *jobz, char *uplo, integer *
00021         n, doublecomplex *ap, doublecomplex *bp, doublereal *w, doublecomplex 
00022         *z__, integer *ldz, doublecomplex *work, doublereal *rwork, integer *
00023         info)
00024 {
00025     /* System generated locals */
00026     integer z_dim1, z_offset, i__1;
00027 
00028     /* Local variables */
00029     integer j, neig;
00030     extern logical lsame_(char *, char *);
00031     char trans[1];
00032     logical upper;
00033     extern /* Subroutine */ int zhpev_(char *, char *, integer *, 
00034             doublecomplex *, doublereal *, doublecomplex *, integer *, 
00035             doublecomplex *, doublereal *, integer *);
00036     logical wantz;
00037     extern /* Subroutine */ int ztpmv_(char *, char *, char *, integer *, 
00038             doublecomplex *, doublecomplex *, integer *), ztpsv_(char *, char *, char *, integer *, doublecomplex *
00039 , doublecomplex *, integer *), xerbla_(
00040             char *, integer *), zhpgst_(integer *, char *, integer *, 
00041             doublecomplex *, doublecomplex *, integer *), zpptrf_(
00042             char *, integer *, doublecomplex *, integer *);
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 /*  ZHPGV computes all the eigenvalues and, optionally, the eigenvectors */
00058 /*  of a complex generalized Hermitian-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 Hermitian, 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) COMPLEX*16 array, dimension (N*(N+1)/2) */
00084 /*          On entry, the upper or lower triangle of the Hermitian matrix */
00085 /*          A, packed columnwise in a linear array.  The j-th column of A */
00086 /*          is stored in the array AP as follows: */
00087 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00088 /*          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. */
00089 
00090 /*          On exit, the contents of AP are destroyed. */
00091 
00092 /*  BP      (input/output) COMPLEX*16 array, dimension (N*(N+1)/2) */
00093 /*          On entry, the upper or lower triangle of the Hermitian matrix */
00094 /*          B, packed columnwise in a linear array.  The j-th column of B */
00095 /*          is stored in the array BP as follows: */
00096 /*          if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j; */
00097 /*          if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n. */
00098 
00099 /*          On exit, the triangular factor U or L from the Cholesky */
00100 /*          factorization B = U**H*U or B = L*L**H, in the same storage */
00101 /*          format as B. */
00102 
00103 /*  W       (output) DOUBLE PRECISION array, dimension (N) */
00104 /*          If INFO = 0, the eigenvalues in ascending order. */
00105 
00106 /*  Z       (output) COMPLEX*16 array, dimension (LDZ, N) */
00107 /*          If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of */
00108 /*          eigenvectors.  The eigenvectors are normalized as follows: */
00109 /*          if ITYPE = 1 or 2, Z**H*B*Z = I; */
00110 /*          if ITYPE = 3, Z**H*inv(B)*Z = I. */
00111 /*          If JOBZ = 'N', then Z is not referenced. */
00112 
00113 /*  LDZ     (input) INTEGER */
00114 /*          The leading dimension of the array Z.  LDZ >= 1, and if */
00115 /*          JOBZ = 'V', LDZ >= max(1,N). */
00116 
00117 /*  WORK    (workspace) COMPLEX*16 array, dimension (max(1, 2*N-1)) */
00118 
00119 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (max(1, 3*N-2)) */
00120 
00121 /*  INFO    (output) INTEGER */
00122 /*          = 0:  successful exit */
00123 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00124 /*          > 0:  ZPPTRF or ZHPEV returned an error code: */
00125 /*             <= N:  if INFO = i, ZHPEV failed to converge; */
00126 /*                    i off-diagonal elements of an intermediate */
00127 /*                    tridiagonal form did not convergeto zero; */
00128 /*             > N:   if INFO = N + i, for 1 <= i <= n, then the leading */
00129 /*                    minor of order i of B is not positive definite. */
00130 /*                    The factorization of B could not be completed and */
00131 /*                    no eigenvalues or eigenvectors were computed. */
00132 
00133 /*  ===================================================================== */
00134 
00135 /*     .. Local Scalars .. */
00136 /*     .. */
00137 /*     .. External Functions .. */
00138 /*     .. */
00139 /*     .. External Subroutines .. */
00140 /*     .. */
00141 /*     .. Executable Statements .. */
00142 
00143 /*     Test the input parameters. */
00144 
00145     /* Parameter adjustments */
00146     --ap;
00147     --bp;
00148     --w;
00149     z_dim1 = *ldz;
00150     z_offset = 1 + z_dim1;
00151     z__ -= z_offset;
00152     --work;
00153     --rwork;
00154 
00155     /* Function Body */
00156     wantz = lsame_(jobz, "V");
00157     upper = lsame_(uplo, "U");
00158 
00159     *info = 0;
00160     if (*itype < 1 || *itype > 3) {
00161         *info = -1;
00162     } else if (! (wantz || lsame_(jobz, "N"))) {
00163         *info = -2;
00164     } else if (! (upper || lsame_(uplo, "L"))) {
00165         *info = -3;
00166     } else if (*n < 0) {
00167         *info = -4;
00168     } else if (*ldz < 1 || wantz && *ldz < *n) {
00169         *info = -9;
00170     }
00171     if (*info != 0) {
00172         i__1 = -(*info);
00173         xerbla_("ZHPGV ", &i__1);
00174         return 0;
00175     }
00176 
00177 /*     Quick return if possible */
00178 
00179     if (*n == 0) {
00180         return 0;
00181     }
00182 
00183 /*     Form a Cholesky factorization of B. */
00184 
00185     zpptrf_(uplo, n, &bp[1], info);
00186     if (*info != 0) {
00187         *info = *n + *info;
00188         return 0;
00189     }
00190 
00191 /*     Transform problem to standard eigenvalue problem and solve. */
00192 
00193     zhpgst_(itype, uplo, n, &ap[1], &bp[1], info);
00194     zhpev_(jobz, uplo, n, &ap[1], &w[1], &z__[z_offset], ldz, &work[1], &
00195             rwork[1], info);
00196 
00197     if (wantz) {
00198 
00199 /*        Backtransform eigenvectors to the original problem. */
00200 
00201         neig = *n;
00202         if (*info > 0) {
00203             neig = *info - 1;
00204         }
00205         if (*itype == 1 || *itype == 2) {
00206 
00207 /*           For A*x=(lambda)*B*x and A*B*x=(lambda)*x; */
00208 /*           backtransform eigenvectors: x = inv(L)'*y or inv(U)*y */
00209 
00210             if (upper) {
00211                 *(unsigned char *)trans = 'N';
00212             } else {
00213                 *(unsigned char *)trans = 'C';
00214             }
00215 
00216             i__1 = neig;
00217             for (j = 1; j <= i__1; ++j) {
00218                 ztpsv_(uplo, trans, "Non-unit", n, &bp[1], &z__[j * z_dim1 + 
00219                         1], &c__1);
00220 /* L10: */
00221             }
00222 
00223         } else if (*itype == 3) {
00224 
00225 /*           For B*A*x=(lambda)*x; */
00226 /*           backtransform eigenvectors: x = L*y or U'*y */
00227 
00228             if (upper) {
00229                 *(unsigned char *)trans = 'C';
00230             } else {
00231                 *(unsigned char *)trans = 'N';
00232             }
00233 
00234             i__1 = neig;
00235             for (j = 1; j <= i__1; ++j) {
00236                 ztpmv_(uplo, trans, "Non-unit", n, &bp[1], &z__[j * z_dim1 + 
00237                         1], &c__1);
00238 /* L20: */
00239             }
00240         }
00241     }
00242     return 0;
00243 
00244 /*     End of ZHPGV */
00245 
00246 } /* zhpgv_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:39