dppcon.c
Go to the documentation of this file.
00001 /* dppcon.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 dppcon_(char *uplo, integer *n, doublereal *ap, 
00021         doublereal *anorm, doublereal *rcond, doublereal *work, integer *
00022         iwork, integer *info)
00023 {
00024     /* System generated locals */
00025     integer i__1;
00026     doublereal d__1;
00027 
00028     /* Local variables */
00029     integer ix, kase;
00030     doublereal scale;
00031     extern logical lsame_(char *, char *);
00032     integer isave[3];
00033     extern /* Subroutine */ int drscl_(integer *, doublereal *, doublereal *, 
00034             integer *);
00035     logical upper;
00036     extern /* Subroutine */ int dlacn2_(integer *, doublereal *, doublereal *, 
00037              integer *, doublereal *, integer *, integer *);
00038     extern doublereal dlamch_(char *);
00039     doublereal scalel;
00040     extern integer idamax_(integer *, doublereal *, integer *);
00041     doublereal scaleu;
00042     extern /* Subroutine */ int xerbla_(char *, integer *), dlatps_(
00043             char *, char *, char *, char *, integer *, doublereal *, 
00044             doublereal *, doublereal *, doublereal *, integer *);
00045     doublereal ainvnm;
00046     char normin[1];
00047     doublereal 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 DLACN2 in place of DLACON, 5 Feb 03, SJH. */
00055 
00056 /*     .. Scalar Arguments .. */
00057 /*     .. */
00058 /*     .. Array Arguments .. */
00059 /*     .. */
00060 
00061 /*  Purpose */
00062 /*  ======= */
00063 
00064 /*  DPPCON estimates the reciprocal of the condition number (in the */
00065 /*  1-norm) of a real symmetric positive definite packed matrix using */
00066 /*  the Cholesky factorization A = U**T*U or A = L*L**T computed by */
00067 /*  DPPTRF. */
00068 
00069 /*  An estimate is obtained for norm(inv(A)), and the reciprocal of the */
00070 /*  condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */
00071 
00072 /*  Arguments */
00073 /*  ========= */
00074 
00075 /*  UPLO    (input) CHARACTER*1 */
00076 /*          = 'U':  Upper triangle of A is stored; */
00077 /*          = 'L':  Lower triangle of A is stored. */
00078 
00079 /*  N       (input) INTEGER */
00080 /*          The order of the matrix A.  N >= 0. */
00081 
00082 /*  AP      (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
00083 /*          The triangular factor U or L from the Cholesky factorization */
00084 /*          A = U**T*U or A = L*L**T, packed columnwise in a linear */
00085 /*          array.  The j-th column of U or L is stored in the array AP */
00086 /*          as follows: */
00087 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j; */
00088 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n. */
00089 
00090 /*  ANORM   (input) DOUBLE PRECISION */
00091 /*          The 1-norm (or infinity-norm) of the symmetric matrix A. */
00092 
00093 /*  RCOND   (output) DOUBLE PRECISION */
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) DOUBLE PRECISION array, dimension (3*N) */
00099 
00100 /*  IWORK   (workspace) INTEGER 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 /*     .. Executable Statements .. */
00121 
00122 /*     Test the input parameters. */
00123 
00124     /* Parameter adjustments */
00125     --iwork;
00126     --work;
00127     --ap;
00128 
00129     /* Function Body */
00130     *info = 0;
00131     upper = lsame_(uplo, "U");
00132     if (! upper && ! lsame_(uplo, "L")) {
00133         *info = -1;
00134     } else if (*n < 0) {
00135         *info = -2;
00136     } else if (*anorm < 0.) {
00137         *info = -4;
00138     }
00139     if (*info != 0) {
00140         i__1 = -(*info);
00141         xerbla_("DPPCON", &i__1);
00142         return 0;
00143     }
00144 
00145 /*     Quick return if possible */
00146 
00147     *rcond = 0.;
00148     if (*n == 0) {
00149         *rcond = 1.;
00150         return 0;
00151     } else if (*anorm == 0.) {
00152         return 0;
00153     }
00154 
00155     smlnum = dlamch_("Safe minimum");
00156 
00157 /*     Estimate the 1-norm of the inverse. */
00158 
00159     kase = 0;
00160     *(unsigned char *)normin = 'N';
00161 L10:
00162     dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00163     if (kase != 0) {
00164         if (upper) {
00165 
00166 /*           Multiply by inv(U'). */
00167 
00168             dlatps_("Upper", "Transpose", "Non-unit", normin, n, &ap[1], &
00169                     work[1], &scalel, &work[(*n << 1) + 1], info);
00170             *(unsigned char *)normin = 'Y';
00171 
00172 /*           Multiply by inv(U). */
00173 
00174             dlatps_("Upper", "No transpose", "Non-unit", normin, n, &ap[1], &
00175                     work[1], &scaleu, &work[(*n << 1) + 1], info);
00176         } else {
00177 
00178 /*           Multiply by inv(L). */
00179 
00180             dlatps_("Lower", "No transpose", "Non-unit", normin, n, &ap[1], &
00181                     work[1], &scalel, &work[(*n << 1) + 1], info);
00182             *(unsigned char *)normin = 'Y';
00183 
00184 /*           Multiply by inv(L'). */
00185 
00186             dlatps_("Lower", "Transpose", "Non-unit", normin, n, &ap[1], &
00187                     work[1], &scaleu, &work[(*n << 1) + 1], info);
00188         }
00189 
00190 /*        Multiply by 1/SCALE if doing so will not cause overflow. */
00191 
00192         scale = scalel * scaleu;
00193         if (scale != 1.) {
00194             ix = idamax_(n, &work[1], &c__1);
00195             if (scale < (d__1 = work[ix], abs(d__1)) * smlnum || scale == 0.) 
00196                     {
00197                 goto L20;
00198             }
00199             drscl_(n, &scale, &work[1], &c__1);
00200         }
00201         goto L10;
00202     }
00203 
00204 /*     Compute the estimate of the reciprocal condition number. */
00205 
00206     if (ainvnm != 0.) {
00207         *rcond = 1. / ainvnm / *anorm;
00208     }
00209 
00210 L20:
00211     return 0;
00212 
00213 /*     End of DPPCON */
00214 
00215 } /* dppcon_ */


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