cpocon.c
Go to the documentation of this file.
00001 /* cpocon.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 cpocon_(char *uplo, integer *n, complex *a, integer *lda, 
00021          real *anorm, real *rcond, complex *work, real *rwork, integer *info)
00022 {
00023     /* System generated locals */
00024     integer a_dim1, a_offset, 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 *);
00043     real ainvnm;
00044     extern /* Subroutine */ int clatrs_(char *, char *, char *, char *, 
00045             integer *, complex *, integer *, complex *, real *, real *, 
00046             integer *), csrscl_(integer *, 
00047             real *, complex *, integer *);
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 /*  CPOCON estimates the reciprocal of the condition number (in the */
00067 /*  1-norm) of a complex Hermitian positive definite matrix using the */
00068 /*  Cholesky factorization A = U**H*U or A = L*L**H computed by CPOTRF. */
00069 
00070 /*  An estimate is obtained for norm(inv(A)), and the reciprocal of the */
00071 /*  condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */
00072 
00073 /*  Arguments */
00074 /*  ========= */
00075 
00076 /*  UPLO    (input) CHARACTER*1 */
00077 /*          = 'U':  Upper triangle of A is stored; */
00078 /*          = 'L':  Lower triangle of A is stored. */
00079 
00080 /*  N       (input) INTEGER */
00081 /*          The order of the matrix A.  N >= 0. */
00082 
00083 /*  A       (input) COMPLEX array, dimension (LDA,N) */
00084 /*          The triangular factor U or L from the Cholesky factorization */
00085 /*          A = U**H*U or A = L*L**H, as computed by CPOTRF. */
00086 
00087 /*  LDA     (input) INTEGER */
00088 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00089 
00090 /*  ANORM   (input) REAL */
00091 /*          The 1-norm (or infinity-norm) of the Hermitian matrix A. */
00092 
00093 /*  RCOND   (output) REAL */
00094 /*          The reciprocal of the condition number of the matrix A, */
00095 /*          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
00096 /*          estimate of the 1-norm of inv(A) computed in this routine. */
00097 
00098 /*  WORK    (workspace) COMPLEX array, dimension (2*N) */
00099 
00100 /*  RWORK   (workspace) REAL array, dimension (N) */
00101 
00102 /*  INFO    (output) INTEGER */
00103 /*          = 0:  successful exit */
00104 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00105 
00106 /*  ===================================================================== */
00107 
00108 /*     .. Parameters .. */
00109 /*     .. */
00110 /*     .. Local Scalars .. */
00111 /*     .. */
00112 /*     .. Local Arrays .. */
00113 /*     .. */
00114 /*     .. External Functions .. */
00115 /*     .. */
00116 /*     .. External Subroutines .. */
00117 /*     .. */
00118 /*     .. Intrinsic Functions .. */
00119 /*     .. */
00120 /*     .. Statement Functions .. */
00121 /*     .. */
00122 /*     .. Statement Function definitions .. */
00123 /*     .. */
00124 /*     .. Executable Statements .. */
00125 
00126 /*     Test the input parameters. */
00127 
00128     /* Parameter adjustments */
00129     a_dim1 = *lda;
00130     a_offset = 1 + a_dim1;
00131     a -= a_offset;
00132     --work;
00133     --rwork;
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 (*lda < max(1,*n)) {
00143         *info = -4;
00144     } else if (*anorm < 0.f) {
00145         *info = -5;
00146     }
00147     if (*info != 0) {
00148         i__1 = -(*info);
00149         xerbla_("CPOCON", &i__1);
00150         return 0;
00151     }
00152 
00153 /*     Quick return if possible */
00154 
00155     *rcond = 0.f;
00156     if (*n == 0) {
00157         *rcond = 1.f;
00158         return 0;
00159     } else if (*anorm == 0.f) {
00160         return 0;
00161     }
00162 
00163     smlnum = slamch_("Safe minimum");
00164 
00165 /*     Estimate the 1-norm of inv(A). */
00166 
00167     kase = 0;
00168     *(unsigned char *)normin = 'N';
00169 L10:
00170     clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00171     if (kase != 0) {
00172         if (upper) {
00173 
00174 /*           Multiply by inv(U'). */
00175 
00176             clatrs_("Upper", "Conjugate transpose", "Non-unit", normin, n, &a[
00177                     a_offset], lda, &work[1], &scalel, &rwork[1], info);
00178             *(unsigned char *)normin = 'Y';
00179 
00180 /*           Multiply by inv(U). */
00181 
00182             clatrs_("Upper", "No transpose", "Non-unit", normin, n, &a[
00183                     a_offset], lda, &work[1], &scaleu, &rwork[1], info);
00184         } else {
00185 
00186 /*           Multiply by inv(L). */
00187 
00188             clatrs_("Lower", "No transpose", "Non-unit", normin, n, &a[
00189                     a_offset], lda, &work[1], &scalel, &rwork[1], info);
00190             *(unsigned char *)normin = 'Y';
00191 
00192 /*           Multiply by inv(L'). */
00193 
00194             clatrs_("Lower", "Conjugate transpose", "Non-unit", normin, n, &a[
00195                     a_offset], lda, &work[1], &scaleu, &rwork[1], info);
00196         }
00197 
00198 /*        Multiply by 1/SCALE if doing so will not cause overflow. */
00199 
00200         scale = scalel * scaleu;
00201         if (scale != 1.f) {
00202             ix = icamax_(n, &work[1], &c__1);
00203             i__1 = ix;
00204             if (scale < ((r__1 = work[i__1].r, dabs(r__1)) + (r__2 = r_imag(&
00205                     work[ix]), dabs(r__2))) * smlnum || scale == 0.f) {
00206                 goto L20;
00207             }
00208             csrscl_(n, &scale, &work[1], &c__1);
00209         }
00210         goto L10;
00211     }
00212 
00213 /*     Compute the estimate of the reciprocal condition number. */
00214 
00215     if (ainvnm != 0.f) {
00216         *rcond = 1.f / ainvnm / *anorm;
00217     }
00218 
00219 L20:
00220     return 0;
00221 
00222 /*     End of CPOCON */
00223 
00224 } /* cpocon_ */


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