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


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