dla_gercond.c
Go to the documentation of this file.
00001 /* dla_gercond.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 doublereal dla_gercond__(char *trans, integer *n, doublereal *a, integer *lda,
00021          doublereal *af, integer *ldaf, integer *ipiv, integer *cmode, 
00022         doublereal *c__, integer *info, doublereal *work, integer *iwork, 
00023         ftnlen trans_len)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, af_dim1, af_offset, i__1, i__2;
00027     doublereal ret_val, d__1;
00028 
00029     /* Local variables */
00030     integer i__, j;
00031     doublereal tmp;
00032     integer kase;
00033     extern logical lsame_(char *, char *);
00034     integer isave[3];
00035     extern /* Subroutine */ int dlacn2_(integer *, doublereal *, doublereal *, 
00036              integer *, doublereal *, integer *, integer *), xerbla_(char *, 
00037             integer *);
00038     doublereal ainvnm;
00039     extern /* Subroutine */ int dgetrs_(char *, integer *, integer *, 
00040             doublereal *, integer *, integer *, doublereal *, integer *, 
00041             integer *);
00042     logical notrans;
00043 
00044 
00045 /*     -- LAPACK routine (version 3.2.1)                                 -- */
00046 /*     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
00047 /*     -- Jason Riedy of Univ. of California Berkeley.                 -- */
00048 /*     -- April 2009                                                   -- */
00049 
00050 /*     -- LAPACK is a software package provided by Univ. of Tennessee, -- */
00051 /*     -- Univ. of California Berkeley and NAG Ltd.                    -- */
00052 
00053 /*     .. */
00054 /*     .. Scalar Arguments .. */
00055 /*     .. */
00056 /*     .. Array Arguments .. */
00057 /*     .. */
00058 
00059 /*  Purpose */
00060 /*  ======= */
00061 
00062 /*     DLA_GERCOND estimates the Skeel condition number of op(A) * op2(C) */
00063 /*     where op2 is determined by CMODE as follows */
00064 /*     CMODE =  1    op2(C) = C */
00065 /*     CMODE =  0    op2(C) = I */
00066 /*     CMODE = -1    op2(C) = inv(C) */
00067 /*     The Skeel condition number cond(A) = norminf( |inv(A)||A| ) */
00068 /*     is computed by computing scaling factors R such that */
00069 /*     diag(R)*A*op2(C) is row equilibrated and computing the standard */
00070 /*     infinity-norm condition number. */
00071 
00072 /*  Arguments */
00073 /*  ========== */
00074 
00075 /*     TRANS   (input) CHARACTER*1 */
00076 /*     Specifies the form of the system of equations: */
00077 /*       = 'N':  A * X = B     (No transpose) */
00078 /*       = 'T':  A**T * X = B  (Transpose) */
00079 /*       = 'C':  A**H * X = B  (Conjugate Transpose = Transpose) */
00080 
00081 /*     N       (input) INTEGER */
00082 /*     The number of linear equations, i.e., the order of the */
00083 /*     matrix A.  N >= 0. */
00084 
00085 /*     A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00086 /*     On entry, the N-by-N matrix A. */
00087 
00088 /*     LDA     (input) INTEGER */
00089 /*     The leading dimension of the array A.  LDA >= max(1,N). */
00090 
00091 /*     AF      (input) DOUBLE PRECISION array, dimension (LDAF,N) */
00092 /*     The factors L and U from the factorization */
00093 /*     A = P*L*U as computed by DGETRF. */
00094 
00095 /*     LDAF    (input) INTEGER */
00096 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00097 
00098 /*     IPIV    (input) INTEGER array, dimension (N) */
00099 /*     The pivot indices from the factorization A = P*L*U */
00100 /*     as computed by DGETRF; row i of the matrix was interchanged */
00101 /*     with row IPIV(i). */
00102 
00103 /*     CMODE   (input) INTEGER */
00104 /*     Determines op2(C) in the formula op(A) * op2(C) as follows: */
00105 /*     CMODE =  1    op2(C) = C */
00106 /*     CMODE =  0    op2(C) = I */
00107 /*     CMODE = -1    op2(C) = inv(C) */
00108 
00109 /*     C       (input) DOUBLE PRECISION array, dimension (N) */
00110 /*     The vector C in the formula op(A) * op2(C). */
00111 
00112 /*     INFO    (output) INTEGER */
00113 /*       = 0:  Successful exit. */
00114 /*     i > 0:  The ith argument is invalid. */
00115 
00116 /*     WORK    (input) DOUBLE PRECISION array, dimension (3*N). */
00117 /*     Workspace. */
00118 
00119 /*     IWORK   (input) INTEGER array, dimension (N). */
00120 /*     Workspace. */
00121 
00122 /*  ===================================================================== */
00123 
00124 /*     .. Local Scalars .. */
00125 /*     .. */
00126 /*     .. Local Arrays .. */
00127 /*     .. */
00128 /*     .. External Functions .. */
00129 /*     .. */
00130 /*     .. External Subroutines .. */
00131 /*     .. */
00132 /*     .. Intrinsic Functions .. */
00133 /*     .. */
00134 /*     .. Executable Statements .. */
00135 
00136     /* Parameter adjustments */
00137     a_dim1 = *lda;
00138     a_offset = 1 + a_dim1;
00139     a -= a_offset;
00140     af_dim1 = *ldaf;
00141     af_offset = 1 + af_dim1;
00142     af -= af_offset;
00143     --ipiv;
00144     --c__;
00145     --work;
00146     --iwork;
00147 
00148     /* Function Body */
00149     ret_val = 0.;
00150 
00151     *info = 0;
00152     notrans = lsame_(trans, "N");
00153     if (! notrans && ! lsame_(trans, "T") && ! lsame_(
00154             trans, "C")) {
00155         *info = -1;
00156     } else if (*n < 0) {
00157         *info = -2;
00158     } else if (*lda < max(1,*n)) {
00159         *info = -4;
00160     } else if (*ldaf < max(1,*n)) {
00161         *info = -6;
00162     }
00163     if (*info != 0) {
00164         i__1 = -(*info);
00165         xerbla_("DLA_GERCOND", &i__1);
00166         return ret_val;
00167     }
00168     if (*n == 0) {
00169         ret_val = 1.;
00170         return ret_val;
00171     }
00172 
00173 /*     Compute the equilibration matrix R such that */
00174 /*     inv(R)*A*C has unit 1-norm. */
00175 
00176     if (notrans) {
00177         i__1 = *n;
00178         for (i__ = 1; i__ <= i__1; ++i__) {
00179             tmp = 0.;
00180             if (*cmode == 1) {
00181                 i__2 = *n;
00182                 for (j = 1; j <= i__2; ++j) {
00183                     tmp += (d__1 = a[i__ + j * a_dim1] * c__[j], abs(d__1));
00184                 }
00185             } else if (*cmode == 0) {
00186                 i__2 = *n;
00187                 for (j = 1; j <= i__2; ++j) {
00188                     tmp += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00189                 }
00190             } else {
00191                 i__2 = *n;
00192                 for (j = 1; j <= i__2; ++j) {
00193                     tmp += (d__1 = a[i__ + j * a_dim1] / c__[j], abs(d__1));
00194                 }
00195             }
00196             work[(*n << 1) + i__] = tmp;
00197         }
00198     } else {
00199         i__1 = *n;
00200         for (i__ = 1; i__ <= i__1; ++i__) {
00201             tmp = 0.;
00202             if (*cmode == 1) {
00203                 i__2 = *n;
00204                 for (j = 1; j <= i__2; ++j) {
00205                     tmp += (d__1 = a[j + i__ * a_dim1] * c__[j], abs(d__1));
00206                 }
00207             } else if (*cmode == 0) {
00208                 i__2 = *n;
00209                 for (j = 1; j <= i__2; ++j) {
00210                     tmp += (d__1 = a[j + i__ * a_dim1], abs(d__1));
00211                 }
00212             } else {
00213                 i__2 = *n;
00214                 for (j = 1; j <= i__2; ++j) {
00215                     tmp += (d__1 = a[j + i__ * a_dim1] / c__[j], abs(d__1));
00216                 }
00217             }
00218             work[(*n << 1) + i__] = tmp;
00219         }
00220     }
00221 
00222 /*     Estimate the norm of inv(op(A)). */
00223 
00224     ainvnm = 0.;
00225     kase = 0;
00226 L10:
00227     dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00228     if (kase != 0) {
00229         if (kase == 2) {
00230 
00231 /*           Multiply by R. */
00232 
00233             i__1 = *n;
00234             for (i__ = 1; i__ <= i__1; ++i__) {
00235                 work[i__] *= work[(*n << 1) + i__];
00236             }
00237             if (notrans) {
00238                 dgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00239                         1], &work[1], n, info);
00240             } else {
00241                 dgetrs_("Transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[1], 
00242                          &work[1], n, info);
00243             }
00244 
00245 /*           Multiply by inv(C). */
00246 
00247             if (*cmode == 1) {
00248                 i__1 = *n;
00249                 for (i__ = 1; i__ <= i__1; ++i__) {
00250                     work[i__] /= c__[i__];
00251                 }
00252             } else if (*cmode == -1) {
00253                 i__1 = *n;
00254                 for (i__ = 1; i__ <= i__1; ++i__) {
00255                     work[i__] *= c__[i__];
00256                 }
00257             }
00258         } else {
00259 
00260 /*           Multiply by inv(C'). */
00261 
00262             if (*cmode == 1) {
00263                 i__1 = *n;
00264                 for (i__ = 1; i__ <= i__1; ++i__) {
00265                     work[i__] /= c__[i__];
00266                 }
00267             } else if (*cmode == -1) {
00268                 i__1 = *n;
00269                 for (i__ = 1; i__ <= i__1; ++i__) {
00270                     work[i__] *= c__[i__];
00271                 }
00272             }
00273             if (notrans) {
00274                 dgetrs_("Transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[1], 
00275                          &work[1], n, info);
00276             } else {
00277                 dgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00278                         1], &work[1], n, info);
00279             }
00280 
00281 /*           Multiply by R. */
00282 
00283             i__1 = *n;
00284             for (i__ = 1; i__ <= i__1; ++i__) {
00285                 work[i__] *= work[(*n << 1) + i__];
00286             }
00287         }
00288         goto L10;
00289     }
00290 
00291 /*     Compute the estimate of the reciprocal condition number. */
00292 
00293     if (ainvnm != 0.) {
00294         ret_val = 1. / ainvnm;
00295     }
00296 
00297     return ret_val;
00298 
00299 } /* dla_gercond__ */


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