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


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