sla_gbrcond.c
Go to the documentation of this file.
00001 /* sla_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 sla_gbrcond__(char *trans, integer *n, integer *kl, integer *ku, 
00021         real *ab, integer *ldab, real *afb, integer *ldafb, integer *ipiv, 
00022         integer *cmode, real *c__, integer *info, real *work, integer *iwork, 
00023         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     real ret_val, r__1;
00028 
00029     /* Local variables */
00030     integer i__, j, kd, ke;
00031     real tmp;
00032     integer kase;
00033     extern logical lsame_(char *, char *);
00034     integer isave[3];
00035     extern /* Subroutine */ int slacn2_(integer *, real *, real *, integer *, 
00036             real *, integer *, integer *), xerbla_(char *, integer *);
00037     real ainvnm;
00038     extern /* Subroutine */ int sgbtrs_(char *, integer *, integer *, integer 
00039             *, integer *, real *, integer *, integer *, real *, integer *, 
00040             integer *);
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 /*     SLA_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) REAL 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) REAL array, dimension (LDAFB,N) */
00100 /*     Details of the LU factorization of the band matrix A, as */
00101 /*     computed by SGBTRF.  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 SGBTRF; 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) REAL 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) REAL 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.f;
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_("SLA_GBRCOND", &i__1);
00181         return ret_val;
00182     }
00183     if (*n == 0) {
00184         ret_val = 1.f;
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.f;
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 += (r__1 = ab[kd + i__ - j + j * ab_dim1] * c__[j], 
00205                             dabs(r__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 += (r__1 = ab[kd + i__ - j + j * ab_dim1], dabs(r__1))
00215                             ;
00216                 }
00217             } else {
00218 /* Computing MAX */
00219                 i__2 = i__ - *kl;
00220 /* Computing MIN */
00221                 i__4 = i__ + *ku;
00222                 i__3 = min(i__4,*n);
00223                 for (j = max(i__2,1); j <= i__3; ++j) {
00224                     tmp += (r__1 = ab[kd + i__ - j + j * ab_dim1] / c__[j], 
00225                             dabs(r__1));
00226                 }
00227             }
00228             work[(*n << 1) + i__] = tmp;
00229         }
00230     } else {
00231         i__1 = *n;
00232         for (i__ = 1; i__ <= i__1; ++i__) {
00233             tmp = 0.f;
00234             if (*cmode == 1) {
00235 /* Computing MAX */
00236                 i__3 = i__ - *kl;
00237 /* Computing MIN */
00238                 i__4 = i__ + *ku;
00239                 i__2 = min(i__4,*n);
00240                 for (j = max(i__3,1); j <= i__2; ++j) {
00241                     tmp += (r__1 = ab[ke - i__ + j + i__ * ab_dim1] * c__[j], 
00242                             dabs(r__1));
00243                 }
00244             } else if (*cmode == 0) {
00245 /* Computing MAX */
00246                 i__2 = i__ - *kl;
00247 /* Computing MIN */
00248                 i__4 = i__ + *ku;
00249                 i__3 = min(i__4,*n);
00250                 for (j = max(i__2,1); j <= i__3; ++j) {
00251                     tmp += (r__1 = ab[ke - i__ + j + i__ * ab_dim1], dabs(
00252                             r__1));
00253                 }
00254             } else {
00255 /* Computing MAX */
00256                 i__3 = i__ - *kl;
00257 /* Computing MIN */
00258                 i__4 = i__ + *ku;
00259                 i__2 = min(i__4,*n);
00260                 for (j = max(i__3,1); j <= i__2; ++j) {
00261                     tmp += (r__1 = ab[ke - i__ + j + i__ * ab_dim1] / c__[j], 
00262                             dabs(r__1));
00263                 }
00264             }
00265             work[(*n << 1) + i__] = tmp;
00266         }
00267     }
00268 
00269 /*     Estimate the norm of inv(op(A)). */
00270 
00271     ainvnm = 0.f;
00272     kase = 0;
00273 L10:
00274     slacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00275     if (kase != 0) {
00276         if (kase == 2) {
00277 
00278 /*           Multiply by R. */
00279 
00280             i__1 = *n;
00281             for (i__ = 1; i__ <= i__1; ++i__) {
00282                 work[i__] *= work[(*n << 1) + i__];
00283             }
00284             if (notrans) {
00285                 sgbtrs_("No transpose", n, kl, ku, &c__1, &afb[afb_offset], 
00286                         ldafb, &ipiv[1], &work[1], n, info);
00287             } else {
00288                 sgbtrs_("Transpose", n, kl, ku, &c__1, &afb[afb_offset], 
00289                         ldafb, &ipiv[1], &work[1], n, info);
00290             }
00291 
00292 /*           Multiply by inv(C). */
00293 
00294             if (*cmode == 1) {
00295                 i__1 = *n;
00296                 for (i__ = 1; i__ <= i__1; ++i__) {
00297                     work[i__] /= c__[i__];
00298                 }
00299             } else if (*cmode == -1) {
00300                 i__1 = *n;
00301                 for (i__ = 1; i__ <= i__1; ++i__) {
00302                     work[i__] *= c__[i__];
00303                 }
00304             }
00305         } else {
00306 
00307 /*           Multiply by inv(C'). */
00308 
00309             if (*cmode == 1) {
00310                 i__1 = *n;
00311                 for (i__ = 1; i__ <= i__1; ++i__) {
00312                     work[i__] /= c__[i__];
00313                 }
00314             } else if (*cmode == -1) {
00315                 i__1 = *n;
00316                 for (i__ = 1; i__ <= i__1; ++i__) {
00317                     work[i__] *= c__[i__];
00318                 }
00319             }
00320             if (notrans) {
00321                 sgbtrs_("Transpose", n, kl, ku, &c__1, &afb[afb_offset], 
00322                         ldafb, &ipiv[1], &work[1], n, info);
00323             } else {
00324                 sgbtrs_("No transpose", n, kl, ku, &c__1, &afb[afb_offset], 
00325                         ldafb, &ipiv[1], &work[1], n, info);
00326             }
00327 
00328 /*           Multiply by R. */
00329 
00330             i__1 = *n;
00331             for (i__ = 1; i__ <= i__1; ++i__) {
00332                 work[i__] *= work[(*n << 1) + i__];
00333             }
00334         }
00335         goto L10;
00336     }
00337 
00338 /*     Compute the estimate of the reciprocal condition number. */
00339 
00340     if (ainvnm != 0.f) {
00341         ret_val = 1.f / ainvnm;
00342     }
00343 
00344     return ret_val;
00345 
00346 } /* sla_gbrcond__ */


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