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


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