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


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