spocon.c
Go to the documentation of this file.
00001 /* spocon.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 spocon_(char *uplo, integer *n, real *a, integer *lda, 
00021         real *anorm, real *rcond, real *work, integer *iwork, integer *info)
00022 {
00023     /* System generated locals */
00024     integer a_dim1, a_offset, 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 slatrs_(char *, char *, char *, char *, 
00044             integer *, real *, integer *, 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 /*  SPOCON estimates the reciprocal of the condition number (in the */
00063 /*  1-norm) of a real symmetric positive definite matrix using the */
00064 /*  Cholesky factorization A = U**T*U or A = L*L**T computed by SPOTRF. */
00065 
00066 /*  An estimate is obtained for norm(inv(A)), and the reciprocal of the */
00067 /*  condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */
00068 
00069 /*  Arguments */
00070 /*  ========= */
00071 
00072 /*  UPLO    (input) CHARACTER*1 */
00073 /*          = 'U':  Upper triangle of A is stored; */
00074 /*          = 'L':  Lower triangle of A is stored. */
00075 
00076 /*  N       (input) INTEGER */
00077 /*          The order of the matrix A.  N >= 0. */
00078 
00079 /*  A       (input) REAL array, dimension (LDA,N) */
00080 /*          The triangular factor U or L from the Cholesky factorization */
00081 /*          A = U**T*U or A = L*L**T, as computed by SPOTRF. */
00082 
00083 /*  LDA     (input) INTEGER */
00084 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00085 
00086 /*  ANORM   (input) REAL */
00087 /*          The 1-norm (or infinity-norm) of the symmetric matrix A. */
00088 
00089 /*  RCOND   (output) REAL */
00090 /*          The reciprocal of the condition number of the matrix A, */
00091 /*          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
00092 /*          estimate of the 1-norm of inv(A) computed in this routine. */
00093 
00094 /*  WORK    (workspace) REAL array, dimension (3*N) */
00095 
00096 /*  IWORK   (workspace) INTEGER array, dimension (N) */
00097 
00098 /*  INFO    (output) INTEGER */
00099 /*          = 0:  successful exit */
00100 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00101 
00102 /*  ===================================================================== */
00103 
00104 /*     .. Parameters .. */
00105 /*     .. */
00106 /*     .. Local Scalars .. */
00107 /*     .. */
00108 /*     .. Local Arrays .. */
00109 /*     .. */
00110 /*     .. External Functions .. */
00111 /*     .. */
00112 /*     .. External Subroutines .. */
00113 /*     .. */
00114 /*     .. Intrinsic Functions .. */
00115 /*     .. */
00116 /*     .. Executable Statements .. */
00117 
00118 /*     Test the input parameters. */
00119 
00120     /* Parameter adjustments */
00121     a_dim1 = *lda;
00122     a_offset = 1 + a_dim1;
00123     a -= a_offset;
00124     --work;
00125     --iwork;
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 (*lda < max(1,*n)) {
00135         *info = -4;
00136     } else if (*anorm < 0.f) {
00137         *info = -5;
00138     }
00139     if (*info != 0) {
00140         i__1 = -(*info);
00141         xerbla_("SPOCON", &i__1);
00142         return 0;
00143     }
00144 
00145 /*     Quick return if possible */
00146 
00147     *rcond = 0.f;
00148     if (*n == 0) {
00149         *rcond = 1.f;
00150         return 0;
00151     } else if (*anorm == 0.f) {
00152         return 0;
00153     }
00154 
00155     smlnum = slamch_("Safe minimum");
00156 
00157 /*     Estimate the 1-norm of inv(A). */
00158 
00159     kase = 0;
00160     *(unsigned char *)normin = 'N';
00161 L10:
00162     slacn2_(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             slatrs_("Upper", "Transpose", "Non-unit", normin, n, &a[a_offset], 
00169                      lda, &work[1], &scalel, &work[(*n << 1) + 1], info);
00170             *(unsigned char *)normin = 'Y';
00171 
00172 /*           Multiply by inv(U). */
00173 
00174             slatrs_("Upper", "No transpose", "Non-unit", normin, n, &a[
00175                     a_offset], lda, &work[1], &scaleu, &work[(*n << 1) + 1], 
00176                     info);
00177         } else {
00178 
00179 /*           Multiply by inv(L). */
00180 
00181             slatrs_("Lower", "No transpose", "Non-unit", normin, n, &a[
00182                     a_offset], lda, &work[1], &scalel, &work[(*n << 1) + 1], 
00183                     info);
00184             *(unsigned char *)normin = 'Y';
00185 
00186 /*           Multiply by inv(L'). */
00187 
00188             slatrs_("Lower", "Transpose", "Non-unit", normin, n, &a[a_offset], 
00189                      lda, &work[1], &scaleu, &work[(*n << 1) + 1], info);
00190         }
00191 
00192 /*        Multiply by 1/SCALE if doing so will not cause overflow. */
00193 
00194         scale = scalel * scaleu;
00195         if (scale != 1.f) {
00196             ix = isamax_(n, &work[1], &c__1);
00197             if (scale < (r__1 = work[ix], dabs(r__1)) * smlnum || scale == 
00198                     0.f) {
00199                 goto L20;
00200             }
00201             srscl_(n, &scale, &work[1], &c__1);
00202         }
00203         goto L10;
00204     }
00205 
00206 /*     Compute the estimate of the reciprocal condition number. */
00207 
00208     if (ainvnm != 0.f) {
00209         *rcond = 1.f / ainvnm / *anorm;
00210     }
00211 
00212 L20:
00213     return 0;
00214 
00215 /*     End of SPOCON */
00216 
00217 } /* spocon_ */


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