ztbcon.c
Go to the documentation of this file.
00001 /* ztbcon.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 ztbcon_(char *norm, char *uplo, char *diag, integer *n, 
00021         integer *kd, doublecomplex *ab, integer *ldab, doublereal *rcond, 
00022         doublecomplex *work, doublereal *rwork, integer *info)
00023 {
00024     /* System generated locals */
00025     integer ab_dim1, ab_offset, i__1;
00026     doublereal d__1, d__2;
00027 
00028     /* Builtin functions */
00029     double d_imag(doublecomplex *);
00030 
00031     /* Local variables */
00032     integer ix, kase, kase1;
00033     doublereal scale;
00034     extern logical lsame_(char *, char *);
00035     integer isave[3];
00036     doublereal anorm;
00037     logical upper;
00038     doublereal xnorm;
00039     extern /* Subroutine */ int zlacn2_(integer *, doublecomplex *, 
00040             doublecomplex *, doublereal *, integer *, integer *);
00041     extern doublereal dlamch_(char *);
00042     extern /* Subroutine */ int xerbla_(char *, integer *);
00043     doublereal ainvnm;
00044     extern integer izamax_(integer *, doublecomplex *, integer *);
00045     extern doublereal zlantb_(char *, char *, char *, integer *, integer *, 
00046             doublecomplex *, integer *, doublereal *);
00047     logical onenrm;
00048     extern /* Subroutine */ int zlatbs_(char *, char *, char *, char *, 
00049             integer *, integer *, doublecomplex *, integer *, doublecomplex *, 
00050              doublereal *, doublereal *, integer *), zdrscl_(integer *, doublereal *, doublecomplex *, 
00051             integer *);
00052     char normin[1];
00053     doublereal smlnum;
00054     logical nounit;
00055 
00056 
00057 /*  -- LAPACK routine (version 3.2) -- */
00058 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00059 /*     November 2006 */
00060 
00061 /*     Modified to call ZLACN2 in place of ZLACON, 10 Feb 03, SJH. */
00062 
00063 /*     .. Scalar Arguments .. */
00064 /*     .. */
00065 /*     .. Array Arguments .. */
00066 /*     .. */
00067 
00068 /*  Purpose */
00069 /*  ======= */
00070 
00071 /*  ZTBCON estimates the reciprocal of the condition number of a */
00072 /*  triangular band matrix A, in either the 1-norm or the infinity-norm. */
00073 
00074 /*  The norm of A is computed and an estimate is obtained for */
00075 /*  norm(inv(A)), then the reciprocal of the condition number is */
00076 /*  computed as */
00077 /*     RCOND = 1 / ( norm(A) * norm(inv(A)) ). */
00078 
00079 /*  Arguments */
00080 /*  ========= */
00081 
00082 /*  NORM    (input) CHARACTER*1 */
00083 /*          Specifies whether the 1-norm condition number or the */
00084 /*          infinity-norm condition number is required: */
00085 /*          = '1' or 'O':  1-norm; */
00086 /*          = 'I':         Infinity-norm. */
00087 
00088 /*  UPLO    (input) CHARACTER*1 */
00089 /*          = 'U':  A is upper triangular; */
00090 /*          = 'L':  A is lower triangular. */
00091 
00092 /*  DIAG    (input) CHARACTER*1 */
00093 /*          = 'N':  A is non-unit triangular; */
00094 /*          = 'U':  A is unit triangular. */
00095 
00096 /*  N       (input) INTEGER */
00097 /*          The order of the matrix A.  N >= 0. */
00098 
00099 /*  KD      (input) INTEGER */
00100 /*          The number of superdiagonals or subdiagonals of the */
00101 /*          triangular band matrix A.  KD >= 0. */
00102 
00103 /*  AB      (input) COMPLEX*16 array, dimension (LDAB,N) */
00104 /*          The upper or lower triangular band matrix A, stored in the */
00105 /*          first kd+1 rows of the array. The j-th column of A is stored */
00106 /*          in the j-th column of the array AB as follows: */
00107 /*          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */
00108 /*          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd). */
00109 /*          If DIAG = 'U', the diagonal elements of A are not referenced */
00110 /*          and are assumed to be 1. */
00111 
00112 /*  LDAB    (input) INTEGER */
00113 /*          The leading dimension of the array AB.  LDAB >= KD+1. */
00114 
00115 /*  RCOND   (output) DOUBLE PRECISION */
00116 /*          The reciprocal of the condition number of the matrix A, */
00117 /*          computed as RCOND = 1/(norm(A) * norm(inv(A))). */
00118 
00119 /*  WORK    (workspace) COMPLEX*16 array, dimension (2*N) */
00120 
00121 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00122 
00123 /*  INFO    (output) INTEGER */
00124 /*          = 0:  successful exit */
00125 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00126 
00127 /*  ===================================================================== */
00128 
00129 /*     .. Parameters .. */
00130 /*     .. */
00131 /*     .. Local Scalars .. */
00132 /*     .. */
00133 /*     .. Local Arrays .. */
00134 /*     .. */
00135 /*     .. External Functions .. */
00136 /*     .. */
00137 /*     .. External Subroutines .. */
00138 /*     .. */
00139 /*     .. Intrinsic Functions .. */
00140 /*     .. */
00141 /*     .. Statement Functions .. */
00142 /*     .. */
00143 /*     .. Statement Function definitions .. */
00144 /*     .. */
00145 /*     .. Executable Statements .. */
00146 
00147 /*     Test the input parameters. */
00148 
00149     /* Parameter adjustments */
00150     ab_dim1 = *ldab;
00151     ab_offset = 1 + ab_dim1;
00152     ab -= ab_offset;
00153     --work;
00154     --rwork;
00155 
00156     /* Function Body */
00157     *info = 0;
00158     upper = lsame_(uplo, "U");
00159     onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O");
00160     nounit = lsame_(diag, "N");
00161 
00162     if (! onenrm && ! lsame_(norm, "I")) {
00163         *info = -1;
00164     } else if (! upper && ! lsame_(uplo, "L")) {
00165         *info = -2;
00166     } else if (! nounit && ! lsame_(diag, "U")) {
00167         *info = -3;
00168     } else if (*n < 0) {
00169         *info = -4;
00170     } else if (*kd < 0) {
00171         *info = -5;
00172     } else if (*ldab < *kd + 1) {
00173         *info = -7;
00174     }
00175     if (*info != 0) {
00176         i__1 = -(*info);
00177         xerbla_("ZTBCON", &i__1);
00178         return 0;
00179     }
00180 
00181 /*     Quick return if possible */
00182 
00183     if (*n == 0) {
00184         *rcond = 1.;
00185         return 0;
00186     }
00187 
00188     *rcond = 0.;
00189     smlnum = dlamch_("Safe minimum") * (doublereal) max(*n,1);
00190 
00191 /*     Compute the 1-norm of the triangular matrix A or A'. */
00192 
00193     anorm = zlantb_(norm, uplo, diag, n, kd, &ab[ab_offset], ldab, &rwork[1]);
00194 
00195 /*     Continue only if ANORM > 0. */
00196 
00197     if (anorm > 0.) {
00198 
00199 /*        Estimate the 1-norm of the inverse of A. */
00200 
00201         ainvnm = 0.;
00202         *(unsigned char *)normin = 'N';
00203         if (onenrm) {
00204             kase1 = 1;
00205         } else {
00206             kase1 = 2;
00207         }
00208         kase = 0;
00209 L10:
00210         zlacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00211         if (kase != 0) {
00212             if (kase == kase1) {
00213 
00214 /*              Multiply by inv(A). */
00215 
00216                 zlatbs_(uplo, "No transpose", diag, normin, n, kd, &ab[
00217                         ab_offset], ldab, &work[1], &scale, &rwork[1], info);
00218             } else {
00219 
00220 /*              Multiply by inv(A'). */
00221 
00222                 zlatbs_(uplo, "Conjugate transpose", diag, normin, n, kd, &ab[
00223                         ab_offset], ldab, &work[1], &scale, &rwork[1], info);
00224             }
00225             *(unsigned char *)normin = 'Y';
00226 
00227 /*           Multiply by 1/SCALE if doing so will not cause overflow. */
00228 
00229             if (scale != 1.) {
00230                 ix = izamax_(n, &work[1], &c__1);
00231                 i__1 = ix;
00232                 xnorm = (d__1 = work[i__1].r, abs(d__1)) + (d__2 = d_imag(&
00233                         work[ix]), abs(d__2));
00234                 if (scale < xnorm * smlnum || scale == 0.) {
00235                     goto L20;
00236                 }
00237                 zdrscl_(n, &scale, &work[1], &c__1);
00238             }
00239             goto L10;
00240         }
00241 
00242 /*        Compute the estimate of the reciprocal condition number. */
00243 
00244         if (ainvnm != 0.) {
00245             *rcond = 1. / anorm / ainvnm;
00246         }
00247     }
00248 
00249 L20:
00250     return 0;
00251 
00252 /*     End of ZTBCON */
00253 
00254 } /* ztbcon_ */


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