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


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