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