cla_syrcond_c.c
Go to the documentation of this file.
00001 /* cla_syrcond_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_syrcond_c__(char *uplo, 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 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 csytrs_(char *, integer *, integer *, complex 
00044             *, integer *, 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_SYRCOND_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 /*     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 block diagonal matrix D and the multipliers used to */
00086 /*     obtain the factor U or L as computed by CSYTRF. */
00087 
00088 /*     LDAF    (input) INTEGER */
00089 /*     The leading dimension of the array AF.  LDAF >= max(1,N). */
00090 
00091 /*     IPIV    (input) INTEGER array, dimension (N) */
00092 /*     Details of the interchanges and the block structure of D */
00093 /*     as determined by CSYTRF. */
00094 
00095 /*     C       (input) REAL array, dimension (N) */
00096 /*     The vector C in the formula op(A) * inv(diag(C)). */
00097 
00098 /*     CAPPLY  (input) LOGICAL */
00099 /*     If .TRUE. then access the vector C in the formula above. */
00100 
00101 /*     INFO    (output) INTEGER */
00102 /*       = 0:  Successful exit. */
00103 /*     i > 0:  The ith argument is invalid. */
00104 
00105 /*     WORK    (input) COMPLEX array, dimension (2*N). */
00106 /*     Workspace. */
00107 
00108 /*     RWORK   (input) REAL array, dimension (N). */
00109 /*     Workspace. */
00110 
00111 /*  ===================================================================== */
00112 
00113 /*     .. Local Scalars .. */
00114 /*     .. */
00115 /*     .. Local Arrays .. */
00116 /*     .. */
00117 /*     .. External Functions .. */
00118 /*     .. */
00119 /*     .. External Subroutines .. */
00120 /*     .. */
00121 /*     .. Intrinsic Functions .. */
00122 /*     .. */
00123 /*     .. Statement Functions .. */
00124 /*     .. */
00125 /*     .. Statement Function Definitions .. */
00126 /*     .. */
00127 /*     .. Executable Statements .. */
00128 
00129     /* Parameter adjustments */
00130     a_dim1 = *lda;
00131     a_offset = 1 + a_dim1;
00132     a -= a_offset;
00133     af_dim1 = *ldaf;
00134     af_offset = 1 + af_dim1;
00135     af -= af_offset;
00136     --ipiv;
00137     --c__;
00138     --work;
00139     --rwork;
00140 
00141     /* Function Body */
00142     ret_val = 0.f;
00143 
00144     *info = 0;
00145     if (*n < 0) {
00146         *info = -2;
00147     }
00148     if (*info != 0) {
00149         i__1 = -(*info);
00150         xerbla_("CLA_SYRCOND_C", &i__1);
00151         return ret_val;
00152     }
00153     up = FALSE_;
00154     if (lsame_(uplo, "U")) {
00155         up = TRUE_;
00156     }
00157 
00158 /*     Compute norm of op(A)*op2(C). */
00159 
00160     anorm = 0.f;
00161     if (up) {
00162         i__1 = *n;
00163         for (i__ = 1; i__ <= i__1; ++i__) {
00164             tmp = 0.f;
00165             if (*capply) {
00166                 i__2 = i__;
00167                 for (j = 1; j <= i__2; ++j) {
00168                     i__3 = j + i__ * a_dim1;
00169                     tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00170                             a[j + i__ * a_dim1]), dabs(r__2))) / c__[j];
00171                 }
00172                 i__2 = *n;
00173                 for (j = i__ + 1; j <= i__2; ++j) {
00174                     i__3 = i__ + j * a_dim1;
00175                     tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00176                             a[i__ + j * a_dim1]), dabs(r__2))) / c__[j];
00177                 }
00178             } else {
00179                 i__2 = i__;
00180                 for (j = 1; j <= i__2; ++j) {
00181                     i__3 = j + i__ * a_dim1;
00182                     tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00183                             j + i__ * a_dim1]), dabs(r__2));
00184                 }
00185                 i__2 = *n;
00186                 for (j = i__ + 1; j <= i__2; ++j) {
00187                     i__3 = i__ + j * a_dim1;
00188                     tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00189                             i__ + j * a_dim1]), dabs(r__2));
00190                 }
00191             }
00192             rwork[i__] = tmp;
00193             anorm = dmax(anorm,tmp);
00194         }
00195     } else {
00196         i__1 = *n;
00197         for (i__ = 1; i__ <= i__1; ++i__) {
00198             tmp = 0.f;
00199             if (*capply) {
00200                 i__2 = i__;
00201                 for (j = 1; j <= i__2; ++j) {
00202                     i__3 = i__ + j * a_dim1;
00203                     tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00204                             a[i__ + j * a_dim1]), dabs(r__2))) / c__[j];
00205                 }
00206                 i__2 = *n;
00207                 for (j = i__ + 1; j <= i__2; ++j) {
00208                     i__3 = j + i__ * a_dim1;
00209                     tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00210                             a[j + i__ * a_dim1]), dabs(r__2))) / c__[j];
00211                 }
00212             } else {
00213                 i__2 = i__;
00214                 for (j = 1; j <= i__2; ++j) {
00215                     i__3 = i__ + j * a_dim1;
00216                     tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00217                             i__ + j * a_dim1]), dabs(r__2));
00218                 }
00219                 i__2 = *n;
00220                 for (j = i__ + 1; j <= i__2; ++j) {
00221                     i__3 = j + i__ * a_dim1;
00222                     tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00223                             j + i__ * a_dim1]), dabs(r__2));
00224                 }
00225             }
00226             rwork[i__] = tmp;
00227             anorm = dmax(anorm,tmp);
00228         }
00229     }
00230 
00231 /*     Quick return if possible. */
00232 
00233     if (*n == 0) {
00234         ret_val = 1.f;
00235         return ret_val;
00236     } else if (anorm == 0.f) {
00237         return ret_val;
00238     }
00239 
00240 /*     Estimate the norm of inv(op(A)). */
00241 
00242     ainvnm = 0.f;
00243 
00244     kase = 0;
00245 L10:
00246     clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00247     if (kase != 0) {
00248         if (kase == 2) {
00249 
00250 /*           Multiply by R. */
00251 
00252             i__1 = *n;
00253             for (i__ = 1; i__ <= i__1; ++i__) {
00254                 i__2 = i__;
00255                 i__3 = i__;
00256                 i__4 = i__;
00257                 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] * 
00258                         work[i__3].i;
00259                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00260             }
00261 
00262             if (up) {
00263                 csytrs_("U", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00264                         1], n, info);
00265             } else {
00266                 csytrs_("L", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00267                         1], n, info);
00268             }
00269 
00270 /*           Multiply by inv(C). */
00271 
00272             if (*capply) {
00273                 i__1 = *n;
00274                 for (i__ = 1; i__ <= i__1; ++i__) {
00275                     i__2 = i__;
00276                     i__3 = i__;
00277                     i__4 = i__;
00278                     q__1.r = c__[i__4] * work[i__3].r, q__1.i = c__[i__4] * 
00279                             work[i__3].i;
00280                     work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00281                 }
00282             }
00283         } else {
00284 
00285 /*           Multiply by inv(C'). */
00286 
00287             if (*capply) {
00288                 i__1 = *n;
00289                 for (i__ = 1; i__ <= i__1; ++i__) {
00290                     i__2 = i__;
00291                     i__3 = i__;
00292                     i__4 = i__;
00293                     q__1.r = c__[i__4] * work[i__3].r, q__1.i = c__[i__4] * 
00294                             work[i__3].i;
00295                     work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00296                 }
00297             }
00298 
00299             if (up) {
00300                 csytrs_("U", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00301                         1], n, info);
00302             } else {
00303                 csytrs_("L", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00304                         1], n, info);
00305             }
00306 
00307 /*           Multiply by R. */
00308 
00309             i__1 = *n;
00310             for (i__ = 1; i__ <= i__1; ++i__) {
00311                 i__2 = i__;
00312                 i__3 = i__;
00313                 i__4 = i__;
00314                 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] * 
00315                         work[i__3].i;
00316                 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00317             }
00318         }
00319         goto L10;
00320     }
00321 
00322 /*     Compute the estimate of the reciprocal condition number. */
00323 
00324     if (ainvnm != 0.f) {
00325         ret_val = 1.f / ainvnm;
00326     }
00327 
00328     return ret_val;
00329 
00330 } /* cla_syrcond_c__ */


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