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


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