cla_porcond_c.c
Go to the documentation of this file.
00001 /* cla_porcond_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_porcond_c__(char *uplo, integer *n, complex *a, integer *lda, 
00021         complex *af, integer *ldaf, real *c__, logical *capply, integer *info,
00022          complex *work, 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;
00028 
00029     /* Builtin functions */
00030     double r_imag(complex *);
00031 
00032     /* Local variables */
00033     integer i__, j;
00034     logical up;
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     real ainvnm;
00043     extern /* Subroutine */ int cpotrs_(char *, integer *, integer *, complex 
00044             *, integer *, complex *, integer *, integer *);
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 Arguments .. */
00057 /*     .. */
00058 /*     .. Array Arguments .. */
00059 /*     .. */
00060 
00061 /*  Purpose */
00062 /*  ======= */
00063 
00064 /*     CLA_PORCOND_C Computes the infinity norm condition number of */
00065 /*     op(A) * inv(diag(C)) where C is a DOUBLE PRECISION vector */
00066 
00067 /*  Arguments */
00068 /*  ========= */
00069 
00070 /*     UPLO    (input) CHARACTER*1 */
00071 /*       = 'U':  Upper triangle of A is stored; */
00072 /*       = 'L':  Lower triangle of A is stored. */
00073 
00074 /*     N       (input) INTEGER */
00075 /*     The number of linear equations, i.e., the order of the */
00076 /*     matrix A.  N >= 0. */
00077 
00078 /*     A       (input) COMPLEX array, dimension (LDA,N) */
00079 /*     On entry, the N-by-N matrix A */
00080 
00081 /*     LDA     (input) INTEGER */
00082 /*     The leading dimension of the array A.  LDA >= max(1,N). */
00083 
00084 /*     AF      (input) COMPLEX array, dimension (LDAF,N) */
00085 /*     The triangular factor U or L from the Cholesky factorization */
00086 /*     A = U**T*U or A = L*L**T, as computed by CPOTRF. */
00087 
00088 /*     LDAF    (input) INTEGER */
00089 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00090 
00091 /*     C       (input) REAL array, dimension (N) */
00092 /*     The vector C in the formula op(A) * inv(diag(C)). */
00093 
00094 /*     CAPPLY  (input) LOGICAL */
00095 /*     If .TRUE. then access the vector C in the formula above. */
00096 
00097 /*     INFO    (output) INTEGER */
00098 /*       = 0:  Successful exit. */
00099 /*     i > 0:  The ith argument is invalid. */
00100 
00101 /*     WORK    (input) COMPLEX array, dimension (2*N). */
00102 /*     Workspace. */
00103 
00104 /*     RWORK   (input) REAL array, dimension (N). */
00105 /*     Workspace. */
00106 
00107 /*  ===================================================================== */
00108 
00109 /*     .. Local Scalars .. */
00110 /*     .. */
00111 /*     .. Local Arrays .. */
00112 /*     .. */
00113 /*     .. External Functions .. */
00114 /*     .. */
00115 /*     .. External Subroutines .. */
00116 /*     .. */
00117 /*     .. Intrinsic Functions .. */
00118 /*     .. */
00119 /*     .. Statement Functions .. */
00120 /*     .. */
00121 /*     .. Statement Function Definitions .. */
00122 /*     .. */
00123 /*     .. Executable Statements .. */
00124 
00125     /* Parameter adjustments */
00126     a_dim1 = *lda;
00127     a_offset = 1 + a_dim1;
00128     a -= a_offset;
00129     af_dim1 = *ldaf;
00130     af_offset = 1 + af_dim1;
00131     af -= af_offset;
00132     --c__;
00133     --work;
00134     --rwork;
00135 
00136     /* Function Body */
00137     ret_val = 0.f;
00138 
00139     *info = 0;
00140     if (*n < 0) {
00141         *info = -2;
00142     }
00143     if (*info != 0) {
00144         i__1 = -(*info);
00145         xerbla_("CLA_PORCOND_C", &i__1);
00146         return ret_val;
00147     }
00148     up = FALSE_;
00149     if (lsame_(uplo, "U")) {
00150         up = TRUE_;
00151     }
00152 
00153 /*     Compute norm of op(A)*op2(C). */
00154 
00155     anorm = 0.f;
00156     if (up) {
00157         i__1 = *n;
00158         for (i__ = 1; i__ <= i__1; ++i__) {
00159             tmp = 0.f;
00160             if (*capply) {
00161                 i__2 = i__;
00162                 for (j = 1; j <= i__2; ++j) {
00163                     i__3 = j + i__ * a_dim1;
00164                     tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00165                             a[j + i__ * a_dim1]), dabs(r__2))) / c__[j];
00166                 }
00167                 i__2 = *n;
00168                 for (j = i__ + 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 = i__;
00175                 for (j = 1; j <= i__2; ++j) {
00176                     i__3 = j + i__ * a_dim1;
00177                     tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00178                             j + i__ * a_dim1]), dabs(r__2));
00179                 }
00180                 i__2 = *n;
00181                 for (j = i__ + 1; j <= i__2; ++j) {
00182                     i__3 = i__ + j * a_dim1;
00183                     tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00184                             i__ + j * a_dim1]), dabs(r__2));
00185                 }
00186             }
00187             rwork[i__] = tmp;
00188             anorm = dmax(anorm,tmp);
00189         }
00190     } else {
00191         i__1 = *n;
00192         for (i__ = 1; i__ <= i__1; ++i__) {
00193             tmp = 0.f;
00194             if (*capply) {
00195                 i__2 = i__;
00196                 for (j = 1; j <= i__2; ++j) {
00197                     i__3 = i__ + j * a_dim1;
00198                     tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00199                             a[i__ + j * a_dim1]), dabs(r__2))) / c__[j];
00200                 }
00201                 i__2 = *n;
00202                 for (j = i__ + 1; j <= i__2; ++j) {
00203                     i__3 = j + i__ * a_dim1;
00204                     tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00205                             a[j + i__ * a_dim1]), dabs(r__2))) / c__[j];
00206                 }
00207             } else {
00208                 i__2 = i__;
00209                 for (j = 1; j <= i__2; ++j) {
00210                     i__3 = i__ + j * a_dim1;
00211                     tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00212                             i__ + j * a_dim1]), dabs(r__2));
00213                 }
00214                 i__2 = *n;
00215                 for (j = i__ + 1; j <= i__2; ++j) {
00216                     i__3 = j + i__ * a_dim1;
00217                     tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00218                             j + i__ * a_dim1]), dabs(r__2));
00219                 }
00220             }
00221             rwork[i__] = tmp;
00222             anorm = dmax(anorm,tmp);
00223         }
00224     }
00225 
00226 /*     Quick return if possible. */
00227 
00228     if (*n == 0) {
00229         ret_val = 1.f;
00230         return ret_val;
00231     } else if (anorm == 0.f) {
00232         return ret_val;
00233     }
00234 
00235 /*     Estimate the norm of inv(op(A)). */
00236 
00237     ainvnm = 0.f;
00238 
00239     kase = 0;
00240 L10:
00241     clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00242     if (kase != 0) {
00243         if (kase == 2) {
00244 
00245 /*           Multiply by R. */
00246 
00247             i__1 = *n;
00248             for (i__ = 1; i__ <= i__1; ++i__) {
00249                 i__2 = i__;
00250                 i__3 = i__;
00251                 i__4 = i__;
00252                 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] * 
00253                         work[i__3].i;
00254                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00255             }
00256 
00257             if (up) {
00258                 cpotrs_("U", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00259                         info);
00260             } else {
00261                 cpotrs_("L", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00262                         info);
00263             }
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                     q__1.r = c__[i__4] * work[i__3].r, q__1.i = c__[i__4] * 
00274                             work[i__3].i;
00275                     work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00276                 }
00277             }
00278         } else {
00279 
00280 /*           Multiply by inv(C'). */
00281 
00282             if (*capply) {
00283                 i__1 = *n;
00284                 for (i__ = 1; i__ <= i__1; ++i__) {
00285                     i__2 = i__;
00286                     i__3 = i__;
00287                     i__4 = i__;
00288                     q__1.r = c__[i__4] * work[i__3].r, q__1.i = c__[i__4] * 
00289                             work[i__3].i;
00290                     work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00291                 }
00292             }
00293 
00294             if (up) {
00295                 cpotrs_("U", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00296                         info);
00297             } else {
00298                 cpotrs_("L", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00299                         info);
00300             }
00301 
00302 /*           Multiply by R. */
00303 
00304             i__1 = *n;
00305             for (i__ = 1; i__ <= i__1; ++i__) {
00306                 i__2 = i__;
00307                 i__3 = i__;
00308                 i__4 = i__;
00309                 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] * 
00310                         work[i__3].i;
00311                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00312             }
00313         }
00314         goto L10;
00315     }
00316 
00317 /*     Compute the estimate of the reciprocal condition number. */
00318 
00319     if (ainvnm != 0.f) {
00320         ret_val = 1.f / ainvnm;
00321     }
00322 
00323     return ret_val;
00324 
00325 } /* cla_porcond_c__ */


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