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


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