chbgv.c
Go to the documentation of this file.
00001 /* chbgv.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 /* Subroutine */ int chbgv_(char *jobz, char *uplo, integer *n, integer *ka, 
00017         integer *kb, complex *ab, integer *ldab, complex *bb, integer *ldbb, 
00018         real *w, complex *z__, integer *ldz, complex *work, real *rwork, 
00019         integer *info)
00020 {
00021     /* System generated locals */
00022     integer ab_dim1, ab_offset, bb_dim1, bb_offset, z_dim1, z_offset, i__1;
00023 
00024     /* Local variables */
00025     integer inde;
00026     char vect[1];
00027     extern logical lsame_(char *, char *);
00028     integer iinfo;
00029     logical upper, wantz;
00030     extern /* Subroutine */ int chbtrd_(char *, char *, integer *, integer *, 
00031             complex *, integer *, real *, real *, complex *, integer *, 
00032             complex *, integer *), chbgst_(char *, char *, 
00033             integer *, integer *, integer *, complex *, integer *, complex *, 
00034             integer *, complex *, integer *, complex *, real *, integer *), xerbla_(char *, integer *), cpbstf_(char 
00035             *, integer *, integer *, complex *, integer *, integer *);
00036     integer indwrk;
00037     extern /* Subroutine */ int csteqr_(char *, integer *, real *, real *, 
00038             complex *, integer *, real *, integer *), ssterf_(integer 
00039             *, real *, real *, integer *);
00040 
00041 
00042 /*  -- LAPACK driver routine (version 3.2) -- */
00043 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00044 /*     November 2006 */
00045 
00046 /*     .. Scalar Arguments .. */
00047 /*     .. */
00048 /*     .. Array Arguments .. */
00049 /*     .. */
00050 
00051 /*  Purpose */
00052 /*  ======= */
00053 
00054 /*  CHBGV computes all the eigenvalues, and optionally, the eigenvectors */
00055 /*  of a complex generalized Hermitian-definite banded eigenproblem, of */
00056 /*  the form A*x=(lambda)*B*x. Here A and B are assumed to be Hermitian */
00057 /*  and banded, and B is also positive definite. */
00058 
00059 /*  Arguments */
00060 /*  ========= */
00061 
00062 /*  JOBZ    (input) CHARACTER*1 */
00063 /*          = 'N':  Compute eigenvalues only; */
00064 /*          = 'V':  Compute eigenvalues and eigenvectors. */
00065 
00066 /*  UPLO    (input) CHARACTER*1 */
00067 /*          = 'U':  Upper triangles of A and B are stored; */
00068 /*          = 'L':  Lower triangles of A and B are stored. */
00069 
00070 /*  N       (input) INTEGER */
00071 /*          The order of the matrices A and B.  N >= 0. */
00072 
00073 /*  KA      (input) INTEGER */
00074 /*          The number of superdiagonals of the matrix A if UPLO = 'U', */
00075 /*          or the number of subdiagonals if UPLO = 'L'. KA >= 0. */
00076 
00077 /*  KB      (input) INTEGER */
00078 /*          The number of superdiagonals of the matrix B if UPLO = 'U', */
00079 /*          or the number of subdiagonals if UPLO = 'L'. KB >= 0. */
00080 
00081 /*  AB      (input/output) COMPLEX array, dimension (LDAB, N) */
00082 /*          On entry, the upper or lower triangle of the Hermitian band */
00083 /*          matrix A, stored in the first ka+1 rows of the array.  The */
00084 /*          j-th column of A is stored in the j-th column of the array AB */
00085 /*          as follows: */
00086 /*          if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j; */
00087 /*          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+ka). */
00088 
00089 /*          On exit, the contents of AB are destroyed. */
00090 
00091 /*  LDAB    (input) INTEGER */
00092 /*          The leading dimension of the array AB.  LDAB >= KA+1. */
00093 
00094 /*  BB      (input/output) COMPLEX array, dimension (LDBB, N) */
00095 /*          On entry, the upper or lower triangle of the Hermitian band */
00096 /*          matrix B, stored in the first kb+1 rows of the array.  The */
00097 /*          j-th column of B is stored in the j-th column of the array BB */
00098 /*          as follows: */
00099 /*          if UPLO = 'U', BB(kb+1+i-j,j) = B(i,j) for max(1,j-kb)<=i<=j; */
00100 /*          if UPLO = 'L', BB(1+i-j,j)    = B(i,j) for j<=i<=min(n,j+kb). */
00101 
00102 /*          On exit, the factor S from the split Cholesky factorization */
00103 /*          B = S**H*S, as returned by CPBSTF. */
00104 
00105 /*  LDBB    (input) INTEGER */
00106 /*          The leading dimension of the array BB.  LDBB >= KB+1. */
00107 
00108 /*  W       (output) REAL array, dimension (N) */
00109 /*          If INFO = 0, the eigenvalues in ascending order. */
00110 
00111 /*  Z       (output) COMPLEX array, dimension (LDZ, N) */
00112 /*          If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of */
00113 /*          eigenvectors, with the i-th column of Z holding the */
00114 /*          eigenvector associated with W(i). The eigenvectors are */
00115 /*          normalized so that Z**H*B*Z = I. */
00116 /*          If JOBZ = 'N', then Z is not referenced. */
00117 
00118 /*  LDZ     (input) INTEGER */
00119 /*          The leading dimension of the array Z.  LDZ >= 1, and if */
00120 /*          JOBZ = 'V', LDZ >= N. */
00121 
00122 /*  WORK    (workspace) COMPLEX array, dimension (N) */
00123 
00124 /*  RWORK   (workspace) REAL array, dimension (3*N) */
00125 
00126 /*  INFO    (output) INTEGER */
00127 /*          = 0:  successful exit */
00128 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00129 /*          > 0:  if INFO = i, and i is: */
00130 /*             <= N:  the algorithm failed to converge: */
00131 /*                    i off-diagonal elements of an intermediate */
00132 /*                    tridiagonal form did not converge to zero; */
00133 /*             > N:   if INFO = N + i, for 1 <= i <= N, then CPBSTF */
00134 /*                    returned INFO = i: B is not positive definite. */
00135 /*                    The factorization of B could not be completed and */
00136 /*                    no eigenvalues or eigenvectors were computed. */
00137 
00138 /*  ===================================================================== */
00139 
00140 /*     .. Local Scalars .. */
00141 /*     .. */
00142 /*     .. External Functions .. */
00143 /*     .. */
00144 /*     .. External Subroutines .. */
00145 /*     .. */
00146 /*     .. Executable Statements .. */
00147 
00148 /*     Test the input parameters. */
00149 
00150     /* Parameter adjustments */
00151     ab_dim1 = *ldab;
00152     ab_offset = 1 + ab_dim1;
00153     ab -= ab_offset;
00154     bb_dim1 = *ldbb;
00155     bb_offset = 1 + bb_dim1;
00156     bb -= bb_offset;
00157     --w;
00158     z_dim1 = *ldz;
00159     z_offset = 1 + z_dim1;
00160     z__ -= z_offset;
00161     --work;
00162     --rwork;
00163 
00164     /* Function Body */
00165     wantz = lsame_(jobz, "V");
00166     upper = lsame_(uplo, "U");
00167 
00168     *info = 0;
00169     if (! (wantz || lsame_(jobz, "N"))) {
00170         *info = -1;
00171     } else if (! (upper || lsame_(uplo, "L"))) {
00172         *info = -2;
00173     } else if (*n < 0) {
00174         *info = -3;
00175     } else if (*ka < 0) {
00176         *info = -4;
00177     } else if (*kb < 0 || *kb > *ka) {
00178         *info = -5;
00179     } else if (*ldab < *ka + 1) {
00180         *info = -7;
00181     } else if (*ldbb < *kb + 1) {
00182         *info = -9;
00183     } else if (*ldz < 1 || wantz && *ldz < *n) {
00184         *info = -12;
00185     }
00186     if (*info != 0) {
00187         i__1 = -(*info);
00188         xerbla_("CHBGV ", &i__1);
00189         return 0;
00190     }
00191 
00192 /*     Quick return if possible */
00193 
00194     if (*n == 0) {
00195         return 0;
00196     }
00197 
00198 /*     Form a split Cholesky factorization of B. */
00199 
00200     cpbstf_(uplo, n, kb, &bb[bb_offset], ldbb, info);
00201     if (*info != 0) {
00202         *info = *n + *info;
00203         return 0;
00204     }
00205 
00206 /*     Transform problem to standard eigenvalue problem. */
00207 
00208     inde = 1;
00209     indwrk = inde + *n;
00210     chbgst_(jobz, uplo, n, ka, kb, &ab[ab_offset], ldab, &bb[bb_offset], ldbb, 
00211              &z__[z_offset], ldz, &work[1], &rwork[indwrk], &iinfo);
00212 
00213 /*     Reduce to tridiagonal form. */
00214 
00215     if (wantz) {
00216         *(unsigned char *)vect = 'U';
00217     } else {
00218         *(unsigned char *)vect = 'N';
00219     }
00220     chbtrd_(vect, uplo, n, ka, &ab[ab_offset], ldab, &w[1], &rwork[inde], &
00221             z__[z_offset], ldz, &work[1], &iinfo);
00222 
00223 /*     For eigenvalues only, call SSTERF.  For eigenvectors, call CSTEQR. */
00224 
00225     if (! wantz) {
00226         ssterf_(n, &w[1], &rwork[inde], info);
00227     } else {
00228         csteqr_(jobz, n, &w[1], &rwork[inde], &z__[z_offset], ldz, &rwork[
00229                 indwrk], info);
00230     }
00231     return 0;
00232 
00233 /*     End of CHBGV */
00234 
00235 } /* chbgv_ */


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