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


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