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


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