dgbcon.c
Go to the documentation of this file.
00001 /* dgbcon.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 /* Subroutine */ int dgbcon_(char *norm, integer *n, integer *kl, integer *ku, 
00021          doublereal *ab, integer *ldab, integer *ipiv, doublereal *anorm, 
00022         doublereal *rcond, doublereal *work, integer *iwork, integer *info)
00023 {
00024     /* System generated locals */
00025     integer ab_dim1, ab_offset, i__1, i__2, i__3;
00026     doublereal d__1;
00027 
00028     /* Local variables */
00029     integer j;
00030     doublereal t;
00031     integer kd, lm, jp, ix, kase;
00032     extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *, 
00033             integer *);
00034     integer kase1;
00035     doublereal scale;
00036     extern logical lsame_(char *, char *);
00037     integer isave[3];
00038     extern /* Subroutine */ int drscl_(integer *, doublereal *, doublereal *, 
00039             integer *);
00040     logical lnoti;
00041     extern /* Subroutine */ int daxpy_(integer *, doublereal *, doublereal *, 
00042             integer *, doublereal *, integer *), dlacn2_(integer *, 
00043             doublereal *, doublereal *, integer *, doublereal *, integer *, 
00044             integer *);
00045     extern doublereal dlamch_(char *);
00046     extern integer idamax_(integer *, doublereal *, integer *);
00047     extern /* Subroutine */ int dlatbs_(char *, char *, char *, char *, 
00048             integer *, integer *, doublereal *, integer *, doublereal *, 
00049             doublereal *, doublereal *, integer *), xerbla_(char *, integer *);
00050     doublereal ainvnm;
00051     logical onenrm;
00052     char normin[1];
00053     doublereal smlnum;
00054 
00055 
00056 /*  -- LAPACK routine (version 3.2) -- */
00057 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00058 /*     November 2006 */
00059 
00060 /*     Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */
00061 
00062 /*     .. Scalar Arguments .. */
00063 /*     .. */
00064 /*     .. Array Arguments .. */
00065 /*     .. */
00066 
00067 /*  Purpose */
00068 /*  ======= */
00069 
00070 /*  DGBCON estimates the reciprocal of the condition number of a real */
00071 /*  general band matrix A, in either the 1-norm or the infinity-norm, */
00072 /*  using the LU factorization computed by DGBTRF. */
00073 
00074 /*  An estimate is obtained for norm(inv(A)), and the reciprocal of the */
00075 /*  condition number is computed as */
00076 /*     RCOND = 1 / ( norm(A) * norm(inv(A)) ). */
00077 
00078 /*  Arguments */
00079 /*  ========= */
00080 
00081 /*  NORM    (input) CHARACTER*1 */
00082 /*          Specifies whether the 1-norm condition number or the */
00083 /*          infinity-norm condition number is required: */
00084 /*          = '1' or 'O':  1-norm; */
00085 /*          = 'I':         Infinity-norm. */
00086 
00087 /*  N       (input) INTEGER */
00088 /*          The order of the matrix A.  N >= 0. */
00089 
00090 /*  KL      (input) INTEGER */
00091 /*          The number of subdiagonals within the band of A.  KL >= 0. */
00092 
00093 /*  KU      (input) INTEGER */
00094 /*          The number of superdiagonals within the band of A.  KU >= 0. */
00095 
00096 /*  AB      (input) DOUBLE PRECISION array, dimension (LDAB,N) */
00097 /*          Details of the LU factorization of the band matrix A, as */
00098 /*          computed by DGBTRF.  U is stored as an upper triangular band */
00099 /*          matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */
00100 /*          the multipliers used during the factorization are stored in */
00101 /*          rows KL+KU+2 to 2*KL+KU+1. */
00102 
00103 /*  LDAB    (input) INTEGER */
00104 /*          The leading dimension of the array AB.  LDAB >= 2*KL+KU+1. */
00105 
00106 /*  IPIV    (input) INTEGER array, dimension (N) */
00107 /*          The pivot indices; for 1 <= i <= N, row i of the matrix was */
00108 /*          interchanged with row IPIV(i). */
00109 
00110 /*  ANORM   (input) DOUBLE PRECISION */
00111 /*          If NORM = '1' or 'O', the 1-norm of the original matrix A. */
00112 /*          If NORM = 'I', the infinity-norm of the original matrix A. */
00113 
00114 /*  RCOND   (output) DOUBLE PRECISION */
00115 /*          The reciprocal of the condition number of the matrix A, */
00116 /*          computed as RCOND = 1/(norm(A) * norm(inv(A))). */
00117 
00118 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (3*N) */
00119 
00120 /*  IWORK   (workspace) INTEGER array, dimension (N) */
00121 
00122 /*  INFO    (output) INTEGER */
00123 /*          = 0:  successful exit */
00124 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00125 
00126 /*  ===================================================================== */
00127 
00128 /*     .. Parameters .. */
00129 /*     .. */
00130 /*     .. Local Scalars .. */
00131 /*     .. */
00132 /*     .. Local Arrays .. */
00133 /*     .. */
00134 /*     .. External Functions .. */
00135 /*     .. */
00136 /*     .. External Subroutines .. */
00137 /*     .. */
00138 /*     .. Intrinsic Functions .. */
00139 /*     .. */
00140 /*     .. Executable Statements .. */
00141 
00142 /*     Test the input parameters. */
00143 
00144     /* Parameter adjustments */
00145     ab_dim1 = *ldab;
00146     ab_offset = 1 + ab_dim1;
00147     ab -= ab_offset;
00148     --ipiv;
00149     --work;
00150     --iwork;
00151 
00152     /* Function Body */
00153     *info = 0;
00154     onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O");
00155     if (! onenrm && ! lsame_(norm, "I")) {
00156         *info = -1;
00157     } else if (*n < 0) {
00158         *info = -2;
00159     } else if (*kl < 0) {
00160         *info = -3;
00161     } else if (*ku < 0) {
00162         *info = -4;
00163     } else if (*ldab < (*kl << 1) + *ku + 1) {
00164         *info = -6;
00165     } else if (*anorm < 0.) {
00166         *info = -8;
00167     }
00168     if (*info != 0) {
00169         i__1 = -(*info);
00170         xerbla_("DGBCON", &i__1);
00171         return 0;
00172     }
00173 
00174 /*     Quick return if possible */
00175 
00176     *rcond = 0.;
00177     if (*n == 0) {
00178         *rcond = 1.;
00179         return 0;
00180     } else if (*anorm == 0.) {
00181         return 0;
00182     }
00183 
00184     smlnum = dlamch_("Safe minimum");
00185 
00186 /*     Estimate the norm of inv(A). */
00187 
00188     ainvnm = 0.;
00189     *(unsigned char *)normin = 'N';
00190     if (onenrm) {
00191         kase1 = 1;
00192     } else {
00193         kase1 = 2;
00194     }
00195     kd = *kl + *ku + 1;
00196     lnoti = *kl > 0;
00197     kase = 0;
00198 L10:
00199     dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00200     if (kase != 0) {
00201         if (kase == kase1) {
00202 
00203 /*           Multiply by inv(L). */
00204 
00205             if (lnoti) {
00206                 i__1 = *n - 1;
00207                 for (j = 1; j <= i__1; ++j) {
00208 /* Computing MIN */
00209                     i__2 = *kl, i__3 = *n - j;
00210                     lm = min(i__2,i__3);
00211                     jp = ipiv[j];
00212                     t = work[jp];
00213                     if (jp != j) {
00214                         work[jp] = work[j];
00215                         work[j] = t;
00216                     }
00217                     d__1 = -t;
00218                     daxpy_(&lm, &d__1, &ab[kd + 1 + j * ab_dim1], &c__1, &
00219                             work[j + 1], &c__1);
00220 /* L20: */
00221                 }
00222             }
00223 
00224 /*           Multiply by inv(U). */
00225 
00226             i__1 = *kl + *ku;
00227             dlatbs_("Upper", "No transpose", "Non-unit", normin, n, &i__1, &
00228                     ab[ab_offset], ldab, &work[1], &scale, &work[(*n << 1) + 
00229                     1], info);
00230         } else {
00231 
00232 /*           Multiply by inv(U'). */
00233 
00234             i__1 = *kl + *ku;
00235             dlatbs_("Upper", "Transpose", "Non-unit", normin, n, &i__1, &ab[
00236                     ab_offset], ldab, &work[1], &scale, &work[(*n << 1) + 1], 
00237                     info);
00238 
00239 /*           Multiply by inv(L'). */
00240 
00241             if (lnoti) {
00242                 for (j = *n - 1; j >= 1; --j) {
00243 /* Computing MIN */
00244                     i__1 = *kl, i__2 = *n - j;
00245                     lm = min(i__1,i__2);
00246                     work[j] -= ddot_(&lm, &ab[kd + 1 + j * ab_dim1], &c__1, &
00247                             work[j + 1], &c__1);
00248                     jp = ipiv[j];
00249                     if (jp != j) {
00250                         t = work[jp];
00251                         work[jp] = work[j];
00252                         work[j] = t;
00253                     }
00254 /* L30: */
00255                 }
00256             }
00257         }
00258 
00259 /*        Divide X by 1/SCALE if doing so will not cause overflow. */
00260 
00261         *(unsigned char *)normin = 'Y';
00262         if (scale != 1.) {
00263             ix = idamax_(n, &work[1], &c__1);
00264             if (scale < (d__1 = work[ix], abs(d__1)) * smlnum || scale == 0.) 
00265                     {
00266                 goto L40;
00267             }
00268             drscl_(n, &scale, &work[1], &c__1);
00269         }
00270         goto L10;
00271     }
00272 
00273 /*     Compute the estimate of the reciprocal condition number. */
00274 
00275     if (ainvnm != 0.) {
00276         *rcond = 1. / ainvnm / *anorm;
00277     }
00278 
00279 L40:
00280     return 0;
00281 
00282 /*     End of DGBCON */
00283 
00284 } /* dgbcon_ */


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