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


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