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