zpbequ.c
Go to the documentation of this file.
00001 /* zpbequ.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 zpbequ_(char *uplo, integer *n, integer *kd, 
00017         doublecomplex *ab, integer *ldab, doublereal *s, doublereal *scond, 
00018         doublereal *amax, integer *info)
00019 {
00020     /* System generated locals */
00021     integer ab_dim1, ab_offset, i__1, i__2;
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 /*  ZPBEQU computes row and column scalings intended to equilibrate a */
00048 /*  Hermitian 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) COMPLEX*16 array, dimension (LDAB,N) */
00071 /*          The upper or lower triangle of the Hermitian 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_("ZPBEQU", &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     i__1 = j + ab_dim1;
00155     s[1] = ab[i__1].r;
00156     smin = s[1];
00157     *amax = s[1];
00158 
00159 /*     Find the minimum and maximum diagonal elements. */
00160 
00161     i__1 = *n;
00162     for (i__ = 2; i__ <= i__1; ++i__) {
00163         i__2 = j + i__ * ab_dim1;
00164         s[i__] = ab[i__2].r;
00165 /* Computing MIN */
00166         d__1 = smin, d__2 = s[i__];
00167         smin = min(d__1,d__2);
00168 /* Computing MAX */
00169         d__1 = *amax, d__2 = s[i__];
00170         *amax = max(d__1,d__2);
00171 /* L10: */
00172     }
00173 
00174     if (smin <= 0.) {
00175 
00176 /*        Find the first non-positive diagonal element and return. */
00177 
00178         i__1 = *n;
00179         for (i__ = 1; i__ <= i__1; ++i__) {
00180             if (s[i__] <= 0.) {
00181                 *info = i__;
00182                 return 0;
00183             }
00184 /* L20: */
00185         }
00186     } else {
00187 
00188 /*        Set the scale factors to the reciprocals */
00189 /*        of the diagonal elements. */
00190 
00191         i__1 = *n;
00192         for (i__ = 1; i__ <= i__1; ++i__) {
00193             s[i__] = 1. / sqrt(s[i__]);
00194 /* L30: */
00195         }
00196 
00197 /*        Compute SCOND = min(S(I)) / max(S(I)) */
00198 
00199         *scond = sqrt(smin) / sqrt(*amax);
00200     }
00201     return 0;
00202 
00203 /*     End of ZPBEQU */
00204 
00205 } /* zpbequ_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:42