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


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