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


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