dgecon.c
Go to the documentation of this file.
00001 /* dgecon.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 dgecon_(char *norm, 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     doublereal sl;
00030     integer ix;
00031     doublereal su;
00032     integer kase, kase1;
00033     doublereal scale;
00034     extern logical lsame_(char *, char *);
00035     integer isave[3];
00036     extern /* Subroutine */ int drscl_(integer *, doublereal *, doublereal *, 
00037             integer *), dlacn2_(integer *, doublereal *, doublereal *, 
00038             integer *, doublereal *, integer *, integer *);
00039     extern doublereal dlamch_(char *);
00040     extern integer idamax_(integer *, doublereal *, integer *);
00041     extern /* Subroutine */ int xerbla_(char *, integer *);
00042     doublereal ainvnm;
00043     extern /* Subroutine */ int dlatrs_(char *, char *, char *, char *, 
00044             integer *, doublereal *, integer *, doublereal *, doublereal *, 
00045             doublereal *, integer *);
00046     logical onenrm;
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 /*  DGECON estimates the reciprocal of the condition number of a general */
00066 /*  real matrix A, in either the 1-norm or the infinity-norm, using */
00067 /*  the LU factorization computed by DGETRF. */
00068 
00069 /*  An estimate is obtained for norm(inv(A)), and the reciprocal of the */
00070 /*  condition number is computed as */
00071 /*     RCOND = 1 / ( norm(A) * norm(inv(A)) ). */
00072 
00073 /*  Arguments */
00074 /*  ========= */
00075 
00076 /*  NORM    (input) CHARACTER*1 */
00077 /*          Specifies whether the 1-norm condition number or the */
00078 /*          infinity-norm condition number is required: */
00079 /*          = '1' or 'O':  1-norm; */
00080 /*          = 'I':         Infinity-norm. */
00081 
00082 /*  N       (input) INTEGER */
00083 /*          The order of the matrix A.  N >= 0. */
00084 
00085 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00086 /*          The factors L and U from the factorization A = P*L*U */
00087 /*          as computed by DGETRF. */
00088 
00089 /*  LDA     (input) INTEGER */
00090 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00091 
00092 /*  ANORM   (input) DOUBLE PRECISION */
00093 /*          If NORM = '1' or 'O', the 1-norm of the original matrix A. */
00094 /*          If NORM = 'I', the infinity-norm of the original matrix A. */
00095 
00096 /*  RCOND   (output) DOUBLE PRECISION */
00097 /*          The reciprocal of the condition number of the matrix A, */
00098 /*          computed as RCOND = 1/(norm(A) * norm(inv(A))). */
00099 
00100 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (4*N) */
00101 
00102 /*  IWORK   (workspace) INTEGER array, dimension (N) */
00103 
00104 /*  INFO    (output) INTEGER */
00105 /*          = 0:  successful exit */
00106 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00107 
00108 /*  ===================================================================== */
00109 
00110 /*     .. Parameters .. */
00111 /*     .. */
00112 /*     .. Local Scalars .. */
00113 /*     .. */
00114 /*     .. Local Arrays .. */
00115 /*     .. */
00116 /*     .. External Functions .. */
00117 /*     .. */
00118 /*     .. External Subroutines .. */
00119 /*     .. */
00120 /*     .. Intrinsic Functions .. */
00121 /*     .. */
00122 /*     .. Executable Statements .. */
00123 
00124 /*     Test the input parameters. */
00125 
00126     /* Parameter adjustments */
00127     a_dim1 = *lda;
00128     a_offset = 1 + a_dim1;
00129     a -= a_offset;
00130     --work;
00131     --iwork;
00132 
00133     /* Function Body */
00134     *info = 0;
00135     onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O");
00136     if (! onenrm && ! lsame_(norm, "I")) {
00137         *info = -1;
00138     } else if (*n < 0) {
00139         *info = -2;
00140     } else if (*lda < max(1,*n)) {
00141         *info = -4;
00142     } else if (*anorm < 0.) {
00143         *info = -5;
00144     }
00145     if (*info != 0) {
00146         i__1 = -(*info);
00147         xerbla_("DGECON", &i__1);
00148         return 0;
00149     }
00150 
00151 /*     Quick return if possible */
00152 
00153     *rcond = 0.;
00154     if (*n == 0) {
00155         *rcond = 1.;
00156         return 0;
00157     } else if (*anorm == 0.) {
00158         return 0;
00159     }
00160 
00161     smlnum = dlamch_("Safe minimum");
00162 
00163 /*     Estimate the norm of inv(A). */
00164 
00165     ainvnm = 0.;
00166     *(unsigned char *)normin = 'N';
00167     if (onenrm) {
00168         kase1 = 1;
00169     } else {
00170         kase1 = 2;
00171     }
00172     kase = 0;
00173 L10:
00174     dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00175     if (kase != 0) {
00176         if (kase == kase1) {
00177 
00178 /*           Multiply by inv(L). */
00179 
00180             dlatrs_("Lower", "No transpose", "Unit", normin, n, &a[a_offset], 
00181                     lda, &work[1], &sl, &work[(*n << 1) + 1], info);
00182 
00183 /*           Multiply by inv(U). */
00184 
00185             dlatrs_("Upper", "No transpose", "Non-unit", normin, n, &a[
00186                     a_offset], lda, &work[1], &su, &work[*n * 3 + 1], info);
00187         } else {
00188 
00189 /*           Multiply by inv(U'). */
00190 
00191             dlatrs_("Upper", "Transpose", "Non-unit", normin, n, &a[a_offset], 
00192                      lda, &work[1], &su, &work[*n * 3 + 1], info);
00193 
00194 /*           Multiply by inv(L'). */
00195 
00196             dlatrs_("Lower", "Transpose", "Unit", normin, n, &a[a_offset], 
00197                     lda, &work[1], &sl, &work[(*n << 1) + 1], info);
00198         }
00199 
00200 /*        Divide X by 1/(SL*SU) if doing so will not cause overflow. */
00201 
00202         scale = sl * su;
00203         *(unsigned char *)normin = 'Y';
00204         if (scale != 1.) {
00205             ix = idamax_(n, &work[1], &c__1);
00206             if (scale < (d__1 = work[ix], abs(d__1)) * smlnum || scale == 0.) 
00207                     {
00208                 goto L20;
00209             }
00210             drscl_(n, &scale, &work[1], &c__1);
00211         }
00212         goto L10;
00213     }
00214 
00215 /*     Compute the estimate of the reciprocal condition number. */
00216 
00217     if (ainvnm != 0.) {
00218         *rcond = 1. / ainvnm / *anorm;
00219     }
00220 
00221 L20:
00222     return 0;
00223 
00224 /*     End of DGECON */
00225 
00226 } /* dgecon_ */


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