Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

dgecon.c

Go to the documentation of this file.
00001 /* DGECON.F -- translated by f2c (version 19941215).
00002    You must link the resulting object file with the libraries:
00003         -lf2c -lm   (in that order)
00004 */
00005 
00006 #include "f2c.h"
00007 
00008 /* Table of constant values */
00009 
00010 static integer c__1 = 1;
00011 
00012 /* Subroutine */ int dgecon_(norm, n, a, lda, anorm, rcond, work, iwork, info,
00013          norm_len)
00014 char *norm;
00015 integer *n;
00016 doublereal *a;
00017 integer *lda;
00018 doublereal *anorm, *rcond, *work;
00019 integer *iwork, *info;
00020 ftnlen norm_len;
00021 {
00022     /* System generated locals */
00023     integer a_dim1, a_offset, i__1;
00024     doublereal d__1;
00025 
00026     /* Local variables */
00027     static integer kase, kase1;
00028     static doublereal scale;
00029     extern logical lsame_();
00030     extern /* Subroutine */ int drscl_();
00031     extern doublereal dlamch_();
00032     static doublereal sl;
00033     static integer ix;
00034     extern /* Subroutine */ int dlacon_();
00035     extern integer idamax_();
00036     static doublereal su;
00037     extern /* Subroutine */ int xerbla_();
00038     static doublereal ainvnm;
00039     extern /* Subroutine */ int dlatrs_();
00040     static logical onenrm;
00041     static char normin[1];
00042     static doublereal smlnum;
00043 
00044 
00045 /*  -- LAPACK routine (version 1.1) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
00047 /*     Courant Institute, Argonne National Lab, and Rice University */
00048 /*     February 29, 1992 */
00049 
00050 /*     .. Scalar Arguments .. */
00051 /*     .. */
00052 /*     .. Array Arguments .. */
00053 /*     .. */
00054 
00055 /*  Purpose */
00056 /*  ======= */
00057 
00058 /*  DGECON estimates the reciprocal of the condition number of a general 
00059 */
00060 /*  real matrix A, in either the 1-norm or the infinity-norm, using */
00061 /*  the LU factorization computed by DGETRF. */
00062 
00063 /*  An estimate is obtained for norm(inv(A)), and the reciprocal of the */
00064 /*  condition number is computed as */
00065 /*     RCOND = 1 / ( norm(A) * norm(inv(A)) ). */
00066 
00067 /*  Arguments */
00068 /*  ========= */
00069 
00070 /*  NORM    (input) CHARACTER*1 */
00071 /*          Specifies whether the 1-norm condition number or the */
00072 /*          infinity-norm condition number is required: */
00073 /*          = '1' or 'O':  1-norm; */
00074 /*          = 'I':         Infinity-norm. */
00075 
00076 /*  N       (input) INTEGER */
00077 /*          The order of the matrix A.  N >= 0. */
00078 
00079 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00080 /*          The factors L and U from the factorization A = P*L*U */
00081 /*          as computed by DGETRF. */
00082 
00083 /*  LDA     (input) INTEGER */
00084 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00085 
00086 /*  ANORM   (input) DOUBLE PRECISION */
00087 /*          If NORM = '1' or 'O', the 1-norm of the original matrix A. */
00088 /*          If NORM = 'I', the infinity-norm of the original matrix A. */
00089 
00090 /*  RCOND   (output) DOUBLE PRECISION */
00091 /*          The reciprocal of the condition number of the matrix A, */
00092 /*          computed as RCOND = 1/(norm(A) * norm(inv(A))). */
00093 
00094 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (4*N) */
00095 
00096 /*  IWORK   (workspace) INTEGER array, dimension (N) */
00097 
00098 /*  INFO    (output) INTEGER */
00099 /*          = 0:  successful exit */
00100 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00101 
00102 /*  ===================================================================== 
00103 */
00104 
00105 /*     .. Parameters .. */
00106 /*     .. */
00107 /*     .. Local Scalars .. */
00108 /*     .. */
00109 /*     .. External Functions .. */
00110 /*     .. */
00111 /*     .. External Subroutines .. */
00112 /*     .. */
00113 /*     .. Intrinsic Functions .. */
00114 /*     .. */
00115 /*     .. Executable Statements .. */
00116 
00117 /*     Test the input parameters. */
00118 
00119     /* Parameter adjustments */
00120     a_dim1 = *lda;
00121     a_offset = a_dim1 + 1;
00122     a -= a_offset;
00123     --work;
00124     --iwork;
00125 
00126     /* Function Body */
00127     *info = 0;
00128     onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O", 1L, 1L);
00129     if (! onenrm && ! lsame_(norm, "I", 1L, 1L)) {
00130         *info = -1;
00131     } else if (*n < 0) {
00132         *info = -2;
00133     } else if (*lda < max(1,*n)) {
00134         *info = -4;
00135     } else if (*anorm < 0.) {
00136         *info = -5;
00137     }
00138     if (*info != 0) {
00139         i__1 = -(*info);
00140         xerbla_("DGECON", &i__1, 6L);
00141         return 0;
00142     }
00143 
00144 /*     Quick return if possible */
00145 
00146     *rcond = 0.;
00147     if (*n == 0) {
00148         *rcond = 1.;
00149         return 0;
00150     } else if (*anorm == 0.) {
00151         return 0;
00152     }
00153 
00154     smlnum = dlamch_("Safe minimum", 12L);
00155 
00156 /*     Estimate the norm of inv(A). */
00157 
00158     ainvnm = 0.;
00159     *(unsigned char *)normin = 'N';
00160     if (onenrm) {
00161         kase1 = 1;
00162     } else {
00163         kase1 = 2;
00164     }
00165     kase = 0;
00166 L10:
00167     dlacon_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase);
00168     if (kase != 0) {
00169         if (kase == kase1) {
00170 
00171 /*           Multiply by inv(L). */
00172 
00173             dlatrs_("Lower", "No transpose", "Unit", normin, n, &a[a_offset], 
00174                     lda, &work[1], &sl, &work[(*n << 1) + 1], info, 5L, 12L, 
00175                     4L, 1L);
00176 
00177 /*           Multiply by inv(U). */
00178 
00179             dlatrs_("Upper", "No transpose", "Non-unit", normin, n, &a[
00180                     a_offset], lda, &work[1], &su, &work[*n * 3 + 1], info, 
00181                     5L, 12L, 8L, 1L);
00182         } else {
00183 
00184 /*           Multiply by inv(U'). */
00185 
00186             dlatrs_("Upper", "Transpose", "Non-unit", normin, n, &a[a_offset],
00187                      lda, &work[1], &su, &work[*n * 3 + 1], info, 5L, 9L, 8L, 
00188                     1L);
00189 
00190 /*           Multiply by inv(L'). */
00191 
00192             dlatrs_("Lower", "Transpose", "Unit", normin, n, &a[a_offset], 
00193                     lda, &work[1], &sl, &work[(*n << 1) + 1], info, 5L, 9L, 
00194                     4L, 1L);
00195         }
00196 
00197 /*        Divide X by 1/(SL*SU) if doing so will not cause overflow. 
00198 */
00199 
00200         scale = sl * su;
00201         *(unsigned char *)normin = 'Y';
00202         if (scale != 1.) {
00203             ix = idamax_(n, &work[1], &c__1);
00204             if (scale < (d__1 = work[ix], abs(d__1)) * smlnum || scale == 0.) 
00205                     {
00206                 goto L20;
00207             }
00208             drscl_(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.) {
00216         *rcond = 1. / ainvnm / *anorm;
00217     }
00218 
00219 L20:
00220     return 0;
00221 
00222 /*     End of DGECON */
00223 
00224 } /* dgecon_ */
00225 

Generated on Wed Sep 5 12:54:19 2007 for DSACSS Operational Code by  doxygen 1.3.9.1