zhegst.c
Go to the documentation of this file.
00001 /* zhegst.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 doublecomplex c_b2 = {.5,0.};
00020 static integer c__1 = 1;
00021 static integer c_n1 = -1;
00022 static doublereal c_b18 = 1.;
00023 
00024 /* Subroutine */ int zhegst_(integer *itype, char *uplo, integer *n, 
00025         doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, 
00026         integer *info)
00027 {
00028     /* System generated locals */
00029     integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
00030     doublecomplex z__1;
00031 
00032     /* Local variables */
00033     integer k, kb, nb;
00034     extern logical lsame_(char *, char *);
00035     extern /* Subroutine */ int zhemm_(char *, char *, integer *, integer *, 
00036             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00037             integer *, doublecomplex *, doublecomplex *, integer *);
00038     logical upper;
00039     extern /* Subroutine */ int ztrmm_(char *, char *, char *, char *, 
00040             integer *, integer *, doublecomplex *, doublecomplex *, integer *, 
00041              doublecomplex *, integer *), 
00042             ztrsm_(char *, char *, char *, char *, integer *, integer *, 
00043             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00044             integer *), zhegs2_(integer *, 
00045             char *, integer *, doublecomplex *, integer *, doublecomplex *, 
00046             integer *, integer *), zher2k_(char *, char *, integer *, 
00047             integer *, doublecomplex *, doublecomplex *, integer *, 
00048             doublecomplex *, integer *, doublereal *, doublecomplex *, 
00049             integer *), xerbla_(char *, integer *);
00050     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00051             integer *, integer *);
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 /*  ZHEGST reduces a complex Hermitian-definite generalized */
00067 /*  eigenproblem to standard form. */
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 ZPOTRF. */
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 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N) */
00094 /*          On entry, the Hermitian matrix A.  If UPLO = 'U', the leading */
00095 /*          N-by-N upper triangular part of A contains the upper */
00096 /*          triangular part of the matrix A, and the strictly lower */
00097 /*          triangular part of A is not referenced.  If UPLO = 'L', the */
00098 /*          leading N-by-N lower triangular part of A contains the lower */
00099 /*          triangular part of the matrix A, and the strictly upper */
00100 /*          triangular part of A is not referenced. */
00101 
00102 /*          On exit, if INFO = 0, the transformed matrix, stored in the */
00103 /*          same format as A. */
00104 
00105 /*  LDA     (input) INTEGER */
00106 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00107 
00108 /*  B       (input) COMPLEX*16 array, dimension (LDB,N) */
00109 /*          The triangular factor from the Cholesky factorization of B, */
00110 /*          as returned by ZPOTRF. */
00111 
00112 /*  LDB     (input) INTEGER */
00113 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00114 
00115 /*  INFO    (output) INTEGER */
00116 /*          = 0:  successful exit */
00117 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00118 
00119 /*  ===================================================================== */
00120 
00121 /*     .. Parameters .. */
00122 /*     .. */
00123 /*     .. Local Scalars .. */
00124 /*     .. */
00125 /*     .. External Subroutines .. */
00126 /*     .. */
00127 /*     .. Intrinsic Functions .. */
00128 /*     .. */
00129 /*     .. External Functions .. */
00130 /*     .. */
00131 /*     .. Executable Statements .. */
00132 
00133 /*     Test the input parameters. */
00134 
00135     /* Parameter adjustments */
00136     a_dim1 = *lda;
00137     a_offset = 1 + a_dim1;
00138     a -= a_offset;
00139     b_dim1 = *ldb;
00140     b_offset = 1 + b_dim1;
00141     b -= b_offset;
00142 
00143     /* Function Body */
00144     *info = 0;
00145     upper = lsame_(uplo, "U");
00146     if (*itype < 1 || *itype > 3) {
00147         *info = -1;
00148     } else if (! upper && ! lsame_(uplo, "L")) {
00149         *info = -2;
00150     } else if (*n < 0) {
00151         *info = -3;
00152     } else if (*lda < max(1,*n)) {
00153         *info = -5;
00154     } else if (*ldb < max(1,*n)) {
00155         *info = -7;
00156     }
00157     if (*info != 0) {
00158         i__1 = -(*info);
00159         xerbla_("ZHEGST", &i__1);
00160         return 0;
00161     }
00162 
00163 /*     Quick return if possible */
00164 
00165     if (*n == 0) {
00166         return 0;
00167     }
00168 
00169 /*     Determine the block size for this environment. */
00170 
00171     nb = ilaenv_(&c__1, "ZHEGST", uplo, n, &c_n1, &c_n1, &c_n1);
00172 
00173     if (nb <= 1 || nb >= *n) {
00174 
00175 /*        Use unblocked code */
00176 
00177         zhegs2_(itype, uplo, n, &a[a_offset], lda, &b[b_offset], ldb, info);
00178     } else {
00179 
00180 /*        Use blocked code */
00181 
00182         if (*itype == 1) {
00183             if (upper) {
00184 
00185 /*              Compute inv(U')*A*inv(U) */
00186 
00187                 i__1 = *n;
00188                 i__2 = nb;
00189                 for (k = 1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) {
00190 /* Computing MIN */
00191                     i__3 = *n - k + 1;
00192                     kb = min(i__3,nb);
00193 
00194 /*                 Update the upper triangle of A(k:n,k:n) */
00195 
00196                     zhegs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k + 
00197                             k * b_dim1], ldb, info);
00198                     if (k + kb <= *n) {
00199                         i__3 = *n - k - kb + 1;
00200                         ztrsm_("Left", uplo, "Conjugate transpose", "Non-unit"
00201 , &kb, &i__3, &c_b1, &b[k + k * b_dim1], ldb, 
00202                                 &a[k + (k + kb) * a_dim1], lda);
00203                         i__3 = *n - k - kb + 1;
00204                         z__1.r = -.5, z__1.i = -0.;
00205                         zhemm_("Left", uplo, &kb, &i__3, &z__1, &a[k + k * 
00206                                 a_dim1], lda, &b[k + (k + kb) * b_dim1], ldb, 
00207                                 &c_b1, &a[k + (k + kb) * a_dim1], lda);
00208                         i__3 = *n - k - kb + 1;
00209                         z__1.r = -1., z__1.i = -0.;
00210                         zher2k_(uplo, "Conjugate transpose", &i__3, &kb, &
00211                                 z__1, &a[k + (k + kb) * a_dim1], lda, &b[k + (
00212                                 k + kb) * b_dim1], ldb, &c_b18, &a[k + kb + (
00213                                 k + kb) * a_dim1], lda)
00214                                 ;
00215                         i__3 = *n - k - kb + 1;
00216                         z__1.r = -.5, z__1.i = -0.;
00217                         zhemm_("Left", uplo, &kb, &i__3, &z__1, &a[k + k * 
00218                                 a_dim1], lda, &b[k + (k + kb) * b_dim1], ldb, 
00219                                 &c_b1, &a[k + (k + kb) * a_dim1], lda);
00220                         i__3 = *n - k - kb + 1;
00221                         ztrsm_("Right", uplo, "No transpose", "Non-unit", &kb, 
00222                                  &i__3, &c_b1, &b[k + kb + (k + kb) * b_dim1], 
00223                                  ldb, &a[k + (k + kb) * a_dim1], lda);
00224                     }
00225 /* L10: */
00226                 }
00227             } else {
00228 
00229 /*              Compute inv(L)*A*inv(L') */
00230 
00231                 i__2 = *n;
00232                 i__1 = nb;
00233                 for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) {
00234 /* Computing MIN */
00235                     i__3 = *n - k + 1;
00236                     kb = min(i__3,nb);
00237 
00238 /*                 Update the lower triangle of A(k:n,k:n) */
00239 
00240                     zhegs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k + 
00241                             k * b_dim1], ldb, info);
00242                     if (k + kb <= *n) {
00243                         i__3 = *n - k - kb + 1;
00244                         ztrsm_("Right", uplo, "Conjugate transpose", "Non-un"
00245                                 "it", &i__3, &kb, &c_b1, &b[k + k * b_dim1], 
00246                                 ldb, &a[k + kb + k * a_dim1], lda);
00247                         i__3 = *n - k - kb + 1;
00248                         z__1.r = -.5, z__1.i = -0.;
00249                         zhemm_("Right", uplo, &i__3, &kb, &z__1, &a[k + k * 
00250                                 a_dim1], lda, &b[k + kb + k * b_dim1], ldb, &
00251                                 c_b1, &a[k + kb + k * a_dim1], lda);
00252                         i__3 = *n - k - kb + 1;
00253                         z__1.r = -1., z__1.i = -0.;
00254                         zher2k_(uplo, "No transpose", &i__3, &kb, &z__1, &a[k 
00255                                 + kb + k * a_dim1], lda, &b[k + kb + k * 
00256                                 b_dim1], ldb, &c_b18, &a[k + kb + (k + kb) * 
00257                                 a_dim1], lda);
00258                         i__3 = *n - k - kb + 1;
00259                         z__1.r = -.5, z__1.i = -0.;
00260                         zhemm_("Right", uplo, &i__3, &kb, &z__1, &a[k + k * 
00261                                 a_dim1], lda, &b[k + kb + k * b_dim1], ldb, &
00262                                 c_b1, &a[k + kb + k * a_dim1], lda);
00263                         i__3 = *n - k - kb + 1;
00264                         ztrsm_("Left", uplo, "No transpose", "Non-unit", &
00265                                 i__3, &kb, &c_b1, &b[k + kb + (k + kb) * 
00266                                 b_dim1], ldb, &a[k + kb + k * a_dim1], lda);
00267                     }
00268 /* L20: */
00269                 }
00270             }
00271         } else {
00272             if (upper) {
00273 
00274 /*              Compute U*A*U' */
00275 
00276                 i__1 = *n;
00277                 i__2 = nb;
00278                 for (k = 1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) {
00279 /* Computing MIN */
00280                     i__3 = *n - k + 1;
00281                     kb = min(i__3,nb);
00282 
00283 /*                 Update the upper triangle of A(1:k+kb-1,1:k+kb-1) */
00284 
00285                     i__3 = k - 1;
00286                     ztrmm_("Left", uplo, "No transpose", "Non-unit", &i__3, &
00287                             kb, &c_b1, &b[b_offset], ldb, &a[k * a_dim1 + 1], 
00288                             lda);
00289                     i__3 = k - 1;
00290                     zhemm_("Right", uplo, &i__3, &kb, &c_b2, &a[k + k * 
00291                             a_dim1], lda, &b[k * b_dim1 + 1], ldb, &c_b1, &a[
00292                             k * a_dim1 + 1], lda);
00293                     i__3 = k - 1;
00294                     zher2k_(uplo, "No transpose", &i__3, &kb, &c_b1, &a[k * 
00295                             a_dim1 + 1], lda, &b[k * b_dim1 + 1], ldb, &c_b18, 
00296                              &a[a_offset], lda);
00297                     i__3 = k - 1;
00298                     zhemm_("Right", uplo, &i__3, &kb, &c_b2, &a[k + k * 
00299                             a_dim1], lda, &b[k * b_dim1 + 1], ldb, &c_b1, &a[
00300                             k * a_dim1 + 1], lda);
00301                     i__3 = k - 1;
00302                     ztrmm_("Right", uplo, "Conjugate transpose", "Non-unit", &
00303                             i__3, &kb, &c_b1, &b[k + k * b_dim1], ldb, &a[k * 
00304                             a_dim1 + 1], lda);
00305                     zhegs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k + 
00306                             k * b_dim1], ldb, info);
00307 /* L30: */
00308                 }
00309             } else {
00310 
00311 /*              Compute L'*A*L */
00312 
00313                 i__2 = *n;
00314                 i__1 = nb;
00315                 for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) {
00316 /* Computing MIN */
00317                     i__3 = *n - k + 1;
00318                     kb = min(i__3,nb);
00319 
00320 /*                 Update the lower triangle of A(1:k+kb-1,1:k+kb-1) */
00321 
00322                     i__3 = k - 1;
00323                     ztrmm_("Right", uplo, "No transpose", "Non-unit", &kb, &
00324                             i__3, &c_b1, &b[b_offset], ldb, &a[k + a_dim1], 
00325                             lda);
00326                     i__3 = k - 1;
00327                     zhemm_("Left", uplo, &kb, &i__3, &c_b2, &a[k + k * a_dim1]
00328 , lda, &b[k + b_dim1], ldb, &c_b1, &a[k + a_dim1], 
00329                              lda);
00330                     i__3 = k - 1;
00331                     zher2k_(uplo, "Conjugate transpose", &i__3, &kb, &c_b1, &
00332                             a[k + a_dim1], lda, &b[k + b_dim1], ldb, &c_b18, &
00333                             a[a_offset], lda);
00334                     i__3 = k - 1;
00335                     zhemm_("Left", uplo, &kb, &i__3, &c_b2, &a[k + k * a_dim1]
00336 , lda, &b[k + b_dim1], ldb, &c_b1, &a[k + a_dim1], 
00337                              lda);
00338                     i__3 = k - 1;
00339                     ztrmm_("Left", uplo, "Conjugate transpose", "Non-unit", &
00340                             kb, &i__3, &c_b1, &b[k + k * b_dim1], ldb, &a[k + 
00341                             a_dim1], lda);
00342                     zhegs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k + 
00343                             k * b_dim1], ldb, info);
00344 /* L40: */
00345                 }
00346             }
00347         }
00348     }
00349     return 0;
00350 
00351 /*     End of ZHEGST */
00352 
00353 } /* zhegst_ */


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