zla_porpvgrw.c
Go to the documentation of this file.
00001 /* zla_porpvgrw.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 zla_porpvgrw__(char *uplo, integer *ncols, doublecomplex *a, 
00017         integer *lda, doublecomplex *af, integer *ldaf, doublereal *work, 
00018         ftnlen uplo_len)
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, af_dim1, af_offset, i__1, i__2, i__3;
00022     doublereal ret_val, d__1, d__2, d__3, d__4;
00023 
00024     /* Builtin functions */
00025     double d_imag(doublecomplex *);
00026 
00027     /* Local variables */
00028     integer i__, j;
00029     doublereal amax, umax;
00030     extern logical lsame_(char *, char *);
00031     logical upper;
00032     doublereal rpvgrw;
00033 
00034 
00035 /*     -- LAPACK routine (version 3.2.1)                                 -- */
00036 /*     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
00037 /*     -- Jason Riedy of Univ. of California Berkeley.                 -- */
00038 /*     -- April 2009                                                   -- */
00039 
00040 /*     -- LAPACK is a software package provided by Univ. of Tennessee, -- */
00041 /*     -- Univ. of California Berkeley and NAG Ltd.                    -- */
00042 
00043 /*     .. */
00044 /*     .. Scalar Arguments .. */
00045 /*     .. */
00046 /*     .. Array Arguments .. */
00047 /*     .. */
00048 
00049 /*  Purpose */
00050 /*  ======= */
00051 
00052 /*  ZLA_PORPVGRW computes the reciprocal pivot growth factor */
00053 /*  norm(A)/norm(U). The "max absolute element" norm is used. If this is */
00054 /*  much less than 1, the stability of the LU factorization of the */
00055 /*  (equilibrated) matrix A could be poor. This also means that the */
00056 /*  solution X, estimated condition numbers, and error bounds could be */
00057 /*  unreliable. */
00058 
00059 /*  Arguments */
00060 /*  ========= */
00061 
00062 /*     UPLO    (input) CHARACTER*1 */
00063 /*       = 'U':  Upper triangle of A is stored; */
00064 /*       = 'L':  Lower triangle of A is stored. */
00065 
00066 /*     NCOLS   (input) INTEGER */
00067 /*     The number of columns of the matrix A. NCOLS >= 0. */
00068 
00069 /*     A       (input) COMPLEX*16 array, dimension (LDA,N) */
00070 /*     On entry, the N-by-N matrix A. */
00071 
00072 /*     LDA     (input) INTEGER */
00073 /*     The leading dimension of the array A.  LDA >= max(1,N). */
00074 
00075 /*     AF      (input) COMPLEX*16 array, dimension (LDAF,N) */
00076 /*     The triangular factor U or L from the Cholesky factorization */
00077 /*     A = U**T*U or A = L*L**T, as computed by ZPOTRF. */
00078 
00079 /*     LDAF    (input) INTEGER */
00080 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00081 
00082 /*     WORK    (input) COMPLEX*16 array, dimension (2*N) */
00083 
00084 /*  ===================================================================== */
00085 
00086 /*     .. Local Scalars .. */
00087 /*     .. */
00088 /*     .. External Functions .. */
00089 /*     .. */
00090 /*     .. Intrinsic Functions .. */
00091 /*     .. */
00092 /*     .. Statement Functions .. */
00093 /*     .. */
00094 /*     .. Statement Function Definitions .. */
00095 /*     .. */
00096 /*     .. Executable Statements .. */
00097     /* Parameter adjustments */
00098     a_dim1 = *lda;
00099     a_offset = 1 + a_dim1;
00100     a -= a_offset;
00101     af_dim1 = *ldaf;
00102     af_offset = 1 + af_dim1;
00103     af -= af_offset;
00104     --work;
00105 
00106     /* Function Body */
00107     upper = lsame_("Upper", uplo);
00108 
00109 /*     DPOTRF will have factored only the NCOLSxNCOLS leading minor, so */
00110 /*     we restrict the growth search to that minor and use only the first */
00111 /*     2*NCOLS workspace entries. */
00112 
00113     rpvgrw = 1.;
00114     i__1 = *ncols << 1;
00115     for (i__ = 1; i__ <= i__1; ++i__) {
00116         work[i__] = 0.;
00117     }
00118 
00119 /*     Find the max magnitude entry of each column. */
00120 
00121     if (upper) {
00122         i__1 = *ncols;
00123         for (j = 1; j <= i__1; ++j) {
00124             i__2 = j;
00125             for (i__ = 1; i__ <= i__2; ++i__) {
00126 /* Computing MAX */
00127                 i__3 = i__ + j * a_dim1;
00128                 d__3 = (d__1 = a[i__3].r, abs(d__1)) + (d__2 = d_imag(&a[i__ 
00129                         + j * a_dim1]), abs(d__2)), d__4 = work[*ncols + j];
00130                 work[*ncols + j] = max(d__3,d__4);
00131             }
00132         }
00133     } else {
00134         i__1 = *ncols;
00135         for (j = 1; j <= i__1; ++j) {
00136             i__2 = *ncols;
00137             for (i__ = j; i__ <= i__2; ++i__) {
00138 /* Computing MAX */
00139                 i__3 = i__ + j * a_dim1;
00140                 d__3 = (d__1 = a[i__3].r, abs(d__1)) + (d__2 = d_imag(&a[i__ 
00141                         + j * a_dim1]), abs(d__2)), d__4 = work[*ncols + j];
00142                 work[*ncols + j] = max(d__3,d__4);
00143             }
00144         }
00145     }
00146 
00147 /*     Now find the max magnitude entry of each column of the factor in */
00148 /*     AF.  No pivoting, so no permutations. */
00149 
00150     if (lsame_("Upper", uplo)) {
00151         i__1 = *ncols;
00152         for (j = 1; j <= i__1; ++j) {
00153             i__2 = j;
00154             for (i__ = 1; i__ <= i__2; ++i__) {
00155 /* Computing MAX */
00156                 i__3 = i__ + j * af_dim1;
00157                 d__3 = (d__1 = af[i__3].r, abs(d__1)) + (d__2 = d_imag(&af[
00158                         i__ + j * af_dim1]), abs(d__2)), d__4 = work[j];
00159                 work[j] = max(d__3,d__4);
00160             }
00161         }
00162     } else {
00163         i__1 = *ncols;
00164         for (j = 1; j <= i__1; ++j) {
00165             i__2 = *ncols;
00166             for (i__ = j; i__ <= i__2; ++i__) {
00167 /* Computing MAX */
00168                 i__3 = i__ + j * af_dim1;
00169                 d__3 = (d__1 = af[i__3].r, abs(d__1)) + (d__2 = d_imag(&af[
00170                         i__ + j * af_dim1]), abs(d__2)), d__4 = work[j];
00171                 work[j] = max(d__3,d__4);
00172             }
00173         }
00174     }
00175 
00176 /*     Compute the *inverse* of the max element growth factor.  Dividing */
00177 /*     by zero would imply the largest entry of the factor's column is */
00178 /*     zero.  Than can happen when either the column of A is zero or */
00179 /*     massive pivots made the factor underflow to zero.  Neither counts */
00180 /*     as growth in itself, so simply ignore terms with zero */
00181 /*     denominators. */
00182 
00183     if (lsame_("Upper", uplo)) {
00184         i__1 = *ncols;
00185         for (i__ = 1; i__ <= i__1; ++i__) {
00186             umax = work[i__];
00187             amax = work[*ncols + i__];
00188             if (umax != 0.) {
00189 /* Computing MIN */
00190                 d__1 = amax / umax;
00191                 rpvgrw = min(d__1,rpvgrw);
00192             }
00193         }
00194     } else {
00195         i__1 = *ncols;
00196         for (i__ = 1; i__ <= i__1; ++i__) {
00197             umax = work[i__];
00198             amax = work[*ncols + i__];
00199             if (umax != 0.) {
00200 /* Computing MIN */
00201                 d__1 = amax / umax;
00202                 rpvgrw = min(d__1,rpvgrw);
00203             }
00204         }
00205     }
00206     ret_val = rpvgrw;
00207     return ret_val;
00208 } /* zla_porpvgrw__ */


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