Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

dlacon.c

Go to the documentation of this file.
00001 /* DLACON.F -- translated by f2c (version 19941215).
00002    You must link the resulting object file with the libraries:
00003         -lf2c -lm   (in that order)
00004 */
00005 
00006 #include "f2c.h"
00007 
00008 /* Table of constant values */
00009 
00010 static integer c__1 = 1;
00011 static doublereal c_b11 = 1.;
00012 
00013 /* Subroutine */ int dlacon_(n, v, x, isgn, est, kase)
00014 integer *n;
00015 doublereal *v, *x;
00016 integer *isgn;
00017 doublereal *est;
00018 integer *kase;
00019 {
00020     /* System generated locals */
00021     integer i__1;
00022     doublereal d__1;
00023 
00024     /* Builtin functions */
00025     double d_sign();
00026     integer i_dnnt();
00027 
00028     /* Local variables */
00029     static integer iter;
00030     static doublereal temp;
00031     static integer jump, i, j;
00032     extern doublereal dasum_();
00033     static integer jlast;
00034     extern /* Subroutine */ int dcopy_();
00035     extern integer idamax_();
00036     static doublereal altsgn, estold;
00037 
00038 
00039 /*  -- LAPACK auxiliary routine (version 1.1) -- */
00040 /*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
00041 /*     Courant Institute, Argonne National Lab, and Rice University */
00042 /*     February 29, 1992 */
00043 
00044 /*     .. Scalar Arguments .. */
00045 /*     .. */
00046 /*     .. Array Arguments .. */
00047 /*     .. */
00048 
00049 /*  Purpose */
00050 /*  ======= */
00051 
00052 /*  DLACON estimates the 1-norm of a square, real matrix A. */
00053 /*  Reverse communication is used for evaluating matrix-vector products. 
00054 */
00055 
00056 /*  Arguments */
00057 /*  ========= */
00058 
00059 /*  N      (input) INTEGER */
00060 /*         The order of the matrix.  N >= 1. */
00061 
00062 /*  V      (workspace) DOUBLE PRECISION array, dimension (N) */
00063 /*         On the final return, V = A*W,  where  EST = norm(V)/norm(W) */
00064 /*         (W is not returned). */
00065 
00066 /*  X      (input/output) DOUBLE PRECISION array, dimension (N) */
00067 /*         On an intermediate return, X should be overwritten by */
00068 /*               A * X,   if KASE=1, */
00069 /*               A' * X,  if KASE=2, */
00070 /*         and DLACON must be re-called with all the other parameters */
00071 /*         unchanged. */
00072 
00073 /*  ISGN   (workspace) INTEGER array, dimension (N) */
00074 
00075 /*  EST    (output) DOUBLE PRECISION */
00076 /*         An estimate (a lower bound) for norm(A). */
00077 
00078 /*  KASE   (input/output) INTEGER */
00079 /*         On the initial call to DLACON, KASE should be 0. */
00080 /*         On an intermediate return, KASE will be 1 or 2, indicating */
00081 /*         whether X should be overwritten by A * X  or A' * X. */
00082 /*         On the final return from DLACON, KASE will again be 0. */
00083 
00084 /*  Further Details */
00085 /*  ======= ======= */
00086 
00087 /*  Contributed by Nick Higham, University of Manchester. */
00088 /*  Originally named SONEST, dated March 16, 1988. */
00089 
00090 /*  Reference: N.J. Higham, "FORTRAN codes for estimating the one-norm of 
00091 */
00092 /*  a real or complex matrix, with applications to condition estimation", 
00093 */
00094 /*  ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988. */
00095 
00096 /*  ===================================================================== 
00097 */
00098 
00099 /*     .. Parameters .. */
00100 /*     .. */
00101 /*     .. Local Scalars .. */
00102 /*     .. */
00103 /*     .. External Functions .. */
00104 /*     .. */
00105 /*     .. External Subroutines .. */
00106 /*     .. */
00107 /*     .. Intrinsic Functions .. */
00108 /*     .. */
00109 /*     .. Save statement .. */
00110 /*     .. */
00111 /*     .. Executable Statements .. */
00112 
00113     /* Parameter adjustments */
00114     --isgn;
00115     --x;
00116     --v;
00117 
00118     /* Function Body */
00119     if (*kase == 0) {
00120         i__1 = *n;
00121         for (i = 1; i <= i__1; ++i) {
00122             x[i] = 1. / (doublereal) (*n);
00123 /* L10: */
00124         }
00125         *kase = 1;
00126         jump = 1;
00127         return 0;
00128     }
00129 
00130     switch ((int)jump) {
00131         case 1:  goto L20;
00132         case 2:  goto L40;
00133         case 3:  goto L70;
00134         case 4:  goto L110;
00135         case 5:  goto L140;
00136     }
00137 
00138 /*     ................ ENTRY   (JUMP = 1) */
00139 /*     FIRST ITERATION.  X HAS BEEN OVERWRITTEN BY A*X. */
00140 
00141 L20:
00142     if (*n == 1) {
00143         v[1] = x[1];
00144         *est = abs(v[1]);
00145 /*        ... QUIT */
00146         goto L150;
00147     }
00148     *est = dasum_(n, &x[1], &c__1);
00149 
00150     i__1 = *n;
00151     for (i = 1; i <= i__1; ++i) {
00152         x[i] = d_sign(&c_b11, &x[i]);
00153         isgn[i] = i_dnnt(&x[i]);
00154 /* L30: */
00155     }
00156     *kase = 2;
00157     jump = 2;
00158     return 0;
00159 
00160 /*     ................ ENTRY   (JUMP = 2) */
00161 /*     FIRST ITERATION.  X HAS BEEN OVERWRITTEN BY TRANDPOSE(A)*X. */
00162 
00163 L40:
00164     j = idamax_(n, &x[1], &c__1);
00165     iter = 2;
00166 
00167 /*     MAIN LOOP - ITERATIONS 2,3,...,ITMAX. */
00168 
00169 L50:
00170     i__1 = *n;
00171     for (i = 1; i <= i__1; ++i) {
00172         x[i] = 0.;
00173 /* L60: */
00174     }
00175     x[j] = 1.;
00176     *kase = 1;
00177     jump = 3;
00178     return 0;
00179 
00180 /*     ................ ENTRY   (JUMP = 3) */
00181 /*     X HAS BEEN OVERWRITTEN BY A*X. */
00182 
00183 L70:
00184     dcopy_(n, &x[1], &c__1, &v[1], &c__1);
00185     estold = *est;
00186     *est = dasum_(n, &v[1], &c__1);
00187     i__1 = *n;
00188     for (i = 1; i <= i__1; ++i) {
00189         d__1 = d_sign(&c_b11, &x[i]);
00190         if (i_dnnt(&d__1) != isgn[i]) {
00191             goto L90;
00192         }
00193 /* L80: */
00194     }
00195 /*     REPEATED SIGN VECTOR DETECTED, HENCE ALGORITHM HAS CONVERGED. */
00196     goto L120;
00197 
00198 L90:
00199 /*     TEST FOR CYCLING. */
00200     if (*est <= estold) {
00201         goto L120;
00202     }
00203 
00204     i__1 = *n;
00205     for (i = 1; i <= i__1; ++i) {
00206         x[i] = d_sign(&c_b11, &x[i]);
00207         isgn[i] = i_dnnt(&x[i]);
00208 /* L100: */
00209     }
00210     *kase = 2;
00211     jump = 4;
00212     return 0;
00213 
00214 /*     ................ ENTRY   (JUMP = 4) */
00215 /*     X HAS BEEN OVERWRITTEN BY TRANDPOSE(A)*X. */
00216 
00217 L110:
00218     jlast = j;
00219     j = idamax_(n, &x[1], &c__1);
00220     if (x[jlast] != (d__1 = x[j], abs(d__1)) && iter < 5) {
00221         ++iter;
00222         goto L50;
00223     }
00224 
00225 /*     ITERATION COMPLETE.  FINAL STAGE. */
00226 
00227 L120:
00228     altsgn = 1.;
00229     i__1 = *n;
00230     for (i = 1; i <= i__1; ++i) {
00231         x[i] = altsgn * ((doublereal) (i - 1) / (doublereal) (*n - 1) + 1.);
00232         altsgn = -altsgn;
00233 /* L130: */
00234     }
00235     *kase = 1;
00236     jump = 5;
00237     return 0;
00238 
00239 /*     ................ ENTRY   (JUMP = 5) */
00240 /*     X HAS BEEN OVERWRITTEN BY A*X. */
00241 
00242 L140:
00243     temp = dasum_(n, &x[1], &c__1) / (doublereal) (*n * 3) * 2.;
00244     if (temp > *est) {
00245         dcopy_(n, &x[1], &c__1, &v[1], &c__1);
00246         *est = temp;
00247     }
00248 
00249 L150:
00250     *kase = 0;
00251     return 0;
00252 
00253 /*     End of DLACON */
00254 
00255 } /* dlacon_ */
00256 

Generated on Wed Sep 5 12:54:19 2007 for DSACSS Operational Code by  doxygen 1.3.9.1