zgbcon.c
Go to the documentation of this file.
00001 /* zgbcon.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 zgbcon_(char *norm, integer *n, integer *kl, integer *ku, 
00021          doublecomplex *ab, integer *ldab, integer *ipiv, doublereal *anorm, 
00022         doublereal *rcond, doublecomplex *work, doublereal *rwork, integer *
00023         info)
00024 {
00025     /* System generated locals */
00026     integer ab_dim1, ab_offset, i__1, i__2, i__3;
00027     doublereal d__1, d__2;
00028     doublecomplex z__1, z__2;
00029 
00030     /* Builtin functions */
00031     double d_imag(doublecomplex *);
00032 
00033     /* Local variables */
00034     integer j;
00035     doublecomplex t;
00036     integer kd, lm, jp, ix, kase, kase1;
00037     doublereal scale;
00038     extern logical lsame_(char *, char *);
00039     integer isave[3];
00040     extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, 
00041             doublecomplex *, integer *, doublecomplex *, integer *);
00042     logical lnoti;
00043     extern /* Subroutine */ int zaxpy_(integer *, doublecomplex *, 
00044             doublecomplex *, integer *, doublecomplex *, integer *), zlacn2_(
00045             integer *, doublecomplex *, doublecomplex *, doublereal *, 
00046             integer *, integer *);
00047     extern doublereal dlamch_(char *);
00048     extern /* Subroutine */ int xerbla_(char *, integer *);
00049     doublereal ainvnm;
00050     extern integer izamax_(integer *, doublecomplex *, integer *);
00051     logical onenrm;
00052     extern /* Subroutine */ int zlatbs_(char *, char *, char *, char *, 
00053             integer *, integer *, doublecomplex *, integer *, doublecomplex *, 
00054              doublereal *, doublereal *, integer *), zdrscl_(integer *, doublereal *, doublecomplex *, 
00055             integer *);
00056     char normin[1];
00057     doublereal 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 ZLACN2 in place of ZLACON, 10 Feb 03, SJH. */
00065 
00066 /*     .. Scalar Arguments .. */
00067 /*     .. */
00068 /*     .. Array Arguments .. */
00069 /*     .. */
00070 
00071 /*  Purpose */
00072 /*  ======= */
00073 
00074 /*  ZGBCON 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 ZGBTRF. */
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*16 array, dimension (LDAB,N) */
00101 /*          Details of the LU factorization of the band matrix A, as */
00102 /*          computed by ZGBTRF.  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) DOUBLE PRECISION */
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) DOUBLE PRECISION */
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*16 array, dimension (2*N) */
00123 
00124 /*  RWORK   (workspace) DOUBLE PRECISION 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.) {
00174         *info = -8;
00175     }
00176     if (*info != 0) {
00177         i__1 = -(*info);
00178         xerbla_("ZGBCON", &i__1);
00179         return 0;
00180     }
00181 
00182 /*     Quick return if possible */
00183 
00184     *rcond = 0.;
00185     if (*n == 0) {
00186         *rcond = 1.;
00187         return 0;
00188     } else if (*anorm == 0.) {
00189         return 0;
00190     }
00191 
00192     smlnum = dlamch_("Safe minimum");
00193 
00194 /*     Estimate the norm of inv(A). */
00195 
00196     ainvnm = 0.;
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     zlacn2_(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                     z__1.r = -t.r, z__1.i = -t.i;
00231                     zaxpy_(&lm, &z__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             zlatbs_("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             zlatbs_("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                     zdotc_(&z__2, &lm, &ab[kd + 1 + j * ab_dim1], &c__1, &
00261                             work[j + 1], &c__1);
00262                     z__1.r = work[i__2].r - z__2.r, z__1.i = work[i__2].i - 
00263                             z__2.i;
00264                     work[i__1].r = z__1.r, work[i__1].i = z__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.) {
00285             ix = izamax_(n, &work[1], &c__1);
00286             i__1 = ix;
00287             if (scale < ((d__1 = work[i__1].r, abs(d__1)) + (d__2 = d_imag(&
00288                     work[ix]), abs(d__2))) * smlnum || scale == 0.) {
00289                 goto L40;
00290             }
00291             zdrscl_(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.) {
00299         *rcond = 1. / ainvnm / *anorm;
00300     }
00301 
00302 L40:
00303     return 0;
00304 
00305 /*     End of ZGBCON */
00306 
00307 } /* zgbcon_ */


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