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


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