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


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