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


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