dla_gbrcond.c
Go to the documentation of this file.
00001 /* dla_gbrcond.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 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 
00020 doublereal dla_gbrcond__(char *trans, integer *n, integer *kl, integer *ku, 
00021         doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, 
00022         integer *ipiv, integer *cmode, doublereal *c__, integer *info, 
00023         doublereal *work, integer *iwork, ftnlen trans_len)
00024 {
00025     /* System generated locals */
00026     integer ab_dim1, ab_offset, afb_dim1, afb_offset, i__1, i__2, i__3, i__4;
00027     doublereal ret_val, d__1;
00028 
00029     /* Local variables */
00030     integer i__, j, kd, ke;
00031     doublereal tmp;
00032     integer kase;
00033     extern logical lsame_(char *, char *);
00034     integer isave[3];
00035     extern /* Subroutine */ int dlacn2_(integer *, doublereal *, doublereal *, 
00036              integer *, doublereal *, integer *, integer *), xerbla_(char *, 
00037             integer *), dgbtrs_(char *, integer *, integer *, integer 
00038             *, integer *, doublereal *, integer *, integer *, doublereal *, 
00039             integer *, integer *);
00040     doublereal ainvnm;
00041     logical notrans;
00042 
00043 
00044 /*     -- LAPACK routine (version 3.2.1)                               -- */
00045 /*     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
00046 /*     -- Jason Riedy of Univ. of California Berkeley.                 -- */
00047 /*     -- April 2009                                                   -- */
00048 
00049 /*     -- LAPACK is a software package provided by Univ. of Tennessee, -- */
00050 /*     -- Univ. of California Berkeley and NAG Ltd.                    -- */
00051 
00052 /*     .. */
00053 /*     .. Scalar Arguments .. */
00054 /*     .. */
00055 /*     .. Array Arguments .. */
00056 /*     .. */
00057 
00058 /*  Purpose */
00059 /*  ======= */
00060 
00061 /*     DLA_GERCOND Estimates the Skeel condition number of  op(A) * op2(C) */
00062 /*     where op2 is determined by CMODE as follows */
00063 /*     CMODE =  1    op2(C) = C */
00064 /*     CMODE =  0    op2(C) = I */
00065 /*     CMODE = -1    op2(C) = inv(C) */
00066 /*     The Skeel condition number  cond(A) = norminf( |inv(A)||A| ) */
00067 /*     is computed by computing scaling factors R such that */
00068 /*     diag(R)*A*op2(C) is row equilibrated and computing the standard */
00069 /*     infinity-norm condition number. */
00070 
00071 /*  Arguments */
00072 /*  ========= */
00073 
00074 /*     TRANS   (input) CHARACTER*1 */
00075 /*     Specifies the form of the system of equations: */
00076 /*       = 'N':  A * X = B     (No transpose) */
00077 /*       = 'T':  A**T * X = B  (Transpose) */
00078 /*       = 'C':  A**H * X = B  (Conjugate Transpose = Transpose) */
00079 
00080 /*     N       (input) INTEGER */
00081 /*     The number of linear equations, i.e., the order of the */
00082 /*     matrix A.  N >= 0. */
00083 
00084 /*     KL      (input) INTEGER */
00085 /*     The number of subdiagonals within the band of A.  KL >= 0. */
00086 
00087 /*     KU      (input) INTEGER */
00088 /*     The number of superdiagonals within the band of A.  KU >= 0. */
00089 
00090 /*     AB      (input) DOUBLE PRECISION array, dimension (LDAB,N) */
00091 /*     On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */
00092 /*     The j-th column of A is stored in the j-th column of the */
00093 /*     array AB as follows: */
00094 /*     AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */
00095 
00096 /*     LDAB    (input) INTEGER */
00097 /*     The leading dimension of the array AB.  LDAB >= KL+KU+1. */
00098 
00099 /*     AFB     (input) DOUBLE PRECISION array, dimension (LDAFB,N) */
00100 /*     Details of the LU factorization of the band matrix A, as */
00101 /*     computed by DGBTRF.  U is stored as an upper triangular */
00102 /*     band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */
00103 /*     and the multipliers used during the factorization are stored */
00104 /*     in rows KL+KU+2 to 2*KL+KU+1. */
00105 
00106 /*     LDAFB   (input) INTEGER */
00107 /*     The leading dimension of the array AFB.  LDAFB >= 2*KL+KU+1. */
00108 
00109 /*     IPIV    (input) INTEGER array, dimension (N) */
00110 /*     The pivot indices from the factorization A = P*L*U */
00111 /*     as computed by DGBTRF; row i of the matrix was interchanged */
00112 /*     with row IPIV(i). */
00113 
00114 /*     CMODE   (input) INTEGER */
00115 /*     Determines op2(C) in the formula op(A) * op2(C) as follows: */
00116 /*     CMODE =  1    op2(C) = C */
00117 /*     CMODE =  0    op2(C) = I */
00118 /*     CMODE = -1    op2(C) = inv(C) */
00119 
00120 /*     C       (input) DOUBLE PRECISION array, dimension (N) */
00121 /*     The vector C in the formula op(A) * op2(C). */
00122 
00123 /*     INFO    (output) INTEGER */
00124 /*       = 0:  Successful exit. */
00125 /*     i > 0:  The ith argument is invalid. */
00126 
00127 /*     WORK    (input) DOUBLE PRECISION array, dimension (5*N). */
00128 /*     Workspace. */
00129 
00130 /*     IWORK   (input) INTEGER array, dimension (N). */
00131 /*     Workspace. */
00132 
00133 /*  ===================================================================== */
00134 
00135 /*     .. Local Scalars .. */
00136 /*     .. */
00137 /*     .. Local Arrays .. */
00138 /*     .. */
00139 /*     .. External Functions .. */
00140 /*     .. */
00141 /*     .. External Subroutines .. */
00142 /*     .. */
00143 /*     .. Intrinsic Functions .. */
00144 /*     .. */
00145 /*     .. Executable Statements .. */
00146 
00147     /* Parameter adjustments */
00148     ab_dim1 = *ldab;
00149     ab_offset = 1 + ab_dim1;
00150     ab -= ab_offset;
00151     afb_dim1 = *ldafb;
00152     afb_offset = 1 + afb_dim1;
00153     afb -= afb_offset;
00154     --ipiv;
00155     --c__;
00156     --work;
00157     --iwork;
00158 
00159     /* Function Body */
00160     ret_val = 0.;
00161 
00162     *info = 0;
00163     notrans = lsame_(trans, "N");
00164     if (! notrans && ! lsame_(trans, "T") && ! lsame_(
00165             trans, "C")) {
00166         *info = -1;
00167     } else if (*n < 0) {
00168         *info = -2;
00169     } else if (*kl < 0 || *kl > *n - 1) {
00170         *info = -3;
00171     } else if (*ku < 0 || *ku > *n - 1) {
00172         *info = -4;
00173     } else if (*ldab < *kl + *ku + 1) {
00174         *info = -6;
00175     } else if (*ldafb < (*kl << 1) + *ku + 1) {
00176         *info = -8;
00177     }
00178     if (*info != 0) {
00179         i__1 = -(*info);
00180         xerbla_("DLA_GBRCOND", &i__1);
00181         return ret_val;
00182     }
00183     if (*n == 0) {
00184         ret_val = 1.;
00185         return ret_val;
00186     }
00187 
00188 /*     Compute the equilibration matrix R such that */
00189 /*     inv(R)*A*C has unit 1-norm. */
00190 
00191     kd = *ku + 1;
00192     ke = *kl + 1;
00193     if (notrans) {
00194         i__1 = *n;
00195         for (i__ = 1; i__ <= i__1; ++i__) {
00196             tmp = 0.;
00197             if (*cmode == 1) {
00198 /* Computing MAX */
00199                 i__2 = i__ - *kl;
00200 /* Computing MIN */
00201                 i__4 = i__ + *ku;
00202                 i__3 = min(i__4,*n);
00203                 for (j = max(i__2,1); j <= i__3; ++j) {
00204                     tmp += (d__1 = ab[kd + i__ - j + j * ab_dim1] * c__[j], 
00205                             abs(d__1));
00206                 }
00207             } else if (*cmode == 0) {
00208 /* Computing MAX */
00209                 i__3 = i__ - *kl;
00210 /* Computing MIN */
00211                 i__4 = i__ + *ku;
00212                 i__2 = min(i__4,*n);
00213                 for (j = max(i__3,1); j <= i__2; ++j) {
00214                     tmp += (d__1 = ab[kd + i__ - j + j * ab_dim1], abs(d__1));
00215                 }
00216             } else {
00217 /* Computing MAX */
00218                 i__2 = i__ - *kl;
00219 /* Computing MIN */
00220                 i__4 = i__ + *ku;
00221                 i__3 = min(i__4,*n);
00222                 for (j = max(i__2,1); j <= i__3; ++j) {
00223                     tmp += (d__1 = ab[kd + i__ - j + j * ab_dim1] / c__[j], 
00224                             abs(d__1));
00225                 }
00226             }
00227             work[(*n << 1) + i__] = tmp;
00228         }
00229     } else {
00230         i__1 = *n;
00231         for (i__ = 1; i__ <= i__1; ++i__) {
00232             tmp = 0.;
00233             if (*cmode == 1) {
00234 /* Computing MAX */
00235                 i__3 = i__ - *kl;
00236 /* Computing MIN */
00237                 i__4 = i__ + *ku;
00238                 i__2 = min(i__4,*n);
00239                 for (j = max(i__3,1); j <= i__2; ++j) {
00240                     tmp += (d__1 = ab[ke - i__ + j + i__ * ab_dim1] * c__[j], 
00241                             abs(d__1));
00242                 }
00243             } else if (*cmode == 0) {
00244 /* Computing MAX */
00245                 i__2 = i__ - *kl;
00246 /* Computing MIN */
00247                 i__4 = i__ + *ku;
00248                 i__3 = min(i__4,*n);
00249                 for (j = max(i__2,1); j <= i__3; ++j) {
00250                     tmp += (d__1 = ab[ke - i__ + j + i__ * ab_dim1], abs(d__1)
00251                             );
00252                 }
00253             } else {
00254 /* Computing MAX */
00255                 i__3 = i__ - *kl;
00256 /* Computing MIN */
00257                 i__4 = i__ + *ku;
00258                 i__2 = min(i__4,*n);
00259                 for (j = max(i__3,1); j <= i__2; ++j) {
00260                     tmp += (d__1 = ab[ke - i__ + j + i__ * ab_dim1] / c__[j], 
00261                             abs(d__1));
00262                 }
00263             }
00264             work[(*n << 1) + i__] = tmp;
00265         }
00266     }
00267 
00268 /*     Estimate the norm of inv(op(A)). */
00269 
00270     ainvnm = 0.;
00271     kase = 0;
00272 L10:
00273     dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00274     if (kase != 0) {
00275         if (kase == 2) {
00276 
00277 /*           Multiply by R. */
00278 
00279             i__1 = *n;
00280             for (i__ = 1; i__ <= i__1; ++i__) {
00281                 work[i__] *= work[(*n << 1) + i__];
00282             }
00283             if (notrans) {
00284                 dgbtrs_("No transpose", n, kl, ku, &c__1, &afb[afb_offset], 
00285                         ldafb, &ipiv[1], &work[1], n, info);
00286             } else {
00287                 dgbtrs_("Transpose", n, kl, ku, &c__1, &afb[afb_offset], 
00288                         ldafb, &ipiv[1], &work[1], n, info);
00289             }
00290 
00291 /*           Multiply by inv(C). */
00292 
00293             if (*cmode == 1) {
00294                 i__1 = *n;
00295                 for (i__ = 1; i__ <= i__1; ++i__) {
00296                     work[i__] /= c__[i__];
00297                 }
00298             } else if (*cmode == -1) {
00299                 i__1 = *n;
00300                 for (i__ = 1; i__ <= i__1; ++i__) {
00301                     work[i__] *= c__[i__];
00302                 }
00303             }
00304         } else {
00305 
00306 /*           Multiply by inv(C'). */
00307 
00308             if (*cmode == 1) {
00309                 i__1 = *n;
00310                 for (i__ = 1; i__ <= i__1; ++i__) {
00311                     work[i__] /= c__[i__];
00312                 }
00313             } else if (*cmode == -1) {
00314                 i__1 = *n;
00315                 for (i__ = 1; i__ <= i__1; ++i__) {
00316                     work[i__] *= c__[i__];
00317                 }
00318             }
00319             if (notrans) {
00320                 dgbtrs_("Transpose", n, kl, ku, &c__1, &afb[afb_offset], 
00321                         ldafb, &ipiv[1], &work[1], n, info);
00322             } else {
00323                 dgbtrs_("No transpose", n, kl, ku, &c__1, &afb[afb_offset], 
00324                         ldafb, &ipiv[1], &work[1], n, info);
00325             }
00326 
00327 /*           Multiply by R. */
00328 
00329             i__1 = *n;
00330             for (i__ = 1; i__ <= i__1; ++i__) {
00331                 work[i__] *= work[(*n << 1) + i__];
00332             }
00333         }
00334         goto L10;
00335     }
00336 
00337 /*     Compute the estimate of the reciprocal condition number. */
00338 
00339     if (ainvnm != 0.) {
00340         ret_val = 1. / ainvnm;
00341     }
00342 
00343     return ret_val;
00344 
00345 } /* dla_gbrcond__ */


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