dpocon.c
Go to the documentation of this file.
00001 /* dpocon.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 dpocon_(char *uplo, integer *n, doublereal *a, integer *
00021         lda, doublereal *anorm, doublereal *rcond, doublereal *work, integer *
00022         iwork, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, 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 *);
00043     doublereal ainvnm;
00044     extern /* Subroutine */ int dlatrs_(char *, char *, char *, char *, 
00045             integer *, doublereal *, integer *, doublereal *, doublereal *, 
00046             doublereal *, integer *);
00047     char normin[1];
00048     doublereal smlnum;
00049 
00050 
00051 /*  -- LAPACK routine (version 3.2) -- */
00052 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00053 /*     November 2006 */
00054 
00055 /*     Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */
00056 
00057 /*     .. Scalar Arguments .. */
00058 /*     .. */
00059 /*     .. Array Arguments .. */
00060 /*     .. */
00061 
00062 /*  Purpose */
00063 /*  ======= */
00064 
00065 /*  DPOCON estimates the reciprocal of the condition number (in the */
00066 /*  1-norm) of a real symmetric positive definite matrix using the */
00067 /*  Cholesky factorization A = U**T*U or A = L*L**T computed by DPOTRF. */
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 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00083 /*          The triangular factor U or L from the Cholesky factorization */
00084 /*          A = U**T*U or A = L*L**T, as computed by DPOTRF. */
00085 
00086 /*  LDA     (input) INTEGER */
00087 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00088 
00089 /*  ANORM   (input) DOUBLE PRECISION */
00090 /*          The 1-norm (or infinity-norm) of the symmetric matrix A. */
00091 
00092 /*  RCOND   (output) DOUBLE PRECISION */
00093 /*          The reciprocal of the condition number of the matrix A, */
00094 /*          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
00095 /*          estimate of the 1-norm of inv(A) computed in this routine. */
00096 
00097 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (3*N) */
00098 
00099 /*  IWORK   (workspace) INTEGER array, dimension (N) */
00100 
00101 /*  INFO    (output) INTEGER */
00102 /*          = 0:  successful exit */
00103 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00104 
00105 /*  ===================================================================== */
00106 
00107 /*     .. Parameters .. */
00108 /*     .. */
00109 /*     .. Local Scalars .. */
00110 /*     .. */
00111 /*     .. Local Arrays .. */
00112 /*     .. */
00113 /*     .. External Functions .. */
00114 /*     .. */
00115 /*     .. External Subroutines .. */
00116 /*     .. */
00117 /*     .. Intrinsic Functions .. */
00118 /*     .. */
00119 /*     .. Executable Statements .. */
00120 
00121 /*     Test the input parameters. */
00122 
00123     /* Parameter adjustments */
00124     a_dim1 = *lda;
00125     a_offset = 1 + a_dim1;
00126     a -= a_offset;
00127     --work;
00128     --iwork;
00129 
00130     /* Function Body */
00131     *info = 0;
00132     upper = lsame_(uplo, "U");
00133     if (! upper && ! lsame_(uplo, "L")) {
00134         *info = -1;
00135     } else if (*n < 0) {
00136         *info = -2;
00137     } else if (*lda < max(1,*n)) {
00138         *info = -4;
00139     } else if (*anorm < 0.) {
00140         *info = -5;
00141     }
00142     if (*info != 0) {
00143         i__1 = -(*info);
00144         xerbla_("DPOCON", &i__1);
00145         return 0;
00146     }
00147 
00148 /*     Quick return if possible */
00149 
00150     *rcond = 0.;
00151     if (*n == 0) {
00152         *rcond = 1.;
00153         return 0;
00154     } else if (*anorm == 0.) {
00155         return 0;
00156     }
00157 
00158     smlnum = dlamch_("Safe minimum");
00159 
00160 /*     Estimate the 1-norm of inv(A). */
00161 
00162     kase = 0;
00163     *(unsigned char *)normin = 'N';
00164 L10:
00165     dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00166     if (kase != 0) {
00167         if (upper) {
00168 
00169 /*           Multiply by inv(U'). */
00170 
00171             dlatrs_("Upper", "Transpose", "Non-unit", normin, n, &a[a_offset], 
00172                      lda, &work[1], &scalel, &work[(*n << 1) + 1], info);
00173             *(unsigned char *)normin = 'Y';
00174 
00175 /*           Multiply by inv(U). */
00176 
00177             dlatrs_("Upper", "No transpose", "Non-unit", normin, n, &a[
00178                     a_offset], lda, &work[1], &scaleu, &work[(*n << 1) + 1], 
00179                     info);
00180         } else {
00181 
00182 /*           Multiply by inv(L). */
00183 
00184             dlatrs_("Lower", "No transpose", "Non-unit", normin, n, &a[
00185                     a_offset], lda, &work[1], &scalel, &work[(*n << 1) + 1], 
00186                     info);
00187             *(unsigned char *)normin = 'Y';
00188 
00189 /*           Multiply by inv(L'). */
00190 
00191             dlatrs_("Lower", "Transpose", "Non-unit", normin, n, &a[a_offset], 
00192                      lda, &work[1], &scaleu, &work[(*n << 1) + 1], info);
00193         }
00194 
00195 /*        Multiply by 1/SCALE if doing so will not cause overflow. */
00196 
00197         scale = scalel * scaleu;
00198         if (scale != 1.) {
00199             ix = idamax_(n, &work[1], &c__1);
00200             if (scale < (d__1 = work[ix], abs(d__1)) * smlnum || scale == 0.) 
00201                     {
00202                 goto L20;
00203             }
00204             drscl_(n, &scale, &work[1], &c__1);
00205         }
00206         goto L10;
00207     }
00208 
00209 /*     Compute the estimate of the reciprocal condition number. */
00210 
00211     if (ainvnm != 0.) {
00212         *rcond = 1. / ainvnm / *anorm;
00213     }
00214 
00215 L20:
00216     return 0;
00217 
00218 /*     End of DPOCON */
00219 
00220 } /* dpocon_ */


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