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


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