zhpgst.c
Go to the documentation of this file.
00001 /* zhpgst.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 doublecomplex c_b1 = {1.,0.};
00019 static integer c__1 = 1;
00020 
00021 /* Subroutine */ int zhpgst_(integer *itype, char *uplo, integer *n, 
00022         doublecomplex *ap, doublecomplex *bp, integer *info)
00023 {
00024     /* System generated locals */
00025     integer i__1, i__2, i__3, i__4;
00026     doublereal d__1, d__2;
00027     doublecomplex z__1, z__2, z__3;
00028 
00029     /* Local variables */
00030     integer j, k, j1, k1, jj, kk;
00031     doublecomplex ct;
00032     doublereal ajj;
00033     integer j1j1;
00034     doublereal akk;
00035     integer k1k1;
00036     doublereal bjj, bkk;
00037     extern /* Subroutine */ int zhpr2_(char *, integer *, doublecomplex *, 
00038             doublecomplex *, integer *, doublecomplex *, integer *, 
00039             doublecomplex *);
00040     extern logical lsame_(char *, char *);
00041     extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, 
00042             doublecomplex *, integer *, doublecomplex *, integer *);
00043     logical upper;
00044     extern /* Subroutine */ int zhpmv_(char *, integer *, doublecomplex *, 
00045             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00046             doublecomplex *, integer *), zaxpy_(integer *, 
00047             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00048             integer *), ztpmv_(char *, char *, char *, integer *, 
00049             doublecomplex *, doublecomplex *, integer *), ztpsv_(char *, char *, char *, integer *, doublecomplex *
00050 , doublecomplex *, integer *), xerbla_(
00051             char *, integer *), zdscal_(integer *, doublereal *, 
00052             doublecomplex *, integer *);
00053 
00054 
00055 /*  -- LAPACK routine (version 3.2) -- */
00056 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00057 /*     November 2006 */
00058 
00059 /*     .. Scalar Arguments .. */
00060 /*     .. */
00061 /*     .. Array Arguments .. */
00062 /*     .. */
00063 
00064 /*  Purpose */
00065 /*  ======= */
00066 
00067 /*  ZHPGST reduces a complex Hermitian-definite generalized */
00068 /*  eigenproblem to standard form, using packed storage. */
00069 
00070 /*  If ITYPE = 1, the problem is A*x = lambda*B*x, */
00071 /*  and A is overwritten by inv(U**H)*A*inv(U) or inv(L)*A*inv(L**H) */
00072 
00073 /*  If ITYPE = 2 or 3, the problem is A*B*x = lambda*x or */
00074 /*  B*A*x = lambda*x, and A is overwritten by U*A*U**H or L**H*A*L. */
00075 
00076 /*  B must have been previously factorized as U**H*U or L*L**H by ZPPTRF. */
00077 
00078 /*  Arguments */
00079 /*  ========= */
00080 
00081 /*  ITYPE   (input) INTEGER */
00082 /*          = 1: compute inv(U**H)*A*inv(U) or inv(L)*A*inv(L**H); */
00083 /*          = 2 or 3: compute U*A*U**H or L**H*A*L. */
00084 
00085 /*  UPLO    (input) CHARACTER*1 */
00086 /*          = 'U':  Upper triangle of A is stored and B is factored as */
00087 /*                  U**H*U; */
00088 /*          = 'L':  Lower triangle of A is stored and B is factored as */
00089 /*                  L*L**H. */
00090 
00091 /*  N       (input) INTEGER */
00092 /*          The order of the matrices A and B.  N >= 0. */
00093 
00094 /*  AP      (input/output) COMPLEX*16 array, dimension (N*(N+1)/2) */
00095 /*          On entry, the upper or lower triangle of the Hermitian matrix */
00096 /*          A, packed columnwise in a linear array.  The j-th column of A */
00097 /*          is stored in the array AP as follows: */
00098 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00099 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
00100 
00101 /*          On exit, if INFO = 0, the transformed matrix, stored in the */
00102 /*          same format as A. */
00103 
00104 /*  BP      (input) COMPLEX*16 array, dimension (N*(N+1)/2) */
00105 /*          The triangular factor from the Cholesky factorization of B, */
00106 /*          stored in the same format as A, as returned by ZPPTRF. */
00107 
00108 /*  INFO    (output) INTEGER */
00109 /*          = 0:  successful exit */
00110 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00111 
00112 /*  ===================================================================== */
00113 
00114 /*     .. Parameters .. */
00115 /*     .. */
00116 /*     .. Local Scalars .. */
00117 /*     .. */
00118 /*     .. External Subroutines .. */
00119 /*     .. */
00120 /*     .. Intrinsic Functions .. */
00121 /*     .. */
00122 /*     .. External Functions .. */
00123 /*     .. */
00124 /*     .. Executable Statements .. */
00125 
00126 /*     Test the input parameters. */
00127 
00128     /* Parameter adjustments */
00129     --bp;
00130     --ap;
00131 
00132     /* Function Body */
00133     *info = 0;
00134     upper = lsame_(uplo, "U");
00135     if (*itype < 1 || *itype > 3) {
00136         *info = -1;
00137     } else if (! upper && ! lsame_(uplo, "L")) {
00138         *info = -2;
00139     } else if (*n < 0) {
00140         *info = -3;
00141     }
00142     if (*info != 0) {
00143         i__1 = -(*info);
00144         xerbla_("ZHPGST", &i__1);
00145         return 0;
00146     }
00147 
00148     if (*itype == 1) {
00149         if (upper) {
00150 
00151 /*           Compute inv(U')*A*inv(U) */
00152 
00153 /*           J1 and JJ are the indices of A(1,j) and A(j,j) */
00154 
00155             jj = 0;
00156             i__1 = *n;
00157             for (j = 1; j <= i__1; ++j) {
00158                 j1 = jj + 1;
00159                 jj += j;
00160 
00161 /*              Compute the j-th column of the upper triangle of A */
00162 
00163                 i__2 = jj;
00164                 i__3 = jj;
00165                 d__1 = ap[i__3].r;
00166                 ap[i__2].r = d__1, ap[i__2].i = 0.;
00167                 i__2 = jj;
00168                 bjj = bp[i__2].r;
00169                 ztpsv_(uplo, "Conjugate transpose", "Non-unit", &j, &bp[1], &
00170                         ap[j1], &c__1);
00171                 i__2 = j - 1;
00172                 z__1.r = -1., z__1.i = -0.;
00173                 zhpmv_(uplo, &i__2, &z__1, &ap[1], &bp[j1], &c__1, &c_b1, &ap[
00174                         j1], &c__1);
00175                 i__2 = j - 1;
00176                 d__1 = 1. / bjj;
00177                 zdscal_(&i__2, &d__1, &ap[j1], &c__1);
00178                 i__2 = jj;
00179                 i__3 = jj;
00180                 i__4 = j - 1;
00181                 zdotc_(&z__3, &i__4, &ap[j1], &c__1, &bp[j1], &c__1);
00182                 z__2.r = ap[i__3].r - z__3.r, z__2.i = ap[i__3].i - z__3.i;
00183                 z__1.r = z__2.r / bjj, z__1.i = z__2.i / bjj;
00184                 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00185 /* L10: */
00186             }
00187         } else {
00188 
00189 /*           Compute inv(L)*A*inv(L') */
00190 
00191 /*           KK and K1K1 are the indices of A(k,k) and A(k+1,k+1) */
00192 
00193             kk = 1;
00194             i__1 = *n;
00195             for (k = 1; k <= i__1; ++k) {
00196                 k1k1 = kk + *n - k + 1;
00197 
00198 /*              Update the lower triangle of A(k:n,k:n) */
00199 
00200                 i__2 = kk;
00201                 akk = ap[i__2].r;
00202                 i__2 = kk;
00203                 bkk = bp[i__2].r;
00204 /* Computing 2nd power */
00205                 d__1 = bkk;
00206                 akk /= d__1 * d__1;
00207                 i__2 = kk;
00208                 ap[i__2].r = akk, ap[i__2].i = 0.;
00209                 if (k < *n) {
00210                     i__2 = *n - k;
00211                     d__1 = 1. / bkk;
00212                     zdscal_(&i__2, &d__1, &ap[kk + 1], &c__1);
00213                     d__1 = akk * -.5;
00214                     ct.r = d__1, ct.i = 0.;
00215                     i__2 = *n - k;
00216                     zaxpy_(&i__2, &ct, &bp[kk + 1], &c__1, &ap[kk + 1], &c__1)
00217                             ;
00218                     i__2 = *n - k;
00219                     z__1.r = -1., z__1.i = -0.;
00220                     zhpr2_(uplo, &i__2, &z__1, &ap[kk + 1], &c__1, &bp[kk + 1]
00221 , &c__1, &ap[k1k1]);
00222                     i__2 = *n - k;
00223                     zaxpy_(&i__2, &ct, &bp[kk + 1], &c__1, &ap[kk + 1], &c__1)
00224                             ;
00225                     i__2 = *n - k;
00226                     ztpsv_(uplo, "No transpose", "Non-unit", &i__2, &bp[k1k1], 
00227                              &ap[kk + 1], &c__1);
00228                 }
00229                 kk = k1k1;
00230 /* L20: */
00231             }
00232         }
00233     } else {
00234         if (upper) {
00235 
00236 /*           Compute U*A*U' */
00237 
00238 /*           K1 and KK are the indices of A(1,k) and A(k,k) */
00239 
00240             kk = 0;
00241             i__1 = *n;
00242             for (k = 1; k <= i__1; ++k) {
00243                 k1 = kk + 1;
00244                 kk += k;
00245 
00246 /*              Update the upper triangle of A(1:k,1:k) */
00247 
00248                 i__2 = kk;
00249                 akk = ap[i__2].r;
00250                 i__2 = kk;
00251                 bkk = bp[i__2].r;
00252                 i__2 = k - 1;
00253                 ztpmv_(uplo, "No transpose", "Non-unit", &i__2, &bp[1], &ap[
00254                         k1], &c__1);
00255                 d__1 = akk * .5;
00256                 ct.r = d__1, ct.i = 0.;
00257                 i__2 = k - 1;
00258                 zaxpy_(&i__2, &ct, &bp[k1], &c__1, &ap[k1], &c__1);
00259                 i__2 = k - 1;
00260                 zhpr2_(uplo, &i__2, &c_b1, &ap[k1], &c__1, &bp[k1], &c__1, &
00261                         ap[1]);
00262                 i__2 = k - 1;
00263                 zaxpy_(&i__2, &ct, &bp[k1], &c__1, &ap[k1], &c__1);
00264                 i__2 = k - 1;
00265                 zdscal_(&i__2, &bkk, &ap[k1], &c__1);
00266                 i__2 = kk;
00267 /* Computing 2nd power */
00268                 d__2 = bkk;
00269                 d__1 = akk * (d__2 * d__2);
00270                 ap[i__2].r = d__1, ap[i__2].i = 0.;
00271 /* L30: */
00272             }
00273         } else {
00274 
00275 /*           Compute L'*A*L */
00276 
00277 /*           JJ and J1J1 are the indices of A(j,j) and A(j+1,j+1) */
00278 
00279             jj = 1;
00280             i__1 = *n;
00281             for (j = 1; j <= i__1; ++j) {
00282                 j1j1 = jj + *n - j + 1;
00283 
00284 /*              Compute the j-th column of the lower triangle of A */
00285 
00286                 i__2 = jj;
00287                 ajj = ap[i__2].r;
00288                 i__2 = jj;
00289                 bjj = bp[i__2].r;
00290                 i__2 = jj;
00291                 d__1 = ajj * bjj;
00292                 i__3 = *n - j;
00293                 zdotc_(&z__2, &i__3, &ap[jj + 1], &c__1, &bp[jj + 1], &c__1);
00294                 z__1.r = d__1 + z__2.r, z__1.i = z__2.i;
00295                 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00296                 i__2 = *n - j;
00297                 zdscal_(&i__2, &bjj, &ap[jj + 1], &c__1);
00298                 i__2 = *n - j;
00299                 zhpmv_(uplo, &i__2, &c_b1, &ap[j1j1], &bp[jj + 1], &c__1, &
00300                         c_b1, &ap[jj + 1], &c__1);
00301                 i__2 = *n - j + 1;
00302                 ztpmv_(uplo, "Conjugate transpose", "Non-unit", &i__2, &bp[jj]
00303 , &ap[jj], &c__1);
00304                 jj = j1j1;
00305 /* L40: */
00306             }
00307         }
00308     }
00309     return 0;
00310 
00311 /*     End of ZHPGST */
00312 
00313 } /* zhpgst_ */


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