sspcon.c
Go to the documentation of this file.
00001 /* sspcon.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 sspcon_(char *uplo, integer *n, real *ap, integer *ipiv, 
00021         real *anorm, real *rcond, real *work, integer *iwork, integer *info)
00022 {
00023     /* System generated locals */
00024     integer i__1;
00025 
00026     /* Local variables */
00027     integer i__, ip, kase;
00028     extern logical lsame_(char *, char *);
00029     integer isave[3];
00030     logical upper;
00031     extern /* Subroutine */ int slacn2_(integer *, real *, real *, integer *, 
00032             real *, integer *, integer *), xerbla_(char *, integer *);
00033     real ainvnm;
00034     extern /* Subroutine */ int ssptrs_(char *, integer *, integer *, real *, 
00035             integer *, real *, integer *, integer *);
00036 
00037 
00038 /*  -- LAPACK routine (version 3.2) -- */
00039 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00040 /*     November 2006 */
00041 
00042 /*     Modified to call SLACN2 in place of SLACON, 5 Feb 03, SJH. */
00043 
00044 /*     .. Scalar Arguments .. */
00045 /*     .. */
00046 /*     .. Array Arguments .. */
00047 /*     .. */
00048 
00049 /*  Purpose */
00050 /*  ======= */
00051 
00052 /*  SSPCON estimates the reciprocal of the condition number (in the */
00053 /*  1-norm) of a real symmetric packed matrix A using the factorization */
00054 /*  A = U*D*U**T or A = L*D*L**T computed by SSPTRF. */
00055 
00056 /*  An estimate is obtained for norm(inv(A)), and the reciprocal of the */
00057 /*  condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */
00058 
00059 /*  Arguments */
00060 /*  ========= */
00061 
00062 /*  UPLO    (input) CHARACTER*1 */
00063 /*          Specifies whether the details of the factorization are stored */
00064 /*          as an upper or lower triangular matrix. */
00065 /*          = 'U':  Upper triangular, form is A = U*D*U**T; */
00066 /*          = 'L':  Lower triangular, form is A = L*D*L**T. */
00067 
00068 /*  N       (input) INTEGER */
00069 /*          The order of the matrix A.  N >= 0. */
00070 
00071 /*  AP      (input) REAL array, dimension (N*(N+1)/2) */
00072 /*          The block diagonal matrix D and the multipliers used to */
00073 /*          obtain the factor U or L as computed by SSPTRF, stored as a */
00074 /*          packed triangular matrix. */
00075 
00076 /*  IPIV    (input) INTEGER array, dimension (N) */
00077 /*          Details of the interchanges and the block structure of D */
00078 /*          as determined by SSPTRF. */
00079 
00080 /*  ANORM   (input) REAL */
00081 /*          The 1-norm of the original matrix A. */
00082 
00083 /*  RCOND   (output) REAL */
00084 /*          The reciprocal of the condition number of the matrix A, */
00085 /*          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
00086 /*          estimate of the 1-norm of inv(A) computed in this routine. */
00087 
00088 /*  WORK    (workspace) REAL array, dimension (2*N) */
00089 
00090 /*  IWORK    (workspace) INTEGER array, dimension (N) */
00091 
00092 /*  INFO    (output) INTEGER */
00093 /*          = 0:  successful exit */
00094 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00095 
00096 /*  ===================================================================== */
00097 
00098 /*     .. Parameters .. */
00099 /*     .. */
00100 /*     .. Local Scalars .. */
00101 /*     .. */
00102 /*     .. Local Arrays .. */
00103 /*     .. */
00104 /*     .. External Functions .. */
00105 /*     .. */
00106 /*     .. External Subroutines .. */
00107 /*     .. */
00108 /*     .. Executable Statements .. */
00109 
00110 /*     Test the input parameters. */
00111 
00112     /* Parameter adjustments */
00113     --iwork;
00114     --work;
00115     --ipiv;
00116     --ap;
00117 
00118     /* Function Body */
00119     *info = 0;
00120     upper = lsame_(uplo, "U");
00121     if (! upper && ! lsame_(uplo, "L")) {
00122         *info = -1;
00123     } else if (*n < 0) {
00124         *info = -2;
00125     } else if (*anorm < 0.f) {
00126         *info = -5;
00127     }
00128     if (*info != 0) {
00129         i__1 = -(*info);
00130         xerbla_("SSPCON", &i__1);
00131         return 0;
00132     }
00133 
00134 /*     Quick return if possible */
00135 
00136     *rcond = 0.f;
00137     if (*n == 0) {
00138         *rcond = 1.f;
00139         return 0;
00140     } else if (*anorm <= 0.f) {
00141         return 0;
00142     }
00143 
00144 /*     Check that the diagonal matrix D is nonsingular. */
00145 
00146     if (upper) {
00147 
00148 /*        Upper triangular storage: examine D from bottom to top */
00149 
00150         ip = *n * (*n + 1) / 2;
00151         for (i__ = *n; i__ >= 1; --i__) {
00152             if (ipiv[i__] > 0 && ap[ip] == 0.f) {
00153                 return 0;
00154             }
00155             ip -= i__;
00156 /* L10: */
00157         }
00158     } else {
00159 
00160 /*        Lower triangular storage: examine D from top to bottom. */
00161 
00162         ip = 1;
00163         i__1 = *n;
00164         for (i__ = 1; i__ <= i__1; ++i__) {
00165             if (ipiv[i__] > 0 && ap[ip] == 0.f) {
00166                 return 0;
00167             }
00168             ip = ip + *n - i__ + 1;
00169 /* L20: */
00170         }
00171     }
00172 
00173 /*     Estimate the 1-norm of the inverse. */
00174 
00175     kase = 0;
00176 L30:
00177     slacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00178     if (kase != 0) {
00179 
00180 /*        Multiply by inv(L*D*L') or inv(U*D*U'). */
00181 
00182         ssptrs_(uplo, n, &c__1, &ap[1], &ipiv[1], &work[1], n, info);
00183         goto L30;
00184     }
00185 
00186 /*     Compute the estimate of the reciprocal condition number. */
00187 
00188     if (ainvnm != 0.f) {
00189         *rcond = 1.f / ainvnm / *anorm;
00190     }
00191 
00192     return 0;
00193 
00194 /*     End of SSPCON */
00195 
00196 } /* sspcon_ */


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