dla_syrpvgrw.c
Go to the documentation of this file.
00001 /* dla_syrpvgrw.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 doublereal dla_syrpvgrw__(char *uplo, integer *n, integer *info, doublereal *
00017         a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, 
00018         doublereal *work, ftnlen uplo_len)
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, af_dim1, af_offset, i__1, i__2;
00022     doublereal ret_val, d__1, d__2, d__3;
00023 
00024     /* Local variables */
00025     integer i__, j, k, kp;
00026     doublereal tmp, amax, umax;
00027     extern logical lsame_(char *, char *);
00028     integer ncols;
00029     logical upper;
00030     doublereal rpvgrw;
00031 
00032 
00033 /*     -- LAPACK routine (version 3.2.1)                                 -- */
00034 /*     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
00035 /*     -- Jason Riedy of Univ. of California Berkeley.                 -- */
00036 /*     -- April 2009                                                   -- */
00037 
00038 /*     -- LAPACK is a software package provided by Univ. of Tennessee, -- */
00039 /*     -- Univ. of California Berkeley and NAG Ltd.                    -- */
00040 
00041 /*     .. */
00042 /*     .. Scalar Arguments .. */
00043 /*     .. */
00044 /*     .. Array Arguments .. */
00045 /*     .. */
00046 
00047 /*  Purpose */
00048 /*  ======= */
00049 
00050 /*  DLA_SYRPVGRW computes the reciprocal pivot growth factor */
00051 /*  norm(A)/norm(U). The "max absolute element" norm is used. If this is */
00052 /*  much less than 1, the stability of the LU factorization of the */
00053 /*  (equilibrated) matrix A could be poor. This also means that the */
00054 /*  solution X, estimated condition numbers, and error bounds could be */
00055 /*  unreliable. */
00056 
00057 /*  Arguments */
00058 /*  ========= */
00059 
00060 /*     UPLO    (input) CHARACTER*1 */
00061 /*       = 'U':  Upper triangle of A is stored; */
00062 /*       = 'L':  Lower triangle of A is stored. */
00063 
00064 /*     N       (input) INTEGER */
00065 /*     The number of linear equations, i.e., the order of the */
00066 /*     matrix A.  N >= 0. */
00067 
00068 /*     INFO    (input) INTEGER */
00069 /*     The value of INFO returned from DSYTRF, .i.e., the pivot in */
00070 /*     column INFO is exactly 0. */
00071 
00072 /*     NCOLS   (input) INTEGER */
00073 /*     The number of columns of the matrix A. NCOLS >= 0. */
00074 
00075 /*     A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00076 /*     On entry, the N-by-N matrix A. */
00077 
00078 /*     LDA     (input) INTEGER */
00079 /*     The leading dimension of the array A.  LDA >= max(1,N). */
00080 
00081 /*     AF      (input) DOUBLE PRECISION array, dimension (LDAF,N) */
00082 /*     The block diagonal matrix D and the multipliers used to */
00083 /*     obtain the factor U or L as computed by DSYTRF. */
00084 
00085 /*     LDAF    (input) INTEGER */
00086 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00087 
00088 /*     IPIV    (input) INTEGER array, dimension (N) */
00089 /*     Details of the interchanges and the block structure of D */
00090 /*     as determined by DSYTRF. */
00091 
00092 /*     WORK    (input) DOUBLE PRECISION array, dimension (2*N) */
00093 
00094 /*  ===================================================================== */
00095 
00096 /*     .. Local Scalars .. */
00097 /*     .. */
00098 /*     .. Intrinsic Functions .. */
00099 /*     .. */
00100 /*     .. External Functions .. */
00101 /*     .. */
00102 /*     .. Executable Statements .. */
00103 
00104     /* Parameter adjustments */
00105     a_dim1 = *lda;
00106     a_offset = 1 + a_dim1;
00107     a -= a_offset;
00108     af_dim1 = *ldaf;
00109     af_offset = 1 + af_dim1;
00110     af -= af_offset;
00111     --ipiv;
00112     --work;
00113 
00114     /* Function Body */
00115     upper = lsame_("Upper", uplo);
00116     if (*info == 0) {
00117         if (upper) {
00118             ncols = 1;
00119         } else {
00120             ncols = *n;
00121         }
00122     } else {
00123         ncols = *info;
00124     }
00125     rpvgrw = 1.;
00126     i__1 = *n << 1;
00127     for (i__ = 1; i__ <= i__1; ++i__) {
00128         work[i__] = 0.;
00129     }
00130 
00131 /*     Find the max magnitude entry of each column of A.  Compute the max */
00132 /*     for all N columns so we can apply the pivot permutation while */
00133 /*     looping below.  Assume a full factorization is the common case. */
00134 
00135     if (upper) {
00136         i__1 = *n;
00137         for (j = 1; j <= i__1; ++j) {
00138             i__2 = j;
00139             for (i__ = 1; i__ <= i__2; ++i__) {
00140 /* Computing MAX */
00141                 d__2 = (d__1 = a[i__ + j * a_dim1], abs(d__1)), d__3 = work[*
00142                         n + i__];
00143                 work[*n + i__] = max(d__2,d__3);
00144 /* Computing MAX */
00145                 d__2 = (d__1 = a[i__ + j * a_dim1], abs(d__1)), d__3 = work[*
00146                         n + j];
00147                 work[*n + j] = max(d__2,d__3);
00148             }
00149         }
00150     } else {
00151         i__1 = *n;
00152         for (j = 1; j <= i__1; ++j) {
00153             i__2 = *n;
00154             for (i__ = j; i__ <= i__2; ++i__) {
00155 /* Computing MAX */
00156                 d__2 = (d__1 = a[i__ + j * a_dim1], abs(d__1)), d__3 = work[*
00157                         n + i__];
00158                 work[*n + i__] = max(d__2,d__3);
00159 /* Computing MAX */
00160                 d__2 = (d__1 = a[i__ + j * a_dim1], abs(d__1)), d__3 = work[*
00161                         n + j];
00162                 work[*n + j] = max(d__2,d__3);
00163             }
00164         }
00165     }
00166 
00167 /*     Now find the max magnitude entry of each column of U or L.  Also */
00168 /*     permute the magnitudes of A above so they're in the same order as */
00169 /*     the factor. */
00170 
00171 /*     The iteration orders and permutations were copied from dsytrs. */
00172 /*     Calls to SSWAP would be severe overkill. */
00173 
00174     if (upper) {
00175         k = *n;
00176         while(k < ncols && k > 0) {
00177             if (ipiv[k] > 0) {
00178 /*              1x1 pivot */
00179                 kp = ipiv[k];
00180                 if (kp != k) {
00181                     tmp = work[*n + k];
00182                     work[*n + k] = work[*n + kp];
00183                     work[*n + kp] = tmp;
00184                 }
00185                 i__1 = k;
00186                 for (i__ = 1; i__ <= i__1; ++i__) {
00187 /* Computing MAX */
00188                     d__2 = (d__1 = af[i__ + k * af_dim1], abs(d__1)), d__3 = 
00189                             work[k];
00190                     work[k] = max(d__2,d__3);
00191                 }
00192                 --k;
00193             } else {
00194 /*              2x2 pivot */
00195                 kp = -ipiv[k];
00196                 tmp = work[*n + k - 1];
00197                 work[*n + k - 1] = work[*n + kp];
00198                 work[*n + kp] = tmp;
00199                 i__1 = k - 1;
00200                 for (i__ = 1; i__ <= i__1; ++i__) {
00201 /* Computing MAX */
00202                     d__2 = (d__1 = af[i__ + k * af_dim1], abs(d__1)), d__3 = 
00203                             work[k];
00204                     work[k] = max(d__2,d__3);
00205 /* Computing MAX */
00206                     d__2 = (d__1 = af[i__ + (k - 1) * af_dim1], abs(d__1)), 
00207                             d__3 = work[k - 1];
00208                     work[k - 1] = max(d__2,d__3);
00209                 }
00210 /* Computing MAX */
00211                 d__2 = (d__1 = af[k + k * af_dim1], abs(d__1)), d__3 = work[k]
00212                         ;
00213                 work[k] = max(d__2,d__3);
00214                 k += -2;
00215             }
00216         }
00217         k = ncols;
00218         while(k <= *n) {
00219             if (ipiv[k] > 0) {
00220                 kp = ipiv[k];
00221                 if (kp != k) {
00222                     tmp = work[*n + k];
00223                     work[*n + k] = work[*n + kp];
00224                     work[*n + kp] = tmp;
00225                 }
00226                 ++k;
00227             } else {
00228                 kp = -ipiv[k];
00229                 tmp = work[*n + k];
00230                 work[*n + k] = work[*n + kp];
00231                 work[*n + kp] = tmp;
00232                 k += 2;
00233             }
00234         }
00235     } else {
00236         k = 1;
00237         while(k <= ncols) {
00238             if (ipiv[k] > 0) {
00239 /*              1x1 pivot */
00240                 kp = ipiv[k];
00241                 if (kp != k) {
00242                     tmp = work[*n + k];
00243                     work[*n + k] = work[*n + kp];
00244                     work[*n + kp] = tmp;
00245                 }
00246                 i__1 = *n;
00247                 for (i__ = k; i__ <= i__1; ++i__) {
00248 /* Computing MAX */
00249                     d__2 = (d__1 = af[i__ + k * af_dim1], abs(d__1)), d__3 = 
00250                             work[k];
00251                     work[k] = max(d__2,d__3);
00252                 }
00253                 ++k;
00254             } else {
00255 /*              2x2 pivot */
00256                 kp = -ipiv[k];
00257                 tmp = work[*n + k + 1];
00258                 work[*n + k + 1] = work[*n + kp];
00259                 work[*n + kp] = tmp;
00260                 i__1 = *n;
00261                 for (i__ = k + 1; i__ <= i__1; ++i__) {
00262 /* Computing MAX */
00263                     d__2 = (d__1 = af[i__ + k * af_dim1], abs(d__1)), d__3 = 
00264                             work[k];
00265                     work[k] = max(d__2,d__3);
00266 /* Computing MAX */
00267                     d__2 = (d__1 = af[i__ + (k + 1) * af_dim1], abs(d__1)), 
00268                             d__3 = work[k + 1];
00269                     work[k + 1] = max(d__2,d__3);
00270                 }
00271 /* Computing MAX */
00272                 d__2 = (d__1 = af[k + k * af_dim1], abs(d__1)), d__3 = work[k]
00273                         ;
00274                 work[k] = max(d__2,d__3);
00275                 k += 2;
00276             }
00277         }
00278         k = ncols;
00279         while(k >= 1) {
00280             if (ipiv[k] > 0) {
00281                 kp = ipiv[k];
00282                 if (kp != k) {
00283                     tmp = work[*n + k];
00284                     work[*n + k] = work[*n + kp];
00285                     work[*n + kp] = tmp;
00286                 }
00287                 --k;
00288             } else {
00289                 kp = -ipiv[k];
00290                 tmp = work[*n + k];
00291                 work[*n + k] = work[*n + kp];
00292                 work[*n + kp] = tmp;
00293                 k += -2;
00294             }
00295         }
00296     }
00297 
00298 /*     Compute the *inverse* of the max element growth factor.  Dividing */
00299 /*     by zero would imply the largest entry of the factor's column is */
00300 /*     zero.  Than can happen when either the column of A is zero or */
00301 /*     massive pivots made the factor underflow to zero.  Neither counts */
00302 /*     as growth in itself, so simply ignore terms with zero */
00303 /*     denominators. */
00304 
00305     if (upper) {
00306         i__1 = *n;
00307         for (i__ = ncols; i__ <= i__1; ++i__) {
00308             umax = work[i__];
00309             amax = work[*n + i__];
00310             if (umax != 0.) {
00311 /* Computing MIN */
00312                 d__1 = amax / umax;
00313                 rpvgrw = min(d__1,rpvgrw);
00314             }
00315         }
00316     } else {
00317         i__1 = ncols;
00318         for (i__ = 1; i__ <= i__1; ++i__) {
00319             umax = work[i__];
00320             amax = work[*n + i__];
00321             if (umax != 0.) {
00322 /* Computing MIN */
00323                 d__1 = amax / umax;
00324                 rpvgrw = min(d__1,rpvgrw);
00325             }
00326         }
00327     }
00328     ret_val = rpvgrw;
00329     return ret_val;
00330 } /* dla_syrpvgrw__ */


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