zla_porcond_x.c
Go to the documentation of this file.
00001 /* zla_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 zla_porcond_x__(char *uplo, integer *n, doublecomplex *a, integer *
00021         lda, doublecomplex *af, integer *ldaf, doublecomplex *x, integer *
00022         info, doublecomplex *work, doublereal *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     doublereal ret_val, d__1, d__2;
00027     doublecomplex z__1, z__2;
00028 
00029     /* Builtin functions */
00030     double d_imag(doublecomplex *);
00031     void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00032 
00033     /* Local variables */
00034     integer i__, j;
00035     logical up;
00036     doublereal tmp;
00037     integer kase;
00038     extern logical lsame_(char *, char *);
00039     integer isave[3];
00040     doublereal anorm;
00041     extern /* Subroutine */ int zlacn2_(integer *, doublecomplex *, 
00042             doublecomplex *, doublereal *, integer *, integer *), xerbla_(
00043             char *, integer *);
00044     doublereal ainvnm;
00045     extern /* Subroutine */ int zpotrs_(char *, integer *, integer *, 
00046             doublecomplex *, integer *, doublecomplex *, integer *, integer *);
00047 
00048 
00049 /*     -- LAPACK routine (version 3.2.1)                                 -- */
00050 /*     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
00051 /*     -- Jason Riedy of Univ. of California Berkeley.                 -- */
00052 /*     -- April 2009                                                   -- */
00053 
00054 /*     -- LAPACK is a software package provided by Univ. of Tennessee, -- */
00055 /*     -- Univ. of California Berkeley and NAG Ltd.                    -- */
00056 
00057 /*     .. */
00058 /*     .. Scalar Arguments .. */
00059 /*     .. */
00060 /*     .. Array Arguments .. */
00061 /*     .. */
00062 
00063 /*  Purpose */
00064 /*  ======= */
00065 
00066 /*     ZLA_PORCOND_X Computes the infinity norm condition number of */
00067 /*     op(A) * diag(X) where X is a COMPLEX*16 vector. */
00068 
00069 /*  Arguments */
00070 /*  ========= */
00071 
00072 /*     UPLO    (input) CHARACTER*1 */
00073 /*       = 'U':  Upper triangle of A is stored; */
00074 /*       = 'L':  Lower triangle of A is stored. */
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*16 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*16 array, dimension (LDAF,N) */
00087 /*     The triangular factor U or L from the Cholesky factorization */
00088 /*     A = U**T*U or A = L*L**T, as computed by ZPOTRF. */
00089 
00090 /*     LDAF    (input) INTEGER */
00091 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00092 
00093 /*     X       (input) COMPLEX*16 array, dimension (N) */
00094 /*     The vector X in the formula op(A) * diag(X). */
00095 
00096 /*     INFO    (output) INTEGER */
00097 /*       = 0:  Successful exit. */
00098 /*     i > 0:  The ith argument is invalid. */
00099 
00100 /*     WORK    (input) COMPLEX*16 array, dimension (2*N). */
00101 /*     Workspace. */
00102 
00103 /*     RWORK   (input) DOUBLE PRECISION array, dimension (N). */
00104 /*     Workspace. */
00105 
00106 /*  ===================================================================== */
00107 
00108 /*     .. Local Scalars .. */
00109 /*     .. */
00110 /*     .. Local Arrays .. */
00111 /*     .. */
00112 /*     .. External Functions .. */
00113 /*     .. */
00114 /*     .. External Subroutines .. */
00115 /*     .. */
00116 /*     .. Intrinsic Functions .. */
00117 /*     .. */
00118 /*     .. Statement Functions .. */
00119 /*     .. */
00120 /*     .. Statement Function Definitions .. */
00121 /*     .. */
00122 /*     .. Executable Statements .. */
00123 
00124     /* Parameter adjustments */
00125     a_dim1 = *lda;
00126     a_offset = 1 + a_dim1;
00127     a -= a_offset;
00128     af_dim1 = *ldaf;
00129     af_offset = 1 + af_dim1;
00130     af -= af_offset;
00131     --x;
00132     --work;
00133     --rwork;
00134 
00135     /* Function Body */
00136     ret_val = 0.;
00137 
00138     *info = 0;
00139     if (*n < 0) {
00140         *info = -2;
00141     }
00142     if (*info != 0) {
00143         i__1 = -(*info);
00144         xerbla_("ZLA_PORCOND_X", &i__1);
00145         return ret_val;
00146     }
00147     up = FALSE_;
00148     if (lsame_(uplo, "U")) {
00149         up = TRUE_;
00150     }
00151 
00152 /*     Compute norm of op(A)*op2(C). */
00153 
00154     anorm = 0.;
00155     if (up) {
00156         i__1 = *n;
00157         for (i__ = 1; i__ <= i__1; ++i__) {
00158             tmp = 0.;
00159             i__2 = i__;
00160             for (j = 1; j <= i__2; ++j) {
00161                 i__3 = j + i__ * a_dim1;
00162                 i__4 = j;
00163                 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00164                         z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00165                         .r;
00166                 z__1.r = z__2.r, z__1.i = z__2.i;
00167                 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1), 
00168                         abs(d__2));
00169             }
00170             i__2 = *n;
00171             for (j = i__ + 1; j <= i__2; ++j) {
00172                 i__3 = i__ + j * a_dim1;
00173                 i__4 = j;
00174                 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00175                         z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00176                         .r;
00177                 z__1.r = z__2.r, z__1.i = z__2.i;
00178                 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1), 
00179                         abs(d__2));
00180             }
00181             rwork[i__] = tmp;
00182             anorm = max(anorm,tmp);
00183         }
00184     } else {
00185         i__1 = *n;
00186         for (i__ = 1; i__ <= i__1; ++i__) {
00187             tmp = 0.;
00188             i__2 = i__;
00189             for (j = 1; j <= i__2; ++j) {
00190                 i__3 = i__ + j * a_dim1;
00191                 i__4 = j;
00192                 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00193                         z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00194                         .r;
00195                 z__1.r = z__2.r, z__1.i = z__2.i;
00196                 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1), 
00197                         abs(d__2));
00198             }
00199             i__2 = *n;
00200             for (j = i__ + 1; j <= i__2; ++j) {
00201                 i__3 = j + i__ * a_dim1;
00202                 i__4 = j;
00203                 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i, 
00204                         z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00205                         .r;
00206                 z__1.r = z__2.r, z__1.i = z__2.i;
00207                 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1), 
00208                         abs(d__2));
00209             }
00210             rwork[i__] = tmp;
00211             anorm = max(anorm,tmp);
00212         }
00213     }
00214 
00215 /*     Quick return if possible. */
00216 
00217     if (*n == 0) {
00218         ret_val = 1.;
00219         return ret_val;
00220     } else if (anorm == 0.) {
00221         return ret_val;
00222     }
00223 
00224 /*     Estimate the norm of inv(op(A)). */
00225 
00226     ainvnm = 0.;
00227 
00228     kase = 0;
00229 L10:
00230     zlacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00231     if (kase != 0) {
00232         if (kase == 2) {
00233 
00234 /*           Multiply by R. */
00235 
00236             i__1 = *n;
00237             for (i__ = 1; i__ <= i__1; ++i__) {
00238                 i__2 = i__;
00239                 i__3 = i__;
00240                 i__4 = i__;
00241                 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] * 
00242                         work[i__3].i;
00243                 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00244             }
00245 
00246             if (up) {
00247                 zpotrs_("U", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00248                         info);
00249             } else {
00250                 zpotrs_("L", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00251                         info);
00252             }
00253 
00254 /*           Multiply by inv(X). */
00255 
00256             i__1 = *n;
00257             for (i__ = 1; i__ <= i__1; ++i__) {
00258                 i__2 = i__;
00259                 z_div(&z__1, &work[i__], &x[i__]);
00260                 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00261             }
00262         } else {
00263 
00264 /*           Multiply by inv(X'). */
00265 
00266             i__1 = *n;
00267             for (i__ = 1; i__ <= i__1; ++i__) {
00268                 i__2 = i__;
00269                 z_div(&z__1, &work[i__], &x[i__]);
00270                 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00271             }
00272 
00273             if (up) {
00274                 zpotrs_("U", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00275                         info);
00276             } else {
00277                 zpotrs_("L", n, &c__1, &af[af_offset], ldaf, &work[1], n, 
00278                         info);
00279             }
00280 
00281 /*           Multiply by R. */
00282 
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                 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] * 
00289                         work[i__3].i;
00290                 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00291             }
00292         }
00293         goto L10;
00294     }
00295 
00296 /*     Compute the estimate of the reciprocal condition number. */
00297 
00298     if (ainvnm != 0.) {
00299         ret_val = 1. / ainvnm;
00300     }
00301 
00302     return ret_val;
00303 
00304 } /* zla_porcond_x__ */


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