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


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