stbcon.c
Go to the documentation of this file.
00001 /* stbcon.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 stbcon_(char *norm, char *uplo, char *diag, integer *n, 
00021         integer *kd, real *ab, integer *ldab, real *rcond, real *work, 
00022         integer *iwork, integer *info)
00023 {
00024     /* System generated locals */
00025     integer ab_dim1, ab_offset, i__1;
00026     real r__1;
00027 
00028     /* Local variables */
00029     integer ix, kase, kase1;
00030     real scale;
00031     extern logical lsame_(char *, char *);
00032     integer isave[3];
00033     real anorm;
00034     extern /* Subroutine */ int srscl_(integer *, real *, real *, integer *);
00035     logical upper;
00036     real xnorm;
00037     extern /* Subroutine */ int slacn2_(integer *, real *, real *, integer *, 
00038             real *, integer *, integer *);
00039     extern doublereal slamch_(char *);
00040     extern /* Subroutine */ int xerbla_(char *, integer *);
00041     extern integer isamax_(integer *, real *, integer *);
00042     extern doublereal slantb_(char *, char *, char *, integer *, integer *, 
00043             real *, integer *, real *);
00044     real ainvnm;
00045     extern /* Subroutine */ int slatbs_(char *, char *, char *, char *, 
00046             integer *, integer *, real *, integer *, real *, real *, real *, 
00047             integer *);
00048     logical onenrm;
00049     char normin[1];
00050     real smlnum;
00051     logical nounit;
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 /*  STBCON estimates the reciprocal of the condition number of a */
00069 /*  triangular band matrix A, in either the 1-norm or the infinity-norm. */
00070 
00071 /*  The norm of A is computed and an estimate is obtained for */
00072 /*  norm(inv(A)), then the reciprocal of the condition number is */
00073 /*  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 /*  UPLO    (input) CHARACTER*1 */
00086 /*          = 'U':  A is upper triangular; */
00087 /*          = 'L':  A is lower triangular. */
00088 
00089 /*  DIAG    (input) CHARACTER*1 */
00090 /*          = 'N':  A is non-unit triangular; */
00091 /*          = 'U':  A is unit triangular. */
00092 
00093 /*  N       (input) INTEGER */
00094 /*          The order of the matrix A.  N >= 0. */
00095 
00096 /*  KD      (input) INTEGER */
00097 /*          The number of superdiagonals or subdiagonals of the */
00098 /*          triangular band matrix A.  KD >= 0. */
00099 
00100 /*  AB      (input) REAL array, dimension (LDAB,N) */
00101 /*          The upper or lower triangular band matrix A, stored in the */
00102 /*          first kd+1 rows of the array. The j-th column of A is stored */
00103 /*          in the j-th column of the array AB as follows: */
00104 /*          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */
00105 /*          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd). */
00106 /*          If DIAG = 'U', the diagonal elements of A are not referenced */
00107 /*          and are assumed to be 1. */
00108 
00109 /*  LDAB    (input) INTEGER */
00110 /*          The leading dimension of the array AB.  LDAB >= KD+1. */
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     --work;
00147     --iwork;
00148 
00149     /* Function Body */
00150     *info = 0;
00151     upper = lsame_(uplo, "U");
00152     onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O");
00153     nounit = lsame_(diag, "N");
00154 
00155     if (! onenrm && ! lsame_(norm, "I")) {
00156         *info = -1;
00157     } else if (! upper && ! lsame_(uplo, "L")) {
00158         *info = -2;
00159     } else if (! nounit && ! lsame_(diag, "U")) {
00160         *info = -3;
00161     } else if (*n < 0) {
00162         *info = -4;
00163     } else if (*kd < 0) {
00164         *info = -5;
00165     } else if (*ldab < *kd + 1) {
00166         *info = -7;
00167     }
00168     if (*info != 0) {
00169         i__1 = -(*info);
00170         xerbla_("STBCON", &i__1);
00171         return 0;
00172     }
00173 
00174 /*     Quick return if possible */
00175 
00176     if (*n == 0) {
00177         *rcond = 1.f;
00178         return 0;
00179     }
00180 
00181     *rcond = 0.f;
00182     smlnum = slamch_("Safe minimum") * (real) max(1,*n);
00183 
00184 /*     Compute the norm of the triangular matrix A. */
00185 
00186     anorm = slantb_(norm, uplo, diag, n, kd, &ab[ab_offset], ldab, &work[1]);
00187 
00188 /*     Continue only if ANORM > 0. */
00189 
00190     if (anorm > 0.f) {
00191 
00192 /*        Estimate the norm of the inverse of A. */
00193 
00194         ainvnm = 0.f;
00195         *(unsigned char *)normin = 'N';
00196         if (onenrm) {
00197             kase1 = 1;
00198         } else {
00199             kase1 = 2;
00200         }
00201         kase = 0;
00202 L10:
00203         slacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00204         if (kase != 0) {
00205             if (kase == kase1) {
00206 
00207 /*              Multiply by inv(A). */
00208 
00209                 slatbs_(uplo, "No transpose", diag, normin, n, kd, &ab[
00210                         ab_offset], ldab, &work[1], &scale, &work[(*n << 1) + 
00211                         1], info)
00212                         ;
00213             } else {
00214 
00215 /*              Multiply by inv(A'). */
00216 
00217                 slatbs_(uplo, "Transpose", diag, normin, n, kd, &ab[ab_offset]
00218 , ldab, &work[1], &scale, &work[(*n << 1) + 1], info);
00219             }
00220             *(unsigned char *)normin = 'Y';
00221 
00222 /*           Multiply by 1/SCALE if doing so will not cause overflow. */
00223 
00224             if (scale != 1.f) {
00225                 ix = isamax_(n, &work[1], &c__1);
00226                 xnorm = (r__1 = work[ix], dabs(r__1));
00227                 if (scale < xnorm * smlnum || scale == 0.f) {
00228                     goto L20;
00229                 }
00230                 srscl_(n, &scale, &work[1], &c__1);
00231             }
00232             goto L10;
00233         }
00234 
00235 /*        Compute the estimate of the reciprocal condition number. */
00236 
00237         if (ainvnm != 0.f) {
00238             *rcond = 1.f / anorm / ainvnm;
00239         }
00240     }
00241 
00242 L20:
00243     return 0;
00244 
00245 /*     End of STBCON */
00246 
00247 } /* stbcon_ */


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