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


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