cla_porcond_x.c
Go to the documentation of this file.
00001 /* cla_porcond_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_porcond_x__(char *uplo, integer *n, complex *a, integer *lda, 
00021         complex *af, integer *ldaf, complex *x, integer *info, complex *work, 
00022         real *rwork, ftnlen uplo_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     logical up;
00036     real tmp;
00037     integer kase;
00038     extern logical lsame_(char *, char *);
00039     integer isave[3];
00040     real anorm;
00041     extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real 
00042             *, integer *, integer *), xerbla_(char *, integer *);
00043     real ainvnm;
00044     extern /* Subroutine */ int cpotrs_(char *, integer *, integer *, complex 
00045             *, integer *, complex *, integer *, integer *);
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_PORCOND_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 /*     UPLO    (input) CHARACTER*1 */
00072 /*       = 'U':  Upper triangle of A is stored; */
00073 /*       = 'L':  Lower triangle of A is stored. */
00074 
00075 /*     N       (input) INTEGER */
00076 /*     The number of linear equations, i.e., the order of the */
00077 /*     matrix A.  N >= 0. */
00078 
00079 /*     A       (input) COMPLEX array, dimension (LDA,N) */
00080 /*     On entry, the N-by-N matrix A. */
00081 
00082 /*     LDA     (input) INTEGER */
00083 /*     The leading dimension of the array A.  LDA >= max(1,N). */
00084 
00085 /*     AF      (input) COMPLEX array, dimension (LDAF,N) */
00086 /*     The triangular factor U or L from the Cholesky factorization */
00087 /*     A = U**T*U or A = L*L**T, as computed by CPOTRF. */
00088 
00089 /*     LDAF    (input) INTEGER */
00090 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00091 
00092 /*     X       (input) COMPLEX array, dimension (N) */
00093 /*     The vector X in the formula op(A) * diag(X). */
00094 
00095 /*     INFO    (output) INTEGER */
00096 /*       = 0:  Successful exit. */
00097 /*     i > 0:  The ith argument is invalid. */
00098 
00099 /*     WORK    (input) COMPLEX array, dimension (2*N). */
00100 /*     Workspace. */
00101 
00102 /*     RWORK   (input) REAL array, dimension (N). */
00103 /*     Workspace. */
00104 
00105 /*  ===================================================================== */
00106 
00107 /*     .. Local Scalars .. */
00108 /*     .. */
00109 /*     .. Local Arrays .. */
00110 /*     .. */
00111 /*     .. External Functions .. */
00112 /*     .. */
00113 /*     .. External Subroutines .. */
00114 /*     .. */
00115 /*     .. Intrinsic Functions .. */
00116 /*     .. */
00117 /*     .. Statement Functions .. */
00118 /*     .. */
00119 /*     .. Statement Function Definitions .. */
00120 /*     .. */
00121 /*     .. Executable Statements .. */
00122 
00123     /* Parameter adjustments */
00124     a_dim1 = *lda;
00125     a_offset = 1 + a_dim1;
00126     a -= a_offset;
00127     af_dim1 = *ldaf;
00128     af_offset = 1 + af_dim1;
00129     af -= af_offset;
00130     --x;
00131     --work;
00132     --rwork;
00133 
00134     /* Function Body */
00135     ret_val = 0.f;
00136 
00137     *info = 0;
00138     if (*n < 0) {
00139         *info = -2;
00140     }
00141     if (*info != 0) {
00142         i__1 = -(*info);
00143         xerbla_("CLA_PORCOND_X", &i__1);
00144         return ret_val;
00145     }
00146     up = FALSE_;
00147     if (lsame_(uplo, "U")) {
00148         up = TRUE_;
00149     }
00150 
00151 /*     Compute norm of op(A)*op2(C). */
00152 
00153     anorm = 0.f;
00154     if (up) {
00155         i__1 = *n;
00156         for (i__ = 1; i__ <= i__1; ++i__) {
00157             tmp = 0.f;
00158             i__2 = i__;
00159             for (j = 1; j <= i__2; ++j) {
00160                 i__3 = j + i__ * a_dim1;
00161                 i__4 = j;
00162                 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00163                         q__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00164                         .r;
00165                 q__1.r = q__2.r, q__1.i = q__2.i;
00166                 tmp += (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&q__1), 
00167                         dabs(r__2));
00168             }
00169             i__2 = *n;
00170             for (j = i__ + 1; j <= i__2; ++j) {
00171                 i__3 = i__ + j * a_dim1;
00172                 i__4 = j;
00173                 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00174                         q__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00175                         .r;
00176                 q__1.r = q__2.r, q__1.i = q__2.i;
00177                 tmp += (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&q__1), 
00178                         dabs(r__2));
00179             }
00180             rwork[i__] = tmp;
00181             anorm = dmax(anorm,tmp);
00182         }
00183     } else {
00184         i__1 = *n;
00185         for (i__ = 1; i__ <= i__1; ++i__) {
00186             tmp = 0.f;
00187             i__2 = i__;
00188             for (j = 1; j <= i__2; ++j) {
00189                 i__3 = i__ + j * a_dim1;
00190                 i__4 = j;
00191                 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00192                         q__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00193                         .r;
00194                 q__1.r = q__2.r, q__1.i = q__2.i;
00195                 tmp += (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&q__1), 
00196                         dabs(r__2));
00197             }
00198             i__2 = *n;
00199             for (j = i__ + 1; j <= i__2; ++j) {
00200                 i__3 = j + i__ * a_dim1;
00201                 i__4 = j;
00202                 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00203                         q__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00204                         .r;
00205                 q__1.r = q__2.r, q__1.i = q__2.i;
00206                 tmp += (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&q__1), 
00207                         dabs(r__2));
00208             }
00209             rwork[i__] = tmp;
00210             anorm = dmax(anorm,tmp);
00211         }
00212     }
00213 
00214 /*     Quick return if possible. */
00215 
00216     if (*n == 0) {
00217         ret_val = 1.f;
00218         return ret_val;
00219     } else if (anorm == 0.f) {
00220         return ret_val;
00221     }
00222 
00223 /*     Estimate the norm of inv(op(A)). */
00224 
00225     ainvnm = 0.f;
00226 
00227     kase = 0;
00228 L10:
00229     clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00230     if (kase != 0) {
00231         if (kase == 2) {
00232 
00233 /*           Multiply by R. */
00234 
00235             i__1 = *n;
00236             for (i__ = 1; i__ <= i__1; ++i__) {
00237                 i__2 = i__;
00238                 i__3 = i__;
00239                 i__4 = i__;
00240                 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] * 
00241                         work[i__3].i;
00242                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00243             }
00244 
00245             if (up) {
00246                 cpotrs_("U", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00247                         info);
00248             } else {
00249                 cpotrs_("L", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00250                         info);
00251             }
00252 
00253 /*           Multiply by inv(X). */
00254 
00255             i__1 = *n;
00256             for (i__ = 1; i__ <= i__1; ++i__) {
00257                 i__2 = i__;
00258                 c_div(&q__1, &work[i__], &x[i__]);
00259                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00260             }
00261         } else {
00262 
00263 /*           Multiply by inv(X'). */
00264 
00265             i__1 = *n;
00266             for (i__ = 1; i__ <= i__1; ++i__) {
00267                 i__2 = i__;
00268                 c_div(&q__1, &work[i__], &x[i__]);
00269                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00270             }
00271 
00272             if (up) {
00273                 cpotrs_("U", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00274                         info);
00275             } else {
00276                 cpotrs_("L", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00277                         info);
00278             }
00279 
00280 /*           Multiply by R. */
00281 
00282             i__1 = *n;
00283             for (i__ = 1; i__ <= i__1; ++i__) {
00284                 i__2 = i__;
00285                 i__3 = i__;
00286                 i__4 = i__;
00287                 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] * 
00288                         work[i__3].i;
00289                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00290             }
00291         }
00292         goto L10;
00293     }
00294 
00295 /*     Compute the estimate of the reciprocal condition number. */
00296 
00297     if (ainvnm != 0.f) {
00298         ret_val = 1.f / ainvnm;
00299     }
00300 
00301     return ret_val;
00302 
00303 } /* cla_porcond_x__ */


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