zla_gercond_x.c
Go to the documentation of this file.
00001 /* zla_gercond_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_gercond_x__(char *trans, integer *n, doublecomplex *a, integer 
00021         *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *
00022         x, integer *info, doublecomplex *work, doublereal *rwork, ftnlen 
00023         trans_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     doublereal tmp;
00037     integer kase;
00038     extern logical lsame_(char *, char *);
00039     integer isave[3];
00040     doublereal anorm;
00041     extern /* Subroutine */ int zlacn2_(integer *, doublecomplex *, 
00042             doublecomplex *, doublereal *, integer *, integer *), xerbla_(
00043             char *, integer *);
00044     doublereal ainvnm;
00045     extern /* Subroutine */ int zgetrs_(char *, integer *, integer *, 
00046             doublecomplex *, integer *, integer *, doublecomplex *, integer *, 
00047              integer *);
00048     logical notrans;
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_GERCOND_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 /*     TRANS   (input) CHARACTER*1 */
00075 /*     Specifies the form of the system of equations: */
00076 /*       = 'N':  A * X = B     (No transpose) */
00077 /*       = 'T':  A**T * X = B  (Transpose) */
00078 /*       = 'C':  A**H * X = B  (Conjugate Transpose = Transpose) */
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) COMPLEX*16 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) COMPLEX*16 array, dimension (LDAF,N) */
00091 /*     The factors L and U from the factorization */
00092 /*     A = P*L*U as computed by ZGETRF. */
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 /*     The pivot indices from the factorization A = P*L*U */
00099 /*     as computed by ZGETRF; row i of the matrix was interchanged */
00100 /*     with row IPIV(i). */
00101 
00102 /*     X       (input) COMPLEX*16 array, dimension (N) */
00103 /*     The vector X in the formula op(A) * diag(X). */
00104 
00105 /*     INFO    (output) INTEGER */
00106 /*       = 0:  Successful exit. */
00107 /*     i > 0:  The ith argument is invalid. */
00108 
00109 /*     WORK    (input) COMPLEX*16 array, dimension (2*N). */
00110 /*     Workspace. */
00111 
00112 /*     RWORK   (input) DOUBLE PRECISION array, dimension (N). */
00113 /*     Workspace. */
00114 
00115 /*  ===================================================================== */
00116 
00117 /*     .. Local Scalars .. */
00118 /*     .. */
00119 /*     .. Local Arrays .. */
00120 /*     .. */
00121 /*     .. External Functions .. */
00122 /*     .. */
00123 /*     .. External Subroutines .. */
00124 /*     .. */
00125 /*     .. Intrinsic Functions .. */
00126 /*     .. */
00127 /*     .. Statement Functions .. */
00128 /*     .. */
00129 /*     .. Statement Function Definitions .. */
00130 /*     .. */
00131 /*     .. Executable Statements .. */
00132 
00133     /* Parameter adjustments */
00134     a_dim1 = *lda;
00135     a_offset = 1 + a_dim1;
00136     a -= a_offset;
00137     af_dim1 = *ldaf;
00138     af_offset = 1 + af_dim1;
00139     af -= af_offset;
00140     --ipiv;
00141     --x;
00142     --work;
00143     --rwork;
00144 
00145     /* Function Body */
00146     ret_val = 0.;
00147 
00148     *info = 0;
00149     notrans = lsame_(trans, "N");
00150     if (! notrans && ! lsame_(trans, "T") && ! lsame_(
00151             trans, "C")) {
00152         *info = -1;
00153     } else if (*n < 0) {
00154         *info = -2;
00155     }
00156     if (*info != 0) {
00157         i__1 = -(*info);
00158         xerbla_("ZLA_GERCOND_X", &i__1);
00159         return ret_val;
00160     }
00161 
00162 /*     Compute norm of op(A)*op2(C). */
00163 
00164     anorm = 0.;
00165     if (notrans) {
00166         i__1 = *n;
00167         for (i__ = 1; i__ <= i__1; ++i__) {
00168             tmp = 0.;
00169             i__2 = *n;
00170             for (j = 1; j <= i__2; ++j) {
00171                 i__3 = i__ + j * a_dim1;
00172                 i__4 = j;
00173                 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00174                         z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00175                         .r;
00176                 z__1.r = z__2.r, z__1.i = z__2.i;
00177                 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1), 
00178                         abs(d__2));
00179             }
00180             rwork[i__] = tmp;
00181             anorm = max(anorm,tmp);
00182         }
00183     } else {
00184         i__1 = *n;
00185         for (i__ = 1; i__ <= i__1; ++i__) {
00186             tmp = 0.;
00187             i__2 = *n;
00188             for (j = 1; j <= i__2; ++j) {
00189                 i__3 = j + i__ * a_dim1;
00190                 i__4 = j;
00191                 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00192                         z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00193                         .r;
00194                 z__1.r = z__2.r, z__1.i = z__2.i;
00195                 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1), 
00196                         abs(d__2));
00197             }
00198             rwork[i__] = tmp;
00199             anorm = max(anorm,tmp);
00200         }
00201     }
00202 
00203 /*     Quick return if possible. */
00204 
00205     if (*n == 0) {
00206         ret_val = 1.;
00207         return ret_val;
00208     } else if (anorm == 0.) {
00209         return ret_val;
00210     }
00211 
00212 /*     Estimate the norm of inv(op(A)). */
00213 
00214     ainvnm = 0.;
00215 
00216     kase = 0;
00217 L10:
00218     zlacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00219     if (kase != 0) {
00220         if (kase == 2) {
00221 /*           Multiply by R. */
00222             i__1 = *n;
00223             for (i__ = 1; i__ <= i__1; ++i__) {
00224                 i__2 = i__;
00225                 i__3 = i__;
00226                 i__4 = i__;
00227                 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] * 
00228                         work[i__3].i;
00229                 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00230             }
00231 
00232             if (notrans) {
00233                 zgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00234                         1], &work[1], n, info);
00235             } else {
00236                 zgetrs_("Conjugate transpose", n, &c__1, &af[af_offset], ldaf, 
00237                          &ipiv[1], &work[1], n, info);
00238             }
00239 
00240 /*           Multiply by inv(X). */
00241 
00242             i__1 = *n;
00243             for (i__ = 1; i__ <= i__1; ++i__) {
00244                 i__2 = i__;
00245                 z_div(&z__1, &work[i__], &x[i__]);
00246                 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00247             }
00248         } else {
00249 
00250 /*           Multiply by inv(X'). */
00251 
00252             i__1 = *n;
00253             for (i__ = 1; i__ <= i__1; ++i__) {
00254                 i__2 = i__;
00255                 z_div(&z__1, &work[i__], &x[i__]);
00256                 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00257             }
00258 
00259             if (notrans) {
00260                 zgetrs_("Conjugate transpose", n, &c__1, &af[af_offset], ldaf, 
00261                          &ipiv[1], &work[1], n, info);
00262             } else {
00263                 zgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00264                         1], &work[1], n, info);
00265             }
00266 
00267 /*           Multiply by R. */
00268 
00269             i__1 = *n;
00270             for (i__ = 1; i__ <= i__1; ++i__) {
00271                 i__2 = i__;
00272                 i__3 = i__;
00273                 i__4 = i__;
00274                 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] * 
00275                         work[i__3].i;
00276                 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00277             }
00278         }
00279         goto L10;
00280     }
00281 
00282 /*     Compute the estimate of the reciprocal condition number. */
00283 
00284     if (ainvnm != 0.) {
00285         ret_val = 1. / ainvnm;
00286     }
00287 
00288     return ret_val;
00289 
00290 } /* zla_gercond_x__ */


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