00001 /* spbequ.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 /* Subroutine */ int spbequ_(char *uplo, integer *n, integer *kd, real *ab, 00017 integer *ldab, real *s, real *scond, real *amax, integer *info) 00018 { 00019 /* System generated locals */ 00020 integer ab_dim1, ab_offset, i__1; 00021 real r__1, r__2; 00022 00023 /* Builtin functions */ 00024 double sqrt(doublereal); 00025 00026 /* Local variables */ 00027 integer i__, j; 00028 real smin; 00029 extern logical lsame_(char *, char *); 00030 logical upper; 00031 extern /* Subroutine */ int xerbla_(char *, integer *); 00032 00033 00034 /* -- LAPACK routine (version 3.2) -- */ 00035 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00036 /* November 2006 */ 00037 00038 /* .. Scalar Arguments .. */ 00039 /* .. */ 00040 /* .. Array Arguments .. */ 00041 /* .. */ 00042 00043 /* Purpose */ 00044 /* ======= */ 00045 00046 /* SPBEQU computes row and column scalings intended to equilibrate a */ 00047 /* symmetric positive definite band matrix A and reduce its condition */ 00048 /* number (with respect to the two-norm). S contains the scale factors, */ 00049 /* S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with */ 00050 /* elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal. This */ 00051 /* choice of S puts the condition number of B within a factor N of the */ 00052 /* smallest possible condition number over all possible diagonal */ 00053 /* scalings. */ 00054 00055 /* Arguments */ 00056 /* ========= */ 00057 00058 /* UPLO (input) CHARACTER*1 */ 00059 /* = 'U': Upper triangular of A is stored; */ 00060 /* = 'L': Lower triangular of A is stored. */ 00061 00062 /* N (input) INTEGER */ 00063 /* The order of the matrix A. N >= 0. */ 00064 00065 /* KD (input) INTEGER */ 00066 /* The number of superdiagonals of the matrix A if UPLO = 'U', */ 00067 /* or the number of subdiagonals if UPLO = 'L'. KD >= 0. */ 00068 00069 /* AB (input) REAL array, dimension (LDAB,N) */ 00070 /* The upper or lower triangle of the symmetric band matrix A, */ 00071 /* stored in the first KD+1 rows of the array. The j-th column */ 00072 /* of A is stored in the j-th column of the array AB as follows: */ 00073 /* if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */ 00074 /* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). */ 00075 00076 /* LDAB (input) INTEGER */ 00077 /* The leading dimension of the array A. LDAB >= KD+1. */ 00078 00079 /* S (output) REAL array, dimension (N) */ 00080 /* If INFO = 0, S contains the scale factors for A. */ 00081 00082 /* SCOND (output) REAL */ 00083 /* If INFO = 0, S contains the ratio of the smallest S(i) to */ 00084 /* the largest S(i). If SCOND >= 0.1 and AMAX is neither too */ 00085 /* large nor too small, it is not worth scaling by S. */ 00086 00087 /* AMAX (output) REAL */ 00088 /* Absolute value of largest matrix element. If AMAX is very */ 00089 /* close to overflow or very close to underflow, the matrix */ 00090 /* should be scaled. */ 00091 00092 /* INFO (output) INTEGER */ 00093 /* = 0: successful exit */ 00094 /* < 0: if INFO = -i, the i-th argument had an illegal value. */ 00095 /* > 0: if INFO = i, the i-th diagonal element is nonpositive. */ 00096 00097 /* ===================================================================== */ 00098 00099 /* .. Parameters .. */ 00100 /* .. */ 00101 /* .. Local Scalars .. */ 00102 /* .. */ 00103 /* .. External Functions .. */ 00104 /* .. */ 00105 /* .. External Subroutines .. */ 00106 /* .. */ 00107 /* .. Intrinsic Functions .. */ 00108 /* .. */ 00109 /* .. Executable Statements .. */ 00110 00111 /* Test the input parameters. */ 00112 00113 /* Parameter adjustments */ 00114 ab_dim1 = *ldab; 00115 ab_offset = 1 + ab_dim1; 00116 ab -= ab_offset; 00117 --s; 00118 00119 /* Function Body */ 00120 *info = 0; 00121 upper = lsame_(uplo, "U"); 00122 if (! upper && ! lsame_(uplo, "L")) { 00123 *info = -1; 00124 } else if (*n < 0) { 00125 *info = -2; 00126 } else if (*kd < 0) { 00127 *info = -3; 00128 } else if (*ldab < *kd + 1) { 00129 *info = -5; 00130 } 00131 if (*info != 0) { 00132 i__1 = -(*info); 00133 xerbla_("SPBEQU", &i__1); 00134 return 0; 00135 } 00136 00137 /* Quick return if possible */ 00138 00139 if (*n == 0) { 00140 *scond = 1.f; 00141 *amax = 0.f; 00142 return 0; 00143 } 00144 00145 if (upper) { 00146 j = *kd + 1; 00147 } else { 00148 j = 1; 00149 } 00150 00151 /* Initialize SMIN and AMAX. */ 00152 00153 s[1] = ab[j + ab_dim1]; 00154 smin = s[1]; 00155 *amax = s[1]; 00156 00157 /* Find the minimum and maximum diagonal elements. */ 00158 00159 i__1 = *n; 00160 for (i__ = 2; i__ <= i__1; ++i__) { 00161 s[i__] = ab[j + i__ * ab_dim1]; 00162 /* Computing MIN */ 00163 r__1 = smin, r__2 = s[i__]; 00164 smin = dmin(r__1,r__2); 00165 /* Computing MAX */ 00166 r__1 = *amax, r__2 = s[i__]; 00167 *amax = dmax(r__1,r__2); 00168 /* L10: */ 00169 } 00170 00171 if (smin <= 0.f) { 00172 00173 /* Find the first non-positive diagonal element and return. */ 00174 00175 i__1 = *n; 00176 for (i__ = 1; i__ <= i__1; ++i__) { 00177 if (s[i__] <= 0.f) { 00178 *info = i__; 00179 return 0; 00180 } 00181 /* L20: */ 00182 } 00183 } else { 00184 00185 /* Set the scale factors to the reciprocals */ 00186 /* of the diagonal elements. */ 00187 00188 i__1 = *n; 00189 for (i__ = 1; i__ <= i__1; ++i__) { 00190 s[i__] = 1.f / sqrt(s[i__]); 00191 /* L30: */ 00192 } 00193 00194 /* Compute SCOND = min(S(I)) / max(S(I)) */ 00195 00196 *scond = sqrt(smin) / sqrt(*amax); 00197 } 00198 return 0; 00199 00200 /* End of SPBEQU */ 00201 00202 } /* spbequ_ */