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


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