dla_syrcond.c
Go to the documentation of this file.
00001 /* dla_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 dla_syrcond__(char *uplo, 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 uplo_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     logical up;
00032     doublereal tmp;
00033     integer kase;
00034     extern logical lsame_(char *, char *);
00035     integer isave[3];
00036     extern /* Subroutine */ int dlacn2_(integer *, doublereal *, doublereal *, 
00037              integer *, doublereal *, integer *, integer *);
00038     extern doublereal dlamch_(char *);
00039     extern /* Subroutine */ int xerbla_(char *, integer *);
00040     doublereal ainvnm;
00041     char normin[1];
00042     doublereal smlnum;
00043     extern /* Subroutine */ int dsytrs_(char *, integer *, integer *, 
00044             doublereal *, integer *, integer *, doublereal *, integer *, 
00045             integer *);
00046 
00047 
00048 /*     -- LAPACK routine (version 3.2.1)                                 -- */
00049 /*     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
00050 /*     -- Jason Riedy of Univ. of California Berkeley.                 -- */
00051 /*     -- April 2009                                                   -- */
00052 
00053 /*     -- LAPACK is a software package provided by Univ. of Tennessee, -- */
00054 /*     -- Univ. of California Berkeley and NAG Ltd.                    -- */
00055 
00056 /*     .. */
00057 /*     .. Scalar Arguments .. */
00058 /*     .. */
00059 /*     .. Array Arguments */
00060 /*     .. */
00061 
00062 /*  Purpose */
00063 /*  ======= */
00064 
00065 /*     DLA_SYRCOND estimates the Skeel condition number of  op(A) * op2(C) */
00066 /*     where op2 is determined by CMODE as follows */
00067 /*     CMODE =  1    op2(C) = C */
00068 /*     CMODE =  0    op2(C) = I */
00069 /*     CMODE = -1    op2(C) = inv(C) */
00070 /*     The Skeel condition number cond(A) = norminf( |inv(A)||A| ) */
00071 /*     is computed by computing scaling factors R such that */
00072 /*     diag(R)*A*op2(C) is row equilibrated and computing the standard */
00073 /*     infinity-norm condition number. */
00074 
00075 /*  Arguments */
00076 /*  ========== */
00077 
00078 /*     UPLO    (input) CHARACTER*1 */
00079 /*       = 'U':  Upper triangle of A is stored; */
00080 /*       = 'L':  Lower triangle of A is stored. */
00081 
00082 /*     N       (input) INTEGER */
00083 /*     The number of linear equations, i.e., the order of the */
00084 /*     matrix A.  N >= 0. */
00085 
00086 /*     A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00087 /*     On entry, the N-by-N matrix A. */
00088 
00089 /*     LDA     (input) INTEGER */
00090 /*     The leading dimension of the array A.  LDA >= max(1,N). */
00091 
00092 /*     AF      (input) DOUBLE PRECISION array, dimension (LDAF,N) */
00093 /*     The block diagonal matrix D and the multipliers used to */
00094 /*     obtain the factor U or L as computed by DSYTRF. */
00095 
00096 /*     LDAF    (input) INTEGER */
00097 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00098 
00099 /*     IPIV    (input) INTEGER array, dimension (N) */
00100 /*     Details of the interchanges and the block structure of D */
00101 /*     as determined by DSYTRF. */
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     if (*n < 0) {
00153         *info = -2;
00154     }
00155     if (*info != 0) {
00156         i__1 = -(*info);
00157         xerbla_("DLA_SYRCOND", &i__1);
00158         return ret_val;
00159     }
00160     if (*n == 0) {
00161         ret_val = 1.;
00162         return ret_val;
00163     }
00164     up = FALSE_;
00165     if (lsame_(uplo, "U")) {
00166         up = TRUE_;
00167     }
00168 
00169 /*     Compute the equilibration matrix R such that */
00170 /*     inv(R)*A*C has unit 1-norm. */
00171 
00172     if (up) {
00173         i__1 = *n;
00174         for (i__ = 1; i__ <= i__1; ++i__) {
00175             tmp = 0.;
00176             if (*cmode == 1) {
00177                 i__2 = i__;
00178                 for (j = 1; j <= i__2; ++j) {
00179                     tmp += (d__1 = a[j + i__ * a_dim1] * c__[j], abs(d__1));
00180                 }
00181                 i__2 = *n;
00182                 for (j = i__ + 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 = i__;
00187                 for (j = 1; j <= i__2; ++j) {
00188                     tmp += (d__1 = a[j + i__ * a_dim1], abs(d__1));
00189                 }
00190                 i__2 = *n;
00191                 for (j = i__ + 1; j <= i__2; ++j) {
00192                     tmp += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00193                 }
00194             } else {
00195                 i__2 = i__;
00196                 for (j = 1; j <= i__2; ++j) {
00197                     tmp += (d__1 = a[j + i__ * a_dim1] / c__[j], abs(d__1));
00198                 }
00199                 i__2 = *n;
00200                 for (j = i__ + 1; j <= i__2; ++j) {
00201                     tmp += (d__1 = a[i__ + j * a_dim1] / c__[j], abs(d__1));
00202                 }
00203             }
00204             work[(*n << 1) + i__] = tmp;
00205         }
00206     } else {
00207         i__1 = *n;
00208         for (i__ = 1; i__ <= i__1; ++i__) {
00209             tmp = 0.;
00210             if (*cmode == 1) {
00211                 i__2 = i__;
00212                 for (j = 1; j <= i__2; ++j) {
00213                     tmp += (d__1 = a[i__ + j * a_dim1] * c__[j], abs(d__1));
00214                 }
00215                 i__2 = *n;
00216                 for (j = i__ + 1; j <= i__2; ++j) {
00217                     tmp += (d__1 = a[j + i__ * a_dim1] * c__[j], abs(d__1));
00218                 }
00219             } else if (*cmode == 0) {
00220                 i__2 = i__;
00221                 for (j = 1; j <= i__2; ++j) {
00222                     tmp += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00223                 }
00224                 i__2 = *n;
00225                 for (j = i__ + 1; j <= i__2; ++j) {
00226                     tmp += (d__1 = a[j + i__ * a_dim1], abs(d__1));
00227                 }
00228             } else {
00229                 i__2 = i__;
00230                 for (j = 1; j <= i__2; ++j) {
00231                     tmp += (d__1 = a[i__ + j * a_dim1] / c__[j], abs(d__1));
00232                 }
00233                 i__2 = *n;
00234                 for (j = i__ + 1; j <= i__2; ++j) {
00235                     tmp += (d__1 = a[j + i__ * a_dim1] / c__[j], abs(d__1));
00236                 }
00237             }
00238             work[(*n << 1) + i__] = tmp;
00239         }
00240     }
00241 
00242 /*     Estimate the norm of inv(op(A)). */
00243 
00244     smlnum = dlamch_("Safe minimum");
00245     ainvnm = 0.;
00246     *(unsigned char *)normin = 'N';
00247     kase = 0;
00248 L10:
00249     dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00250     if (kase != 0) {
00251         if (kase == 2) {
00252 
00253 /*           Multiply by R. */
00254 
00255             i__1 = *n;
00256             for (i__ = 1; i__ <= i__1; ++i__) {
00257                 work[i__] *= work[(*n << 1) + i__];
00258             }
00259             if (up) {
00260                 dsytrs_("U", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00261                         1], n, info);
00262             } else {
00263                 dsytrs_("L", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00264                         1], n, info);
00265             }
00266 
00267 /*           Multiply by inv(C). */
00268 
00269             if (*cmode == 1) {
00270                 i__1 = *n;
00271                 for (i__ = 1; i__ <= i__1; ++i__) {
00272                     work[i__] /= c__[i__];
00273                 }
00274             } else if (*cmode == -1) {
00275                 i__1 = *n;
00276                 for (i__ = 1; i__ <= i__1; ++i__) {
00277                     work[i__] *= c__[i__];
00278                 }
00279             }
00280         } else {
00281 
00282 /*           Multiply by inv(C'). */
00283 
00284             if (*cmode == 1) {
00285                 i__1 = *n;
00286                 for (i__ = 1; i__ <= i__1; ++i__) {
00287                     work[i__] /= c__[i__];
00288                 }
00289             } else if (*cmode == -1) {
00290                 i__1 = *n;
00291                 for (i__ = 1; i__ <= i__1; ++i__) {
00292                     work[i__] *= c__[i__];
00293                 }
00294             }
00295             if (up) {
00296                 dsytrs_("U", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00297                         1], n, info);
00298             } else {
00299                 dsytrs_("L", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00300                         1], n, info);
00301             }
00302 
00303 /*           Multiply by R. */
00304 
00305             i__1 = *n;
00306             for (i__ = 1; i__ <= i__1; ++i__) {
00307                 work[i__] *= work[(*n << 1) + i__];
00308             }
00309         }
00310 
00311         goto L10;
00312     }
00313 
00314 /*     Compute the estimate of the reciprocal condition number. */
00315 
00316     if (ainvnm != 0.) {
00317         ret_val = 1. / ainvnm;
00318     }
00319 
00320     return ret_val;
00321 
00322 } /* dla_syrcond__ */


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