cla_gercond_x.c
Go to the documentation of this file.
00001 /* cla_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 cla_gercond_x__(char *trans, integer *n, complex *a, integer *lda, 
00021         complex *af, integer *ldaf, integer *ipiv, complex *x, integer *info, 
00022         complex *work, real *rwork, ftnlen trans_len)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, af_dim1, af_offset, i__1, i__2, i__3, i__4;
00026     real ret_val, r__1, r__2;
00027     complex q__1, q__2;
00028 
00029     /* Builtin functions */
00030     double r_imag(complex *);
00031     void c_div(complex *, complex *, complex *);
00032 
00033     /* Local variables */
00034     integer i__, j;
00035     real tmp;
00036     integer kase;
00037     extern logical lsame_(char *, char *);
00038     integer isave[3];
00039     real anorm;
00040     extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real 
00041             *, integer *, integer *), xerbla_(char *, integer *), 
00042             cgetrs_(char *, integer *, integer *, complex *, integer *, 
00043             integer *, complex *, integer *, integer *);
00044     real ainvnm;
00045     logical notrans;
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 /*     CLA_GERCOND_X computes the infinity norm condition number of */
00066 /*     op(A) * diag(X) where X is a COMPLEX vector. */
00067 
00068 /*  Arguments */
00069 /*  ========= */
00070 
00071 /*     TRANS   (input) CHARACTER*1 */
00072 /*     Specifies the form of the system of equations: */
00073 /*       = 'N':  A * X = B     (No transpose) */
00074 /*       = 'T':  A**T * X = B  (Transpose) */
00075 /*       = 'C':  A**H * X = B  (Conjugate Transpose = Transpose) */
00076 
00077 /*     N       (input) INTEGER */
00078 /*     The number of linear equations, i.e., the order of the */
00079 /*     matrix A.  N >= 0. */
00080 
00081 /*     A       (input) COMPLEX array, dimension (LDA,N) */
00082 /*     On entry, the N-by-N matrix A. */
00083 
00084 /*     LDA     (input) INTEGER */
00085 /*     The leading dimension of the array A.  LDA >= max(1,N). */
00086 
00087 /*     AF      (input) COMPLEX array, dimension (LDAF,N) */
00088 /*     The factors L and U from the factorization */
00089 /*     A = P*L*U as computed by CGETRF. */
00090 
00091 /*     LDAF    (input) INTEGER */
00092 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00093 
00094 /*     IPIV    (input) INTEGER array, dimension (N) */
00095 /*     The pivot indices from the factorization A = P*L*U */
00096 /*     as computed by CGETRF; row i of the matrix was interchanged */
00097 /*     with row IPIV(i). */
00098 
00099 /*     X       (input) COMPLEX 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 array, dimension (2*N). */
00107 /*     Workspace. */
00108 
00109 /*     RWORK   (input) REAL 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.f;
00144 
00145     *info = 0;
00146     notrans = lsame_(trans, "N");
00147     if (! notrans && ! lsame_(trans, "T") && ! lsame_(
00148             trans, "C")) {
00149         *info = -1;
00150     } else if (*n < 0) {
00151         *info = -2;
00152     }
00153     if (*info != 0) {
00154         i__1 = -(*info);
00155         xerbla_("CLA_GERCOND_X", &i__1);
00156         return ret_val;
00157     }
00158 
00159 /*     Compute norm of op(A)*op2(C). */
00160 
00161     anorm = 0.f;
00162     if (notrans) {
00163         i__1 = *n;
00164         for (i__ = 1; i__ <= i__1; ++i__) {
00165             tmp = 0.f;
00166             i__2 = *n;
00167             for (j = 1; j <= i__2; ++j) {
00168                 i__3 = i__ + j * a_dim1;
00169                 i__4 = j;
00170                 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00171                         q__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00172                         .r;
00173                 q__1.r = q__2.r, q__1.i = q__2.i;
00174                 tmp += (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&q__1), 
00175                         dabs(r__2));
00176             }
00177             rwork[i__] = tmp;
00178             anorm = dmax(anorm,tmp);
00179         }
00180     } else {
00181         i__1 = *n;
00182         for (i__ = 1; i__ <= i__1; ++i__) {
00183             tmp = 0.f;
00184             i__2 = *n;
00185             for (j = 1; j <= i__2; ++j) {
00186                 i__3 = j + i__ * a_dim1;
00187                 i__4 = j;
00188                 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00189                         q__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00190                         .r;
00191                 q__1.r = q__2.r, q__1.i = q__2.i;
00192                 tmp += (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&q__1), 
00193                         dabs(r__2));
00194             }
00195             rwork[i__] = tmp;
00196             anorm = dmax(anorm,tmp);
00197         }
00198     }
00199 
00200 /*     Quick return if possible. */
00201 
00202     if (*n == 0) {
00203         ret_val = 1.f;
00204         return ret_val;
00205     } else if (anorm == 0.f) {
00206         return ret_val;
00207     }
00208 
00209 /*     Estimate the norm of inv(op(A)). */
00210 
00211     ainvnm = 0.f;
00212 
00213     kase = 0;
00214 L10:
00215     clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00216     if (kase != 0) {
00217         if (kase == 2) {
00218 /*           Multiply by R. */
00219             i__1 = *n;
00220             for (i__ = 1; i__ <= i__1; ++i__) {
00221                 i__2 = i__;
00222                 i__3 = i__;
00223                 i__4 = i__;
00224                 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] * 
00225                         work[i__3].i;
00226                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00227             }
00228 
00229             if (notrans) {
00230                 cgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00231                         1], &work[1], n, info);
00232             } else {
00233                 cgetrs_("Conjugate transpose", n, &c__1, &af[af_offset], ldaf, 
00234                          &ipiv[1], &work[1], n, info);
00235             }
00236 
00237 /*           Multiply by inv(X). */
00238 
00239             i__1 = *n;
00240             for (i__ = 1; i__ <= i__1; ++i__) {
00241                 i__2 = i__;
00242                 c_div(&q__1, &work[i__], &x[i__]);
00243                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00244             }
00245         } else {
00246 
00247 /*           Multiply by inv(X'). */
00248 
00249             i__1 = *n;
00250             for (i__ = 1; i__ <= i__1; ++i__) {
00251                 i__2 = i__;
00252                 c_div(&q__1, &work[i__], &x[i__]);
00253                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00254             }
00255 
00256             if (notrans) {
00257                 cgetrs_("Conjugate transpose", n, &c__1, &af[af_offset], ldaf, 
00258                          &ipiv[1], &work[1], n, info);
00259             } else {
00260                 cgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00261                         1], &work[1], n, info);
00262             }
00263 
00264 /*           Multiply by R. */
00265 
00266             i__1 = *n;
00267             for (i__ = 1; i__ <= i__1; ++i__) {
00268                 i__2 = i__;
00269                 i__3 = i__;
00270                 i__4 = i__;
00271                 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] * 
00272                         work[i__3].i;
00273                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00274             }
00275         }
00276         goto L10;
00277     }
00278 
00279 /*     Compute the estimate of the reciprocal condition number. */
00280 
00281     if (ainvnm != 0.f) {
00282         ret_val = 1.f / ainvnm;
00283     }
00284 
00285     return ret_val;
00286 
00287 } /* cla_gercond_x__ */


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