dspgst.c
Go to the documentation of this file.
00001 /* dspgst.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 doublereal c_b9 = -1.;
00020 static doublereal c_b11 = 1.;
00021 
00022 /* Subroutine */ int dspgst_(integer *itype, char *uplo, integer *n, 
00023         doublereal *ap, doublereal *bp, integer *info)
00024 {
00025     /* System generated locals */
00026     integer i__1, i__2;
00027     doublereal d__1;
00028 
00029     /* Local variables */
00030     integer j, k, j1, k1, jj, kk;
00031     doublereal ct, ajj;
00032     integer j1j1;
00033     doublereal akk;
00034     integer k1k1;
00035     doublereal bjj, bkk;
00036     extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *, 
00037             integer *);
00038     extern /* Subroutine */ int dspr2_(char *, integer *, doublereal *, 
00039             doublereal *, integer *, doublereal *, integer *, doublereal *), dscal_(integer *, doublereal *, doublereal *, integer *);
00040     extern logical lsame_(char *, char *);
00041     extern /* Subroutine */ int daxpy_(integer *, doublereal *, doublereal *, 
00042             integer *, doublereal *, integer *), dspmv_(char *, integer *, 
00043             doublereal *, doublereal *, doublereal *, integer *, doublereal *, 
00044              doublereal *, integer *);
00045     logical upper;
00046     extern /* Subroutine */ int dtpmv_(char *, char *, char *, integer *, 
00047             doublereal *, doublereal *, integer *), 
00048             dtpsv_(char *, char *, char *, integer *, doublereal *, 
00049             doublereal *, integer *), xerbla_(char *, 
00050             integer *);
00051 
00052 
00053 /*  -- LAPACK routine (version 3.2) -- */
00054 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00055 /*     November 2006 */
00056 
00057 /*     .. Scalar Arguments .. */
00058 /*     .. */
00059 /*     .. Array Arguments .. */
00060 /*     .. */
00061 
00062 /*  Purpose */
00063 /*  ======= */
00064 
00065 /*  DSPGST reduces a real symmetric-definite generalized eigenproblem */
00066 /*  to standard form, using packed storage. */
00067 
00068 /*  If ITYPE = 1, the problem is A*x = lambda*B*x, */
00069 /*  and A is overwritten by inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T) */
00070 
00071 /*  If ITYPE = 2 or 3, the problem is A*B*x = lambda*x or */
00072 /*  B*A*x = lambda*x, and A is overwritten by U*A*U**T or L**T*A*L. */
00073 
00074 /*  B must have been previously factorized as U**T*U or L*L**T by DPPTRF. */
00075 
00076 /*  Arguments */
00077 /*  ========= */
00078 
00079 /*  ITYPE   (input) INTEGER */
00080 /*          = 1: compute inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T); */
00081 /*          = 2 or 3: compute U*A*U**T or L**T*A*L. */
00082 
00083 /*  UPLO    (input) CHARACTER*1 */
00084 /*          = 'U':  Upper triangle of A is stored and B is factored as */
00085 /*                  U**T*U; */
00086 /*          = 'L':  Lower triangle of A is stored and B is factored as */
00087 /*                  L*L**T. */
00088 
00089 /*  N       (input) INTEGER */
00090 /*          The order of the matrices A and B.  N >= 0. */
00091 
00092 /*  AP      (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
00093 /*          On entry, the upper or lower triangle of the symmetric matrix */
00094 /*          A, packed columnwise in a linear array.  The j-th column of A */
00095 /*          is stored in the array AP as follows: */
00096 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00097 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
00098 
00099 /*          On exit, if INFO = 0, the transformed matrix, stored in the */
00100 /*          same format as A. */
00101 
00102 /*  BP      (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
00103 /*          The triangular factor from the Cholesky factorization of B, */
00104 /*          stored in the same format as A, as returned by DPPTRF. */
00105 
00106 /*  INFO    (output) INTEGER */
00107 /*          = 0:  successful exit */
00108 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00109 
00110 /*  ===================================================================== */
00111 
00112 /*     .. Parameters .. */
00113 /*     .. */
00114 /*     .. Local Scalars .. */
00115 /*     .. */
00116 /*     .. External Subroutines .. */
00117 /*     .. */
00118 /*     .. External Functions .. */
00119 /*     .. */
00120 /*     .. Executable Statements .. */
00121 
00122 /*     Test the input parameters. */
00123 
00124     /* Parameter adjustments */
00125     --bp;
00126     --ap;
00127 
00128     /* Function Body */
00129     *info = 0;
00130     upper = lsame_(uplo, "U");
00131     if (*itype < 1 || *itype > 3) {
00132         *info = -1;
00133     } else if (! upper && ! lsame_(uplo, "L")) {
00134         *info = -2;
00135     } else if (*n < 0) {
00136         *info = -3;
00137     }
00138     if (*info != 0) {
00139         i__1 = -(*info);
00140         xerbla_("DSPGST", &i__1);
00141         return 0;
00142     }
00143 
00144     if (*itype == 1) {
00145         if (upper) {
00146 
00147 /*           Compute inv(U')*A*inv(U) */
00148 
00149 /*           J1 and JJ are the indices of A(1,j) and A(j,j) */
00150 
00151             jj = 0;
00152             i__1 = *n;
00153             for (j = 1; j <= i__1; ++j) {
00154                 j1 = jj + 1;
00155                 jj += j;
00156 
00157 /*              Compute the j-th column of the upper triangle of A */
00158 
00159                 bjj = bp[jj];
00160                 dtpsv_(uplo, "Transpose", "Nonunit", &j, &bp[1], &ap[j1], &
00161                         c__1);
00162                 i__2 = j - 1;
00163                 dspmv_(uplo, &i__2, &c_b9, &ap[1], &bp[j1], &c__1, &c_b11, &
00164                         ap[j1], &c__1);
00165                 i__2 = j - 1;
00166                 d__1 = 1. / bjj;
00167                 dscal_(&i__2, &d__1, &ap[j1], &c__1);
00168                 i__2 = j - 1;
00169                 ap[jj] = (ap[jj] - ddot_(&i__2, &ap[j1], &c__1, &bp[j1], &
00170                         c__1)) / bjj;
00171 /* L10: */
00172             }
00173         } else {
00174 
00175 /*           Compute inv(L)*A*inv(L') */
00176 
00177 /*           KK and K1K1 are the indices of A(k,k) and A(k+1,k+1) */
00178 
00179             kk = 1;
00180             i__1 = *n;
00181             for (k = 1; k <= i__1; ++k) {
00182                 k1k1 = kk + *n - k + 1;
00183 
00184 /*              Update the lower triangle of A(k:n,k:n) */
00185 
00186                 akk = ap[kk];
00187                 bkk = bp[kk];
00188 /* Computing 2nd power */
00189                 d__1 = bkk;
00190                 akk /= d__1 * d__1;
00191                 ap[kk] = akk;
00192                 if (k < *n) {
00193                     i__2 = *n - k;
00194                     d__1 = 1. / bkk;
00195                     dscal_(&i__2, &d__1, &ap[kk + 1], &c__1);
00196                     ct = akk * -.5;
00197                     i__2 = *n - k;
00198                     daxpy_(&i__2, &ct, &bp[kk + 1], &c__1, &ap[kk + 1], &c__1)
00199                             ;
00200                     i__2 = *n - k;
00201                     dspr2_(uplo, &i__2, &c_b9, &ap[kk + 1], &c__1, &bp[kk + 1]
00202 , &c__1, &ap[k1k1]);
00203                     i__2 = *n - k;
00204                     daxpy_(&i__2, &ct, &bp[kk + 1], &c__1, &ap[kk + 1], &c__1)
00205                             ;
00206                     i__2 = *n - k;
00207                     dtpsv_(uplo, "No transpose", "Non-unit", &i__2, &bp[k1k1], 
00208                              &ap[kk + 1], &c__1);
00209                 }
00210                 kk = k1k1;
00211 /* L20: */
00212             }
00213         }
00214     } else {
00215         if (upper) {
00216 
00217 /*           Compute U*A*U' */
00218 
00219 /*           K1 and KK are the indices of A(1,k) and A(k,k) */
00220 
00221             kk = 0;
00222             i__1 = *n;
00223             for (k = 1; k <= i__1; ++k) {
00224                 k1 = kk + 1;
00225                 kk += k;
00226 
00227 /*              Update the upper triangle of A(1:k,1:k) */
00228 
00229                 akk = ap[kk];
00230                 bkk = bp[kk];
00231                 i__2 = k - 1;
00232                 dtpmv_(uplo, "No transpose", "Non-unit", &i__2, &bp[1], &ap[
00233                         k1], &c__1);
00234                 ct = akk * .5;
00235                 i__2 = k - 1;
00236                 daxpy_(&i__2, &ct, &bp[k1], &c__1, &ap[k1], &c__1);
00237                 i__2 = k - 1;
00238                 dspr2_(uplo, &i__2, &c_b11, &ap[k1], &c__1, &bp[k1], &c__1, &
00239                         ap[1]);
00240                 i__2 = k - 1;
00241                 daxpy_(&i__2, &ct, &bp[k1], &c__1, &ap[k1], &c__1);
00242                 i__2 = k - 1;
00243                 dscal_(&i__2, &bkk, &ap[k1], &c__1);
00244 /* Computing 2nd power */
00245                 d__1 = bkk;
00246                 ap[kk] = akk * (d__1 * d__1);
00247 /* L30: */
00248             }
00249         } else {
00250 
00251 /*           Compute L'*A*L */
00252 
00253 /*           JJ and J1J1 are the indices of A(j,j) and A(j+1,j+1) */
00254 
00255             jj = 1;
00256             i__1 = *n;
00257             for (j = 1; j <= i__1; ++j) {
00258                 j1j1 = jj + *n - j + 1;
00259 
00260 /*              Compute the j-th column of the lower triangle of A */
00261 
00262                 ajj = ap[jj];
00263                 bjj = bp[jj];
00264                 i__2 = *n - j;
00265                 ap[jj] = ajj * bjj + ddot_(&i__2, &ap[jj + 1], &c__1, &bp[jj 
00266                         + 1], &c__1);
00267                 i__2 = *n - j;
00268                 dscal_(&i__2, &bjj, &ap[jj + 1], &c__1);
00269                 i__2 = *n - j;
00270                 dspmv_(uplo, &i__2, &c_b11, &ap[j1j1], &bp[jj + 1], &c__1, &
00271                         c_b11, &ap[jj + 1], &c__1);
00272                 i__2 = *n - j + 1;
00273                 dtpmv_(uplo, "Transpose", "Non-unit", &i__2, &bp[jj], &ap[jj], 
00274                          &c__1);
00275                 jj = j1j1;
00276 /* L40: */
00277             }
00278         }
00279     }
00280     return 0;
00281 
00282 /*     End of DSPGST */
00283 
00284 } /* dspgst_ */


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