cpbequ.c
Go to the documentation of this file.
00001 /* cpbequ.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 cpbequ_(char *uplo, integer *n, integer *kd, complex *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, i__2;
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 /*  CPBEQU computes row and column scalings intended to equilibrate a */
00047 /*  Hermitian 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) COMPLEX array, dimension (LDAB,N) */
00070 /*          The upper or lower triangle of the Hermitian 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_("CPBEQU", &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     i__1 = j + ab_dim1;
00154     s[1] = ab[i__1].r;
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         i__2 = j + i__ * ab_dim1;
00163         s[i__] = ab[i__2].r;
00164 /* Computing MIN */
00165         r__1 = smin, r__2 = s[i__];
00166         smin = dmin(r__1,r__2);
00167 /* Computing MAX */
00168         r__1 = *amax, r__2 = s[i__];
00169         *amax = dmax(r__1,r__2);
00170 /* L10: */
00171     }
00172 
00173     if (smin <= 0.f) {
00174 
00175 /*        Find the first non-positive diagonal element and return. */
00176 
00177         i__1 = *n;
00178         for (i__ = 1; i__ <= i__1; ++i__) {
00179             if (s[i__] <= 0.f) {
00180                 *info = i__;
00181                 return 0;
00182             }
00183 /* L20: */
00184         }
00185     } else {
00186 
00187 /*        Set the scale factors to the reciprocals */
00188 /*        of the diagonal elements. */
00189 
00190         i__1 = *n;
00191         for (i__ = 1; i__ <= i__1; ++i__) {
00192             s[i__] = 1.f / sqrt(s[i__]);
00193 /* L30: */
00194         }
00195 
00196 /*        Compute SCOND = min(S(I)) / max(S(I)) */
00197 
00198         *scond = sqrt(smin) / sqrt(*amax);
00199     }
00200     return 0;
00201 
00202 /*     End of CPBEQU */
00203 
00204 } /* cpbequ_ */


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