spbcon.c
Go to the documentation of this file.
00001 /* spbcon.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 spbcon_(char *uplo, integer *n, integer *kd, real *ab, 
00021         integer *ldab, real *anorm, real *rcond, real *work, integer *iwork, 
00022         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;
00030     real scale;
00031     extern logical lsame_(char *, char *);
00032     integer isave[3];
00033     extern /* Subroutine */ int srscl_(integer *, real *, real *, integer *);
00034     logical upper;
00035     extern /* Subroutine */ int slacn2_(integer *, real *, real *, integer *, 
00036             real *, integer *, integer *);
00037     real scalel;
00038     extern doublereal slamch_(char *);
00039     real scaleu;
00040     extern /* Subroutine */ int xerbla_(char *, integer *);
00041     extern integer isamax_(integer *, real *, integer *);
00042     real ainvnm;
00043     extern /* Subroutine */ int slatbs_(char *, char *, char *, char *, 
00044             integer *, integer *, real *, integer *, real *, real *, real *, 
00045             integer *);
00046     char normin[1];
00047     real smlnum;
00048 
00049 
00050 /*  -- LAPACK routine (version 3.2) -- */
00051 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00052 /*     November 2006 */
00053 
00054 /*     Modified to call SLACN2 in place of SLACON, 7 Feb 03, SJH. */
00055 
00056 /*     .. Scalar Arguments .. */
00057 /*     .. */
00058 /*     .. Array Arguments .. */
00059 /*     .. */
00060 
00061 /*  Purpose */
00062 /*  ======= */
00063 
00064 /*  SPBCON estimates the reciprocal of the condition number (in the */
00065 /*  1-norm) of a real symmetric positive definite band matrix using the */
00066 /*  Cholesky factorization A = U**T*U or A = L*L**T computed by SPBTRF. */
00067 
00068 /*  An estimate is obtained for norm(inv(A)), and the reciprocal of the */
00069 /*  condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */
00070 
00071 /*  Arguments */
00072 /*  ========= */
00073 
00074 /*  UPLO    (input) CHARACTER*1 */
00075 /*          = 'U':  Upper triangular factor stored in AB; */
00076 /*          = 'L':  Lower triangular factor stored in AB. */
00077 
00078 /*  N       (input) INTEGER */
00079 /*          The order of the matrix A.  N >= 0. */
00080 
00081 /*  KD      (input) INTEGER */
00082 /*          The number of superdiagonals of the matrix A if UPLO = 'U', */
00083 /*          or the number of subdiagonals if UPLO = 'L'.  KD >= 0. */
00084 
00085 /*  AB      (input) REAL array, dimension (LDAB,N) */
00086 /*          The triangular factor U or L from the Cholesky factorization */
00087 /*          A = U**T*U or A = L*L**T of the band matrix A, stored in the */
00088 /*          first KD+1 rows of the array.  The j-th column of U or L is */
00089 /*          stored in the j-th column of the array AB as follows: */
00090 /*          if UPLO ='U', AB(kd+1+i-j,j) = U(i,j) for max(1,j-kd)<=i<=j; */
00091 /*          if UPLO ='L', AB(1+i-j,j)    = L(i,j) for j<=i<=min(n,j+kd). */
00092 
00093 /*  LDAB    (input) INTEGER */
00094 /*          The leading dimension of the array AB.  LDAB >= KD+1. */
00095 
00096 /*  ANORM   (input) REAL */
00097 /*          The 1-norm (or infinity-norm) of the symmetric band matrix A. */
00098 
00099 /*  RCOND   (output) REAL */
00100 /*          The reciprocal of the condition number of the matrix A, */
00101 /*          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
00102 /*          estimate of the 1-norm of inv(A) computed in this routine. */
00103 
00104 /*  WORK    (workspace) REAL array, dimension (3*N) */
00105 
00106 /*  IWORK   (workspace) INTEGER array, dimension (N) */
00107 
00108 /*  INFO    (output) INTEGER */
00109 /*          = 0:  successful exit */
00110 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00111 
00112 /*  ===================================================================== */
00113 
00114 /*     .. Parameters .. */
00115 /*     .. */
00116 /*     .. Local Scalars .. */
00117 /*     .. */
00118 /*     .. Local Arrays .. */
00119 /*     .. */
00120 /*     .. External Functions .. */
00121 /*     .. */
00122 /*     .. External Subroutines .. */
00123 /*     .. */
00124 /*     .. Intrinsic Functions .. */
00125 /*     .. */
00126 /*     .. Executable Statements .. */
00127 
00128 /*     Test the input parameters. */
00129 
00130     /* Parameter adjustments */
00131     ab_dim1 = *ldab;
00132     ab_offset = 1 + ab_dim1;
00133     ab -= ab_offset;
00134     --work;
00135     --iwork;
00136 
00137     /* Function Body */
00138     *info = 0;
00139     upper = lsame_(uplo, "U");
00140     if (! upper && ! lsame_(uplo, "L")) {
00141         *info = -1;
00142     } else if (*n < 0) {
00143         *info = -2;
00144     } else if (*kd < 0) {
00145         *info = -3;
00146     } else if (*ldab < *kd + 1) {
00147         *info = -5;
00148     } else if (*anorm < 0.f) {
00149         *info = -6;
00150     }
00151     if (*info != 0) {
00152         i__1 = -(*info);
00153         xerbla_("SPBCON", &i__1);
00154         return 0;
00155     }
00156 
00157 /*     Quick return if possible */
00158 
00159     *rcond = 0.f;
00160     if (*n == 0) {
00161         *rcond = 1.f;
00162         return 0;
00163     } else if (*anorm == 0.f) {
00164         return 0;
00165     }
00166 
00167     smlnum = slamch_("Safe minimum");
00168 
00169 /*     Estimate the 1-norm of the inverse. */
00170 
00171     kase = 0;
00172     *(unsigned char *)normin = 'N';
00173 L10:
00174     slacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00175     if (kase != 0) {
00176         if (upper) {
00177 
00178 /*           Multiply by inv(U'). */
00179 
00180             slatbs_("Upper", "Transpose", "Non-unit", normin, n, kd, &ab[
00181                     ab_offset], ldab, &work[1], &scalel, &work[(*n << 1) + 1], 
00182                      info);
00183             *(unsigned char *)normin = 'Y';
00184 
00185 /*           Multiply by inv(U). */
00186 
00187             slatbs_("Upper", "No transpose", "Non-unit", normin, n, kd, &ab[
00188                     ab_offset], ldab, &work[1], &scaleu, &work[(*n << 1) + 1], 
00189                      info);
00190         } else {
00191 
00192 /*           Multiply by inv(L). */
00193 
00194             slatbs_("Lower", "No transpose", "Non-unit", normin, n, kd, &ab[
00195                     ab_offset], ldab, &work[1], &scalel, &work[(*n << 1) + 1], 
00196                      info);
00197             *(unsigned char *)normin = 'Y';
00198 
00199 /*           Multiply by inv(L'). */
00200 
00201             slatbs_("Lower", "Transpose", "Non-unit", normin, n, kd, &ab[
00202                     ab_offset], ldab, &work[1], &scaleu, &work[(*n << 1) + 1], 
00203                      info);
00204         }
00205 
00206 /*        Multiply by 1/SCALE if doing so will not cause overflow. */
00207 
00208         scale = scalel * scaleu;
00209         if (scale != 1.f) {
00210             ix = isamax_(n, &work[1], &c__1);
00211             if (scale < (r__1 = work[ix], dabs(r__1)) * smlnum || scale == 
00212                     0.f) {
00213                 goto L20;
00214             }
00215             srscl_(n, &scale, &work[1], &c__1);
00216         }
00217         goto L10;
00218     }
00219 
00220 /*     Compute the estimate of the reciprocal condition number. */
00221 
00222     if (ainvnm != 0.f) {
00223         *rcond = 1.f / ainvnm / *anorm;
00224     }
00225 
00226 L20:
00227 
00228     return 0;
00229 
00230 /*     End of SPBCON */
00231 
00232 } /* spbcon_ */


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