slaeda.c
Go to the documentation of this file.
00001 /* slaeda.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__2 = 2;
00019 static integer c__1 = 1;
00020 static real c_b24 = 1.f;
00021 static real c_b26 = 0.f;
00022 
00023 /* Subroutine */ int slaeda_(integer *n, integer *tlvls, integer *curlvl, 
00024         integer *curpbm, integer *prmptr, integer *perm, integer *givptr, 
00025         integer *givcol, real *givnum, real *q, integer *qptr, real *z__, 
00026         real *ztemp, integer *info)
00027 {
00028     /* System generated locals */
00029     integer i__1, i__2, i__3;
00030 
00031     /* Builtin functions */
00032     integer pow_ii(integer *, integer *);
00033     double sqrt(doublereal);
00034 
00035     /* Local variables */
00036     integer i__, k, mid, ptr, curr;
00037     extern /* Subroutine */ int srot_(integer *, real *, integer *, real *, 
00038             integer *, real *, real *);
00039     integer bsiz1, bsiz2, psiz1, psiz2, zptr1;
00040     extern /* Subroutine */ int sgemv_(char *, integer *, integer *, real *, 
00041             real *, integer *, real *, integer *, real *, real *, integer *), scopy_(integer *, real *, integer *, real *, integer *), 
00042             xerbla_(char *, integer *);
00043 
00044 
00045 /*  -- LAPACK routine (version 3.2) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  SLAEDA computes the Z vector corresponding to the merge step in the */
00058 /*  CURLVLth step of the merge process with TLVLS steps for the CURPBMth */
00059 /*  problem. */
00060 
00061 /*  Arguments */
00062 /*  ========= */
00063 
00064 /*  N      (input) INTEGER */
00065 /*         The dimension of the symmetric tridiagonal matrix.  N >= 0. */
00066 
00067 /*  TLVLS  (input) INTEGER */
00068 /*         The total number of merging levels in the overall divide and */
00069 /*         conquer tree. */
00070 
00071 /*  CURLVL (input) INTEGER */
00072 /*         The current level in the overall merge routine, */
00073 /*         0 <= curlvl <= tlvls. */
00074 
00075 /*  CURPBM (input) INTEGER */
00076 /*         The current problem in the current level in the overall */
00077 /*         merge routine (counting from upper left to lower right). */
00078 
00079 /*  PRMPTR (input) INTEGER array, dimension (N lg N) */
00080 /*         Contains a list of pointers which indicate where in PERM a */
00081 /*         level's permutation is stored.  PRMPTR(i+1) - PRMPTR(i) */
00082 /*         indicates the size of the permutation and incidentally the */
00083 /*         size of the full, non-deflated problem. */
00084 
00085 /*  PERM   (input) INTEGER array, dimension (N lg N) */
00086 /*         Contains the permutations (from deflation and sorting) to be */
00087 /*         applied to each eigenblock. */
00088 
00089 /*  GIVPTR (input) INTEGER array, dimension (N lg N) */
00090 /*         Contains a list of pointers which indicate where in GIVCOL a */
00091 /*         level's Givens rotations are stored.  GIVPTR(i+1) - GIVPTR(i) */
00092 /*         indicates the number of Givens rotations. */
00093 
00094 /*  GIVCOL (input) INTEGER array, dimension (2, N lg N) */
00095 /*         Each pair of numbers indicates a pair of columns to take place */
00096 /*         in a Givens rotation. */
00097 
00098 /*  GIVNUM (input) REAL array, dimension (2, N lg N) */
00099 /*         Each number indicates the S value to be used in the */
00100 /*         corresponding Givens rotation. */
00101 
00102 /*  Q      (input) REAL array, dimension (N**2) */
00103 /*         Contains the square eigenblocks from previous levels, the */
00104 /*         starting positions for blocks are given by QPTR. */
00105 
00106 /*  QPTR   (input) INTEGER array, dimension (N+2) */
00107 /*         Contains a list of pointers which indicate where in Q an */
00108 /*         eigenblock is stored.  SQRT( QPTR(i+1) - QPTR(i) ) indicates */
00109 /*         the size of the block. */
00110 
00111 /*  Z      (output) REAL array, dimension (N) */
00112 /*         On output this vector contains the updating vector (the last */
00113 /*         row of the first sub-eigenvector matrix and the first row of */
00114 /*         the second sub-eigenvector matrix). */
00115 
00116 /*  ZTEMP  (workspace) REAL array, dimension (N) */
00117 
00118 /*  INFO   (output) INTEGER */
00119 /*          = 0:  successful exit. */
00120 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00121 
00122 /*  Further Details */
00123 /*  =============== */
00124 
00125 /*  Based on contributions by */
00126 /*     Jeff Rutter, Computer Science Division, University of California */
00127 /*     at Berkeley, USA */
00128 
00129 /*  ===================================================================== */
00130 
00131 /*     .. Parameters .. */
00132 /*     .. */
00133 /*     .. Local Scalars .. */
00134 /*     .. */
00135 /*     .. External Subroutines .. */
00136 /*     .. */
00137 /*     .. Intrinsic Functions .. */
00138 /*     .. */
00139 /*     .. Executable Statements .. */
00140 
00141 /*     Test the input parameters. */
00142 
00143     /* Parameter adjustments */
00144     --ztemp;
00145     --z__;
00146     --qptr;
00147     --q;
00148     givnum -= 3;
00149     givcol -= 3;
00150     --givptr;
00151     --perm;
00152     --prmptr;
00153 
00154     /* Function Body */
00155     *info = 0;
00156 
00157     if (*n < 0) {
00158         *info = -1;
00159     }
00160     if (*info != 0) {
00161         i__1 = -(*info);
00162         xerbla_("SLAEDA", &i__1);
00163         return 0;
00164     }
00165 
00166 /*     Quick return if possible */
00167 
00168     if (*n == 0) {
00169         return 0;
00170     }
00171 
00172 /*     Determine location of first number in second half. */
00173 
00174     mid = *n / 2 + 1;
00175 
00176 /*     Gather last/first rows of appropriate eigenblocks into center of Z */
00177 
00178     ptr = 1;
00179 
00180 /*     Determine location of lowest level subproblem in the full storage */
00181 /*     scheme */
00182 
00183     i__1 = *curlvl - 1;
00184     curr = ptr + *curpbm * pow_ii(&c__2, curlvl) + pow_ii(&c__2, &i__1) - 1;
00185 
00186 /*     Determine size of these matrices.  We add HALF to the value of */
00187 /*     the SQRT in case the machine underestimates one of these square */
00188 /*     roots. */
00189 
00190     bsiz1 = (integer) (sqrt((real) (qptr[curr + 1] - qptr[curr])) + .5f);
00191     bsiz2 = (integer) (sqrt((real) (qptr[curr + 2] - qptr[curr + 1])) + .5f);
00192     i__1 = mid - bsiz1 - 1;
00193     for (k = 1; k <= i__1; ++k) {
00194         z__[k] = 0.f;
00195 /* L10: */
00196     }
00197     scopy_(&bsiz1, &q[qptr[curr] + bsiz1 - 1], &bsiz1, &z__[mid - bsiz1], &
00198             c__1);
00199     scopy_(&bsiz2, &q[qptr[curr + 1]], &bsiz2, &z__[mid], &c__1);
00200     i__1 = *n;
00201     for (k = mid + bsiz2; k <= i__1; ++k) {
00202         z__[k] = 0.f;
00203 /* L20: */
00204     }
00205 
00206 /*     Loop thru remaining levels 1 -> CURLVL applying the Givens */
00207 /*     rotations and permutation and then multiplying the center matrices */
00208 /*     against the current Z. */
00209 
00210     ptr = pow_ii(&c__2, tlvls) + 1;
00211     i__1 = *curlvl - 1;
00212     for (k = 1; k <= i__1; ++k) {
00213         i__2 = *curlvl - k;
00214         i__3 = *curlvl - k - 1;
00215         curr = ptr + *curpbm * pow_ii(&c__2, &i__2) + pow_ii(&c__2, &i__3) - 
00216                 1;
00217         psiz1 = prmptr[curr + 1] - prmptr[curr];
00218         psiz2 = prmptr[curr + 2] - prmptr[curr + 1];
00219         zptr1 = mid - psiz1;
00220 
00221 /*       Apply Givens at CURR and CURR+1 */
00222 
00223         i__2 = givptr[curr + 1] - 1;
00224         for (i__ = givptr[curr]; i__ <= i__2; ++i__) {
00225             srot_(&c__1, &z__[zptr1 + givcol[(i__ << 1) + 1] - 1], &c__1, &
00226                     z__[zptr1 + givcol[(i__ << 1) + 2] - 1], &c__1, &givnum[(
00227                     i__ << 1) + 1], &givnum[(i__ << 1) + 2]);
00228 /* L30: */
00229         }
00230         i__2 = givptr[curr + 2] - 1;
00231         for (i__ = givptr[curr + 1]; i__ <= i__2; ++i__) {
00232             srot_(&c__1, &z__[mid - 1 + givcol[(i__ << 1) + 1]], &c__1, &z__[
00233                     mid - 1 + givcol[(i__ << 1) + 2]], &c__1, &givnum[(i__ << 
00234                     1) + 1], &givnum[(i__ << 1) + 2]);
00235 /* L40: */
00236         }
00237         psiz1 = prmptr[curr + 1] - prmptr[curr];
00238         psiz2 = prmptr[curr + 2] - prmptr[curr + 1];
00239         i__2 = psiz1 - 1;
00240         for (i__ = 0; i__ <= i__2; ++i__) {
00241             ztemp[i__ + 1] = z__[zptr1 + perm[prmptr[curr] + i__] - 1];
00242 /* L50: */
00243         }
00244         i__2 = psiz2 - 1;
00245         for (i__ = 0; i__ <= i__2; ++i__) {
00246             ztemp[psiz1 + i__ + 1] = z__[mid + perm[prmptr[curr + 1] + i__] - 
00247                     1];
00248 /* L60: */
00249         }
00250 
00251 /*        Multiply Blocks at CURR and CURR+1 */
00252 
00253 /*        Determine size of these matrices.  We add HALF to the value of */
00254 /*        the SQRT in case the machine underestimates one of these */
00255 /*        square roots. */
00256 
00257         bsiz1 = (integer) (sqrt((real) (qptr[curr + 1] - qptr[curr])) + .5f);
00258         bsiz2 = (integer) (sqrt((real) (qptr[curr + 2] - qptr[curr + 1])) + 
00259                 .5f);
00260         if (bsiz1 > 0) {
00261             sgemv_("T", &bsiz1, &bsiz1, &c_b24, &q[qptr[curr]], &bsiz1, &
00262                     ztemp[1], &c__1, &c_b26, &z__[zptr1], &c__1);
00263         }
00264         i__2 = psiz1 - bsiz1;
00265         scopy_(&i__2, &ztemp[bsiz1 + 1], &c__1, &z__[zptr1 + bsiz1], &c__1);
00266         if (bsiz2 > 0) {
00267             sgemv_("T", &bsiz2, &bsiz2, &c_b24, &q[qptr[curr + 1]], &bsiz2, &
00268                     ztemp[psiz1 + 1], &c__1, &c_b26, &z__[mid], &c__1);
00269         }
00270         i__2 = psiz2 - bsiz2;
00271         scopy_(&i__2, &ztemp[psiz1 + bsiz2 + 1], &c__1, &z__[mid + bsiz2], &
00272                 c__1);
00273 
00274         i__2 = *tlvls - k;
00275         ptr += pow_ii(&c__2, &i__2);
00276 /* L70: */
00277     }
00278 
00279     return 0;
00280 
00281 /*     End of SLAEDA */
00282 
00283 } /* slaeda_ */


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