slasq3.c
Go to the documentation of this file.
00001 /* slasq3.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 /* Subroutine */ int slasq3_(integer *i0, integer *n0, real *z__, integer *pp, 
00017          real *dmin__, real *sigma, real *desig, real *qmax, integer *nfail, 
00018         integer *iter, integer *ndiv, logical *ieee, integer *ttype, real *
00019         dmin1, real *dmin2, real *dn, real *dn1, real *dn2, real *g, real *
00020         tau)
00021 {
00022     /* System generated locals */
00023     integer i__1;
00024     real r__1, r__2;
00025 
00026     /* Builtin functions */
00027     double sqrt(doublereal);
00028 
00029     /* Local variables */
00030     real s, t;
00031     integer j4, nn;
00032     real eps, tol;
00033     integer n0in, ipn4;
00034     real tol2, temp;
00035     extern /* Subroutine */ int slasq4_(integer *, integer *, real *, integer 
00036             *, integer *, real *, real *, real *, real *, real *, real *, 
00037             real *, integer *, real *), slasq5_(integer *, integer *, real *, 
00038             integer *, real *, real *, real *, real *, real *, real *, real *, 
00039              logical *), slasq6_(integer *, integer *, real *, integer *, 
00040             real *, real *, real *, real *, real *, real *);
00041     extern doublereal slamch_(char *);
00042     extern logical sisnan_(real *);
00043 
00044 
00045 /*  -- LAPACK routine (version 3.2)                                    -- */
00046 
00047 /*  -- Contributed by Osni Marques of the Lawrence Berkeley National   -- */
00048 /*  -- Laboratory and Beresford Parlett of the Univ. of California at  -- */
00049 /*  -- Berkeley                                                        -- */
00050 /*  -- November 2008                                                   -- */
00051 
00052 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
00053 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
00054 
00055 /*     .. Scalar Arguments .. */
00056 /*     .. */
00057 /*     .. Array Arguments .. */
00058 /*     .. */
00059 
00060 /*  Purpose */
00061 /*  ======= */
00062 
00063 /*  SLASQ3 checks for deflation, computes a shift (TAU) and calls dqds. */
00064 /*  In case of failure it changes shifts, and tries again until output */
00065 /*  is positive. */
00066 
00067 /*  Arguments */
00068 /*  ========= */
00069 
00070 /*  I0     (input) INTEGER */
00071 /*         First index. */
00072 
00073 /*  N0     (input) INTEGER */
00074 /*         Last index. */
00075 
00076 /*  Z      (input) REAL array, dimension ( 4*N ) */
00077 /*         Z holds the qd array. */
00078 
00079 /*  PP     (input/output) INTEGER */
00080 /*         PP=0 for ping, PP=1 for pong. */
00081 /*         PP=2 indicates that flipping was applied to the Z array */
00082 /*         and that the initial tests for deflation should not be */
00083 /*         performed. */
00084 
00085 /*  DMIN   (output) REAL */
00086 /*         Minimum value of d. */
00087 
00088 /*  SIGMA  (output) REAL */
00089 /*         Sum of shifts used in current segment. */
00090 
00091 /*  DESIG  (input/output) REAL */
00092 /*         Lower order part of SIGMA */
00093 
00094 /*  QMAX   (input) REAL */
00095 /*         Maximum value of q. */
00096 
00097 /*  NFAIL  (output) INTEGER */
00098 /*         Number of times shift was too big. */
00099 
00100 /*  ITER   (output) INTEGER */
00101 /*         Number of iterations. */
00102 
00103 /*  NDIV   (output) INTEGER */
00104 /*         Number of divisions. */
00105 
00106 /*  IEEE   (input) LOGICAL */
00107 /*         Flag for IEEE or non IEEE arithmetic (passed to SLASQ5). */
00108 
00109 /*  TTYPE  (input/output) INTEGER */
00110 /*         Shift type. */
00111 
00112 /*  DMIN1, DMIN2, DN, DN1, DN2, G, TAU (input/output) REAL */
00113 /*         These are passed as arguments in order to save their values */
00114 /*         between calls to SLASQ3. */
00115 
00116 /*  ===================================================================== */
00117 
00118 /*     .. Parameters .. */
00119 /*     .. */
00120 /*     .. Local Scalars .. */
00121 /*     .. */
00122 /*     .. External Subroutines .. */
00123 /*     .. */
00124 /*     .. External Function .. */
00125 /*     .. */
00126 /*     .. Intrinsic Functions .. */
00127 /*     .. */
00128 /*     .. Executable Statements .. */
00129 
00130     /* Parameter adjustments */
00131     --z__;
00132 
00133     /* Function Body */
00134     n0in = *n0;
00135     eps = slamch_("Precision");
00136     tol = eps * 100.f;
00137 /* Computing 2nd power */
00138     r__1 = tol;
00139     tol2 = r__1 * r__1;
00140 
00141 /*     Check for deflation. */
00142 
00143 L10:
00144 
00145     if (*n0 < *i0) {
00146         return 0;
00147     }
00148     if (*n0 == *i0) {
00149         goto L20;
00150     }
00151     nn = (*n0 << 2) + *pp;
00152     if (*n0 == *i0 + 1) {
00153         goto L40;
00154     }
00155 
00156 /*     Check whether E(N0-1) is negligible, 1 eigenvalue. */
00157 
00158     if (z__[nn - 5] > tol2 * (*sigma + z__[nn - 3]) && z__[nn - (*pp << 1) - 
00159             4] > tol2 * z__[nn - 7]) {
00160         goto L30;
00161     }
00162 
00163 L20:
00164 
00165     z__[(*n0 << 2) - 3] = z__[(*n0 << 2) + *pp - 3] + *sigma;
00166     --(*n0);
00167     goto L10;
00168 
00169 /*     Check  whether E(N0-2) is negligible, 2 eigenvalues. */
00170 
00171 L30:
00172 
00173     if (z__[nn - 9] > tol2 * *sigma && z__[nn - (*pp << 1) - 8] > tol2 * z__[
00174             nn - 11]) {
00175         goto L50;
00176     }
00177 
00178 L40:
00179 
00180     if (z__[nn - 3] > z__[nn - 7]) {
00181         s = z__[nn - 3];
00182         z__[nn - 3] = z__[nn - 7];
00183         z__[nn - 7] = s;
00184     }
00185     if (z__[nn - 5] > z__[nn - 3] * tol2) {
00186         t = (z__[nn - 7] - z__[nn - 3] + z__[nn - 5]) * .5f;
00187         s = z__[nn - 3] * (z__[nn - 5] / t);
00188         if (s <= t) {
00189             s = z__[nn - 3] * (z__[nn - 5] / (t * (sqrt(s / t + 1.f) + 1.f)));
00190         } else {
00191             s = z__[nn - 3] * (z__[nn - 5] / (t + sqrt(t) * sqrt(t + s)));
00192         }
00193         t = z__[nn - 7] + (s + z__[nn - 5]);
00194         z__[nn - 3] *= z__[nn - 7] / t;
00195         z__[nn - 7] = t;
00196     }
00197     z__[(*n0 << 2) - 7] = z__[nn - 7] + *sigma;
00198     z__[(*n0 << 2) - 3] = z__[nn - 3] + *sigma;
00199     *n0 += -2;
00200     goto L10;
00201 
00202 L50:
00203     if (*pp == 2) {
00204         *pp = 0;
00205     }
00206 
00207 /*     Reverse the qd-array, if warranted. */
00208 
00209     if (*dmin__ <= 0.f || *n0 < n0in) {
00210         if (z__[(*i0 << 2) + *pp - 3] * 1.5f < z__[(*n0 << 2) + *pp - 3]) {
00211             ipn4 = *i0 + *n0 << 2;
00212             i__1 = *i0 + *n0 - 1 << 1;
00213             for (j4 = *i0 << 2; j4 <= i__1; j4 += 4) {
00214                 temp = z__[j4 - 3];
00215                 z__[j4 - 3] = z__[ipn4 - j4 - 3];
00216                 z__[ipn4 - j4 - 3] = temp;
00217                 temp = z__[j4 - 2];
00218                 z__[j4 - 2] = z__[ipn4 - j4 - 2];
00219                 z__[ipn4 - j4 - 2] = temp;
00220                 temp = z__[j4 - 1];
00221                 z__[j4 - 1] = z__[ipn4 - j4 - 5];
00222                 z__[ipn4 - j4 - 5] = temp;
00223                 temp = z__[j4];
00224                 z__[j4] = z__[ipn4 - j4 - 4];
00225                 z__[ipn4 - j4 - 4] = temp;
00226 /* L60: */
00227             }
00228             if (*n0 - *i0 <= 4) {
00229                 z__[(*n0 << 2) + *pp - 1] = z__[(*i0 << 2) + *pp - 1];
00230                 z__[(*n0 << 2) - *pp] = z__[(*i0 << 2) - *pp];
00231             }
00232 /* Computing MIN */
00233             r__1 = *dmin2, r__2 = z__[(*n0 << 2) + *pp - 1];
00234             *dmin2 = dmin(r__1,r__2);
00235 /* Computing MIN */
00236             r__1 = z__[(*n0 << 2) + *pp - 1], r__2 = z__[(*i0 << 2) + *pp - 1]
00237                     , r__1 = min(r__1,r__2), r__2 = z__[(*i0 << 2) + *pp + 3];
00238             z__[(*n0 << 2) + *pp - 1] = dmin(r__1,r__2);
00239 /* Computing MIN */
00240             r__1 = z__[(*n0 << 2) - *pp], r__2 = z__[(*i0 << 2) - *pp], r__1 =
00241                      min(r__1,r__2), r__2 = z__[(*i0 << 2) - *pp + 4];
00242             z__[(*n0 << 2) - *pp] = dmin(r__1,r__2);
00243 /* Computing MAX */
00244             r__1 = *qmax, r__2 = z__[(*i0 << 2) + *pp - 3], r__1 = max(r__1,
00245                     r__2), r__2 = z__[(*i0 << 2) + *pp + 1];
00246             *qmax = dmax(r__1,r__2);
00247             *dmin__ = -0.f;
00248         }
00249     }
00250 
00251 /*     Choose a shift. */
00252 
00253     slasq4_(i0, n0, &z__[1], pp, &n0in, dmin__, dmin1, dmin2, dn, dn1, dn2, 
00254             tau, ttype, g);
00255 
00256 /*     Call dqds until DMIN > 0. */
00257 
00258 L70:
00259 
00260     slasq5_(i0, n0, &z__[1], pp, tau, dmin__, dmin1, dmin2, dn, dn1, dn2, 
00261             ieee);
00262 
00263     *ndiv += *n0 - *i0 + 2;
00264     ++(*iter);
00265 
00266 /*     Check status. */
00267 
00268     if (*dmin__ >= 0.f && *dmin1 > 0.f) {
00269 
00270 /*        Success. */
00271 
00272         goto L90;
00273 
00274     } else if (*dmin__ < 0.f && *dmin1 > 0.f && z__[(*n0 - 1 << 2) - *pp] < 
00275             tol * (*sigma + *dn1) && dabs(*dn) < tol * *sigma) {
00276 
00277 /*        Convergence hidden by negative DN. */
00278 
00279         z__[(*n0 - 1 << 2) - *pp + 2] = 0.f;
00280         *dmin__ = 0.f;
00281         goto L90;
00282     } else if (*dmin__ < 0.f) {
00283 
00284 /*        TAU too big. Select new TAU and try again. */
00285 
00286         ++(*nfail);
00287         if (*ttype < -22) {
00288 
00289 /*           Failed twice. Play it safe. */
00290 
00291             *tau = 0.f;
00292         } else if (*dmin1 > 0.f) {
00293 
00294 /*           Late failure. Gives excellent shift. */
00295 
00296             *tau = (*tau + *dmin__) * (1.f - eps * 2.f);
00297             *ttype += -11;
00298         } else {
00299 
00300 /*           Early failure. Divide by 4. */
00301 
00302             *tau *= .25f;
00303             *ttype += -12;
00304         }
00305         goto L70;
00306     } else if (sisnan_(dmin__)) {
00307 
00308 /*        NaN. */
00309 
00310         if (*tau == 0.f) {
00311             goto L80;
00312         } else {
00313             *tau = 0.f;
00314             goto L70;
00315         }
00316     } else {
00317 
00318 /*        Possible underflow. Play it safe. */
00319 
00320         goto L80;
00321     }
00322 
00323 /*     Risk of underflow. */
00324 
00325 L80:
00326     slasq6_(i0, n0, &z__[1], pp, dmin__, dmin1, dmin2, dn, dn1, dn2);
00327     *ndiv += *n0 - *i0 + 2;
00328     ++(*iter);
00329     *tau = 0.f;
00330 
00331 L90:
00332     if (*tau < *sigma) {
00333         *desig += *tau;
00334         t = *sigma + *desig;
00335         *desig -= t - *sigma;
00336     } else {
00337         t = *sigma + *tau;
00338         *desig = *sigma - (t - *tau) + *desig;
00339     }
00340     *sigma = t;
00341 
00342     return 0;
00343 
00344 /*     End of SLASQ3 */
00345 
00346 } /* slasq3_ */


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