dsygst.c
Go to the documentation of this file.
00001 /* dsygst.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 integer c__1 = 1;
00019 static integer c_n1 = -1;
00020 static doublereal c_b14 = 1.;
00021 static doublereal c_b16 = -.5;
00022 static doublereal c_b19 = -1.;
00023 static doublereal c_b52 = .5;
00024 
00025 /* Subroutine */ int dsygst_(integer *itype, char *uplo, integer *n, 
00026         doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *
00027         info)
00028 {
00029     /* System generated locals */
00030     integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
00031 
00032     /* Local variables */
00033     integer k, kb, nb;
00034     extern logical lsame_(char *, char *);
00035     extern /* Subroutine */ int dtrmm_(char *, char *, char *, char *, 
00036             integer *, integer *, doublereal *, doublereal *, integer *, 
00037             doublereal *, integer *), dsymm_(
00038             char *, char *, integer *, integer *, doublereal *, doublereal *, 
00039             integer *, doublereal *, integer *, doublereal *, doublereal *, 
00040             integer *);
00041     logical upper;
00042     extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *, 
00043             integer *, integer *, doublereal *, doublereal *, integer *, 
00044             doublereal *, integer *), dsygs2_(
00045             integer *, char *, integer *, doublereal *, integer *, doublereal 
00046             *, integer *, integer *), dsyr2k_(char *, char *, integer 
00047             *, integer *, doublereal *, doublereal *, integer *, doublereal *, 
00048              integer *, doublereal *, doublereal *, integer *)
00049             , 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 /*  DSYGST reduces a real symmetric-definite generalized eigenproblem */
00067 /*  to standard form. */
00068 
00069 /*  If ITYPE = 1, the problem is A*x = lambda*B*x, */
00070 /*  and A is overwritten by inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T) */
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**T or L**T*A*L. */
00074 
00075 /*  B must have been previously factorized as U**T*U or L*L**T by DPOTRF. */
00076 
00077 /*  Arguments */
00078 /*  ========= */
00079 
00080 /*  ITYPE   (input) INTEGER */
00081 /*          = 1: compute inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T); */
00082 /*          = 2 or 3: compute U*A*U**T or L**T*A*L. */
00083 
00084 /*  UPLO    (input) CHARACTER*1 */
00085 /*          = 'U':  Upper triangle of A is stored and B is factored as */
00086 /*                  U**T*U; */
00087 /*          = 'L':  Lower triangle of A is stored and B is factored as */
00088 /*                  L*L**T. */
00089 
00090 /*  N       (input) INTEGER */
00091 /*          The order of the matrices A and B.  N >= 0. */
00092 
00093 /*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
00094 /*          On entry, the symmetric 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) DOUBLE PRECISION array, dimension (LDB,N) */
00109 /*          The triangular factor from the Cholesky factorization of B, */
00110 /*          as returned by DPOTRF. */
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_("DSYGST", &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, "DSYGST", uplo, n, &c_n1, &c_n1, &c_n1);
00172 
00173     if (nb <= 1 || nb >= *n) {
00174 
00175 /*        Use unblocked code */
00176 
00177         dsygs2_(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                     dsygs2_(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                         dtrsm_("Left", uplo, "Transpose", "Non-unit", &kb, &
00201                                 i__3, &c_b14, &b[k + k * b_dim1], ldb, &a[k + 
00202                                 (k + kb) * a_dim1], lda);
00203                         i__3 = *n - k - kb + 1;
00204                         dsymm_("Left", uplo, &kb, &i__3, &c_b16, &a[k + k * 
00205                                 a_dim1], lda, &b[k + (k + kb) * b_dim1], ldb, 
00206                                 &c_b14, &a[k + (k + kb) * a_dim1], lda);
00207                         i__3 = *n - k - kb + 1;
00208                         dsyr2k_(uplo, "Transpose", &i__3, &kb, &c_b19, &a[k + 
00209                                 (k + kb) * a_dim1], lda, &b[k + (k + kb) * 
00210                                 b_dim1], ldb, &c_b14, &a[k + kb + (k + kb) * 
00211                                 a_dim1], lda);
00212                         i__3 = *n - k - kb + 1;
00213                         dsymm_("Left", uplo, &kb, &i__3, &c_b16, &a[k + k * 
00214                                 a_dim1], lda, &b[k + (k + kb) * b_dim1], ldb, 
00215                                 &c_b14, &a[k + (k + kb) * a_dim1], lda);
00216                         i__3 = *n - k - kb + 1;
00217                         dtrsm_("Right", uplo, "No transpose", "Non-unit", &kb, 
00218                                  &i__3, &c_b14, &b[k + kb + (k + kb) * b_dim1]
00219 , ldb, &a[k + (k + kb) * a_dim1], lda);
00220                     }
00221 /* L10: */
00222                 }
00223             } else {
00224 
00225 /*              Compute inv(L)*A*inv(L') */
00226 
00227                 i__2 = *n;
00228                 i__1 = nb;
00229                 for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) {
00230 /* Computing MIN */
00231                     i__3 = *n - k + 1;
00232                     kb = min(i__3,nb);
00233 
00234 /*                 Update the lower triangle of A(k:n,k:n) */
00235 
00236                     dsygs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k + 
00237                             k * b_dim1], ldb, info);
00238                     if (k + kb <= *n) {
00239                         i__3 = *n - k - kb + 1;
00240                         dtrsm_("Right", uplo, "Transpose", "Non-unit", &i__3, 
00241                                 &kb, &c_b14, &b[k + k * b_dim1], ldb, &a[k + 
00242                                 kb + k * a_dim1], lda);
00243                         i__3 = *n - k - kb + 1;
00244                         dsymm_("Right", uplo, &i__3, &kb, &c_b16, &a[k + k * 
00245                                 a_dim1], lda, &b[k + kb + k * b_dim1], ldb, &
00246                                 c_b14, &a[k + kb + k * a_dim1], lda);
00247                         i__3 = *n - k - kb + 1;
00248                         dsyr2k_(uplo, "No transpose", &i__3, &kb, &c_b19, &a[
00249                                 k + kb + k * a_dim1], lda, &b[k + kb + k * 
00250                                 b_dim1], ldb, &c_b14, &a[k + kb + (k + kb) * 
00251                                 a_dim1], lda);
00252                         i__3 = *n - k - kb + 1;
00253                         dsymm_("Right", uplo, &i__3, &kb, &c_b16, &a[k + k * 
00254                                 a_dim1], lda, &b[k + kb + k * b_dim1], ldb, &
00255                                 c_b14, &a[k + kb + k * a_dim1], lda);
00256                         i__3 = *n - k - kb + 1;
00257                         dtrsm_("Left", uplo, "No transpose", "Non-unit", &
00258                                 i__3, &kb, &c_b14, &b[k + kb + (k + kb) * 
00259                                 b_dim1], ldb, &a[k + kb + k * a_dim1], lda);
00260                     }
00261 /* L20: */
00262                 }
00263             }
00264         } else {
00265             if (upper) {
00266 
00267 /*              Compute U*A*U' */
00268 
00269                 i__1 = *n;
00270                 i__2 = nb;
00271                 for (k = 1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) {
00272 /* Computing MIN */
00273                     i__3 = *n - k + 1;
00274                     kb = min(i__3,nb);
00275 
00276 /*                 Update the upper triangle of A(1:k+kb-1,1:k+kb-1) */
00277 
00278                     i__3 = k - 1;
00279                     dtrmm_("Left", uplo, "No transpose", "Non-unit", &i__3, &
00280                             kb, &c_b14, &b[b_offset], ldb, &a[k * a_dim1 + 1], 
00281                              lda)
00282                             ;
00283                     i__3 = k - 1;
00284                     dsymm_("Right", uplo, &i__3, &kb, &c_b52, &a[k + k * 
00285                             a_dim1], lda, &b[k * b_dim1 + 1], ldb, &c_b14, &a[
00286                             k * a_dim1 + 1], lda);
00287                     i__3 = k - 1;
00288                     dsyr2k_(uplo, "No transpose", &i__3, &kb, &c_b14, &a[k * 
00289                             a_dim1 + 1], lda, &b[k * b_dim1 + 1], ldb, &c_b14, 
00290                              &a[a_offset], lda);
00291                     i__3 = k - 1;
00292                     dsymm_("Right", uplo, &i__3, &kb, &c_b52, &a[k + k * 
00293                             a_dim1], lda, &b[k * b_dim1 + 1], ldb, &c_b14, &a[
00294                             k * a_dim1 + 1], lda);
00295                     i__3 = k - 1;
00296                     dtrmm_("Right", uplo, "Transpose", "Non-unit", &i__3, &kb, 
00297                              &c_b14, &b[k + k * b_dim1], ldb, &a[k * a_dim1 + 
00298                             1], lda);
00299                     dsygs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k + 
00300                             k * b_dim1], ldb, info);
00301 /* L30: */
00302                 }
00303             } else {
00304 
00305 /*              Compute L'*A*L */
00306 
00307                 i__2 = *n;
00308                 i__1 = nb;
00309                 for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) {
00310 /* Computing MIN */
00311                     i__3 = *n - k + 1;
00312                     kb = min(i__3,nb);
00313 
00314 /*                 Update the lower triangle of A(1:k+kb-1,1:k+kb-1) */
00315 
00316                     i__3 = k - 1;
00317                     dtrmm_("Right", uplo, "No transpose", "Non-unit", &kb, &
00318                             i__3, &c_b14, &b[b_offset], ldb, &a[k + a_dim1], 
00319                             lda);
00320                     i__3 = k - 1;
00321                     dsymm_("Left", uplo, &kb, &i__3, &c_b52, &a[k + k * 
00322                             a_dim1], lda, &b[k + b_dim1], ldb, &c_b14, &a[k + 
00323                             a_dim1], lda);
00324                     i__3 = k - 1;
00325                     dsyr2k_(uplo, "Transpose", &i__3, &kb, &c_b14, &a[k + 
00326                             a_dim1], lda, &b[k + b_dim1], ldb, &c_b14, &a[
00327                             a_offset], lda);
00328                     i__3 = k - 1;
00329                     dsymm_("Left", uplo, &kb, &i__3, &c_b52, &a[k + k * 
00330                             a_dim1], lda, &b[k + b_dim1], ldb, &c_b14, &a[k + 
00331                             a_dim1], lda);
00332                     i__3 = k - 1;
00333                     dtrmm_("Left", uplo, "Transpose", "Non-unit", &kb, &i__3, 
00334                             &c_b14, &b[k + k * b_dim1], ldb, &a[k + a_dim1], 
00335                             lda);
00336                     dsygs2_(itype, uplo, &kb, &a[k + k * a_dim1], lda, &b[k + 
00337                             k * b_dim1], ldb, info);
00338 /* L40: */
00339                 }
00340             }
00341         }
00342     }
00343     return 0;
00344 
00345 /*     End of DSYGST */
00346 
00347 } /* dsygst_ */


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