zla_gercond_c.c
Go to the documentation of this file.
00001 /* zla_gercond_c.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_c__(char *trans, integer *n, doublecomplex *a, integer 
00021         *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *
00022         c__, logical *capply, integer *info, doublecomplex *work, doublereal *
00023         rwork, ftnlen 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;
00029 
00030     /* Builtin functions */
00031     double d_imag(doublecomplex *);
00032 
00033     /* Local variables */
00034     integer i__, j;
00035     doublereal tmp;
00036     integer kase;
00037     extern logical lsame_(char *, char *);
00038     integer isave[3];
00039     doublereal anorm;
00040     extern /* Subroutine */ int zlacn2_(integer *, doublecomplex *, 
00041             doublecomplex *, doublereal *, integer *, integer *), xerbla_(
00042             char *, integer *);
00043     doublereal ainvnm;
00044     extern /* Subroutine */ int zgetrs_(char *, integer *, integer *, 
00045             doublecomplex *, integer *, integer *, doublecomplex *, integer *, 
00046              integer *);
00047     logical notrans;
00048 
00049 
00050 /*     -- LAPACK routine (version 3.2.1)                                 -- */
00051 /*     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
00052 /*     -- Jason Riedy of Univ. of California Berkeley.                 -- */
00053 /*     -- April 2009                                                   -- */
00054 
00055 /*     -- LAPACK is a software package provided by Univ. of Tennessee, -- */
00056 /*     -- Univ. of California Berkeley and NAG Ltd.                    -- */
00057 
00058 /*     .. */
00059 /*     .. Scalar Aguments .. */
00060 /*     .. */
00061 /*     .. Array Arguments .. */
00062 /*     .. */
00063 
00064 /*  Purpose */
00065 /*  ======= */
00066 
00067 /*     ZLA_GERCOND_C computes the infinity norm condition number of */
00068 /*     op(A) * inv(diag(C)) where C is a DOUBLE PRECISION vector. */
00069 
00070 /*  Arguments */
00071 /*  ========= */
00072 
00073 /*     TRANS   (input) CHARACTER*1 */
00074 /*     Specifies the form of the system of equations: */
00075 /*       = 'N':  A * X = B     (No transpose) */
00076 /*       = 'T':  A**T * X = B  (Transpose) */
00077 /*       = 'C':  A**H * X = B  (Conjugate Transpose = Transpose) */
00078 
00079 /*     N       (input) INTEGER */
00080 /*     The number of linear equations, i.e., the order of the */
00081 /*     matrix A.  N >= 0. */
00082 
00083 /*     A       (input) COMPLEX*16 array, dimension (LDA,N) */
00084 /*     On entry, the N-by-N matrix A */
00085 
00086 /*     LDA     (input) INTEGER */
00087 /*     The leading dimension of the array A.  LDA >= max(1,N). */
00088 
00089 /*     AF      (input) COMPLEX*16 array, dimension (LDAF,N) */
00090 /*     The factors L and U from the factorization */
00091 /*     A = P*L*U as computed by ZGETRF. */
00092 
00093 /*     LDAF    (input) INTEGER */
00094 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00095 
00096 /*     IPIV    (input) INTEGER array, dimension (N) */
00097 /*     The pivot indices from the factorization A = P*L*U */
00098 /*     as computed by ZGETRF; row i of the matrix was interchanged */
00099 /*     with row IPIV(i). */
00100 
00101 /*     C       (input) DOUBLE PRECISION array, dimension (N) */
00102 /*     The vector C in the formula op(A) * inv(diag(C)). */
00103 
00104 /*     CAPPLY  (input) LOGICAL */
00105 /*     If .TRUE. then access the vector C in the formula above. */
00106 
00107 /*     INFO    (output) INTEGER */
00108 /*       = 0:  Successful exit. */
00109 /*     i > 0:  The ith argument is invalid. */
00110 
00111 /*     WORK    (input) COMPLEX*16 array, dimension (2*N). */
00112 /*     Workspace. */
00113 
00114 /*     RWORK   (input) DOUBLE PRECISION array, dimension (N). */
00115 /*     Workspace. */
00116 
00117 /*  ===================================================================== */
00118 
00119 /*     .. Local Scalars .. */
00120 /*     .. */
00121 /*     .. Local Arrays .. */
00122 /*     .. */
00123 /*     .. External Functions .. */
00124 /*     .. */
00125 /*     .. External Subroutines .. */
00126 /*     .. */
00127 /*     .. Intrinsic Functions .. */
00128 /*     .. */
00129 /*     .. Statement Functions .. */
00130 /*     .. */
00131 /*     .. Statement Function Definitions .. */
00132 /*     .. */
00133 /*     .. Executable Statements .. */
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     --rwork;
00145 
00146     /* Function Body */
00147     ret_val = 0.;
00148 
00149     *info = 0;
00150     notrans = lsame_(trans, "N");
00151     if (! notrans && ! lsame_(trans, "T") && ! lsame_(
00152             trans, "C")) {
00153     } else if (*n < 0) {
00154         *info = -2;
00155     }
00156     if (*info != 0) {
00157         i__1 = -(*info);
00158         xerbla_("ZLA_GERCOND_C", &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             if (*capply) {
00170                 i__2 = *n;
00171                 for (j = 1; j <= i__2; ++j) {
00172                     i__3 = i__ + j * a_dim1;
00173                     tmp += ((d__1 = a[i__3].r, abs(d__1)) + (d__2 = d_imag(&a[
00174                             i__ + j * a_dim1]), abs(d__2))) / c__[j];
00175                 }
00176             } else {
00177                 i__2 = *n;
00178                 for (j = 1; j <= i__2; ++j) {
00179                     i__3 = i__ + j * a_dim1;
00180                     tmp += (d__1 = a[i__3].r, abs(d__1)) + (d__2 = d_imag(&a[
00181                             i__ + j * a_dim1]), abs(d__2));
00182                 }
00183             }
00184             rwork[i__] = tmp;
00185             anorm = max(anorm,tmp);
00186         }
00187     } else {
00188         i__1 = *n;
00189         for (i__ = 1; i__ <= i__1; ++i__) {
00190             tmp = 0.;
00191             if (*capply) {
00192                 i__2 = *n;
00193                 for (j = 1; j <= i__2; ++j) {
00194                     i__3 = j + i__ * a_dim1;
00195                     tmp += ((d__1 = a[i__3].r, abs(d__1)) + (d__2 = d_imag(&a[
00196                             j + i__ * a_dim1]), abs(d__2))) / c__[j];
00197                 }
00198             } else {
00199                 i__2 = *n;
00200                 for (j = 1; j <= i__2; ++j) {
00201                     i__3 = j + i__ * a_dim1;
00202                     tmp += (d__1 = a[i__3].r, abs(d__1)) + (d__2 = d_imag(&a[
00203                             j + i__ * a_dim1]), abs(d__2));
00204                 }
00205             }
00206             rwork[i__] = tmp;
00207             anorm = max(anorm,tmp);
00208         }
00209     }
00210 
00211 /*     Quick return if possible. */
00212 
00213     if (*n == 0) {
00214         ret_val = 1.;
00215         return ret_val;
00216     } else if (anorm == 0.) {
00217         return ret_val;
00218     }
00219 
00220 /*     Estimate the norm of inv(op(A)). */
00221 
00222     ainvnm = 0.;
00223 
00224     kase = 0;
00225 L10:
00226     zlacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00227     if (kase != 0) {
00228         if (kase == 2) {
00229 
00230 /*           Multiply by R. */
00231 
00232             i__1 = *n;
00233             for (i__ = 1; i__ <= i__1; ++i__) {
00234                 i__2 = i__;
00235                 i__3 = i__;
00236                 i__4 = i__;
00237                 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] * 
00238                         work[i__3].i;
00239                 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00240             }
00241 
00242             if (notrans) {
00243                 zgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00244                         1], &work[1], n, info);
00245             } else {
00246                 zgetrs_("Conjugate transpose", n, &c__1, &af[af_offset], ldaf, 
00247                          &ipiv[1], &work[1], n, info);
00248             }
00249 
00250 /*           Multiply by inv(C). */
00251 
00252             if (*capply) {
00253                 i__1 = *n;
00254                 for (i__ = 1; i__ <= i__1; ++i__) {
00255                     i__2 = i__;
00256                     i__3 = i__;
00257                     i__4 = i__;
00258                     z__1.r = c__[i__4] * work[i__3].r, z__1.i = c__[i__4] * 
00259                             work[i__3].i;
00260                     work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00261                 }
00262             }
00263         } else {
00264 
00265 /*           Multiply by inv(C'). */
00266 
00267             if (*capply) {
00268                 i__1 = *n;
00269                 for (i__ = 1; i__ <= i__1; ++i__) {
00270                     i__2 = i__;
00271                     i__3 = i__;
00272                     i__4 = i__;
00273                     z__1.r = c__[i__4] * work[i__3].r, z__1.i = c__[i__4] * 
00274                             work[i__3].i;
00275                     work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00276                 }
00277             }
00278 
00279             if (notrans) {
00280                 zgetrs_("Conjugate transpose", n, &c__1, &af[af_offset], ldaf, 
00281                          &ipiv[1], &work[1], n, info);
00282             } else {
00283                 zgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00284                         1], &work[1], n, info);
00285             }
00286 
00287 /*           Multiply by R. */
00288 
00289             i__1 = *n;
00290             for (i__ = 1; i__ <= i__1; ++i__) {
00291                 i__2 = i__;
00292                 i__3 = i__;
00293                 i__4 = i__;
00294                 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] * 
00295                         work[i__3].i;
00296                 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00297             }
00298         }
00299         goto L10;
00300     }
00301 
00302 /*     Compute the estimate of the reciprocal condition number. */
00303 
00304     if (ainvnm != 0.) {
00305         ret_val = 1. / ainvnm;
00306     }
00307 
00308     return ret_val;
00309 
00310 } /* zla_gercond_c__ */


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