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


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