zgetc2.c
Go to the documentation of this file.
00001 /* zgetc2.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 static doublecomplex c_b10 = {-1.,-0.};
00020 
00021 /* Subroutine */ int zgetc2_(integer *n, doublecomplex *a, integer *lda, 
00022         integer *ipiv, integer *jpiv, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, i__1, i__2, i__3;
00026     doublereal d__1;
00027     doublecomplex z__1;
00028 
00029     /* Builtin functions */
00030     double z_abs(doublecomplex *);
00031     void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00032 
00033     /* Local variables */
00034     integer i__, j, ip, jp;
00035     doublereal eps;
00036     integer ipv, jpv;
00037     doublereal smin, xmax;
00038     extern /* Subroutine */ int zgeru_(integer *, integer *, doublecomplex *, 
00039             doublecomplex *, integer *, doublecomplex *, integer *, 
00040             doublecomplex *, integer *), zswap_(integer *, doublecomplex *, 
00041             integer *, doublecomplex *, integer *), dlabad_(doublereal *, 
00042             doublereal *);
00043     extern doublereal dlamch_(char *);
00044     doublereal bignum, smlnum;
00045 
00046 
00047 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00048 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00049 /*     November 2006 */
00050 
00051 /*     .. Scalar Arguments .. */
00052 /*     .. */
00053 /*     .. Array Arguments .. */
00054 /*     .. */
00055 
00056 /*  Purpose */
00057 /*  ======= */
00058 
00059 /*  ZGETC2 computes an LU factorization, using complete pivoting, of the */
00060 /*  n-by-n matrix A. The factorization has the form A = P * L * U * Q, */
00061 /*  where P and Q are permutation matrices, L is lower triangular with */
00062 /*  unit diagonal elements and U is upper triangular. */
00063 
00064 /*  This is a level 1 BLAS version of the algorithm. */
00065 
00066 /*  Arguments */
00067 /*  ========= */
00068 
00069 /*  N       (input) INTEGER */
00070 /*          The order of the matrix A. N >= 0. */
00071 
00072 /*  A       (input/output) COMPLEX*16 array, dimension (LDA, N) */
00073 /*          On entry, the n-by-n matrix to be factored. */
00074 /*          On exit, the factors L and U from the factorization */
00075 /*          A = P*L*U*Q; the unit diagonal elements of L are not stored. */
00076 /*          If U(k, k) appears to be less than SMIN, U(k, k) is given the */
00077 /*          value of SMIN, giving a nonsingular perturbed system. */
00078 
00079 /*  LDA     (input) INTEGER */
00080 /*          The leading dimension of the array A.  LDA >= max(1, N). */
00081 
00082 /*  IPIV    (output) INTEGER array, dimension (N). */
00083 /*          The pivot indices; for 1 <= i <= N, row i of the */
00084 /*          matrix has been interchanged with row IPIV(i). */
00085 
00086 /*  JPIV    (output) INTEGER array, dimension (N). */
00087 /*          The pivot indices; for 1 <= j <= N, column j of the */
00088 /*          matrix has been interchanged with column JPIV(j). */
00089 
00090 /*  INFO    (output) INTEGER */
00091 /*           = 0: successful exit */
00092 /*           > 0: if INFO = k, U(k, k) is likely to produce overflow if */
00093 /*                one tries to solve for x in Ax = b. So U is perturbed */
00094 /*                to avoid the overflow. */
00095 
00096 /*  Further Details */
00097 /*  =============== */
00098 
00099 /*  Based on contributions by */
00100 /*     Bo Kagstrom and Peter Poromaa, Department of Computing Science, */
00101 /*     Umea University, S-901 87 Umea, Sweden. */
00102 
00103 /*  ===================================================================== */
00104 
00105 /*     .. Parameters .. */
00106 /*     .. */
00107 /*     .. Local Scalars .. */
00108 /*     .. */
00109 /*     .. External Subroutines .. */
00110 /*     .. */
00111 /*     .. External Functions .. */
00112 /*     .. */
00113 /*     .. Intrinsic Functions .. */
00114 /*     .. */
00115 /*     .. Executable Statements .. */
00116 
00117 /*     Set constants to control overflow */
00118 
00119     /* Parameter adjustments */
00120     a_dim1 = *lda;
00121     a_offset = 1 + a_dim1;
00122     a -= a_offset;
00123     --ipiv;
00124     --jpiv;
00125 
00126     /* Function Body */
00127     *info = 0;
00128     eps = dlamch_("P");
00129     smlnum = dlamch_("S") / eps;
00130     bignum = 1. / smlnum;
00131     dlabad_(&smlnum, &bignum);
00132 
00133 /*     Factorize A using complete pivoting. */
00134 /*     Set pivots less than SMIN to SMIN */
00135 
00136     i__1 = *n - 1;
00137     for (i__ = 1; i__ <= i__1; ++i__) {
00138 
00139 /*        Find max element in matrix A */
00140 
00141         xmax = 0.;
00142         i__2 = *n;
00143         for (ip = i__; ip <= i__2; ++ip) {
00144             i__3 = *n;
00145             for (jp = i__; jp <= i__3; ++jp) {
00146                 if (z_abs(&a[ip + jp * a_dim1]) >= xmax) {
00147                     xmax = z_abs(&a[ip + jp * a_dim1]);
00148                     ipv = ip;
00149                     jpv = jp;
00150                 }
00151 /* L10: */
00152             }
00153 /* L20: */
00154         }
00155         if (i__ == 1) {
00156 /* Computing MAX */
00157             d__1 = eps * xmax;
00158             smin = max(d__1,smlnum);
00159         }
00160 
00161 /*        Swap rows */
00162 
00163         if (ipv != i__) {
00164             zswap_(n, &a[ipv + a_dim1], lda, &a[i__ + a_dim1], lda);
00165         }
00166         ipiv[i__] = ipv;
00167 
00168 /*        Swap columns */
00169 
00170         if (jpv != i__) {
00171             zswap_(n, &a[jpv * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], &
00172                     c__1);
00173         }
00174         jpiv[i__] = jpv;
00175 
00176 /*        Check for singularity */
00177 
00178         if (z_abs(&a[i__ + i__ * a_dim1]) < smin) {
00179             *info = i__;
00180             i__2 = i__ + i__ * a_dim1;
00181             z__1.r = smin, z__1.i = 0.;
00182             a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00183         }
00184         i__2 = *n;
00185         for (j = i__ + 1; j <= i__2; ++j) {
00186             i__3 = j + i__ * a_dim1;
00187             z_div(&z__1, &a[j + i__ * a_dim1], &a[i__ + i__ * a_dim1]);
00188             a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00189 /* L30: */
00190         }
00191         i__2 = *n - i__;
00192         i__3 = *n - i__;
00193         zgeru_(&i__2, &i__3, &c_b10, &a[i__ + 1 + i__ * a_dim1], &c__1, &a[
00194                 i__ + (i__ + 1) * a_dim1], lda, &a[i__ + 1 + (i__ + 1) * 
00195                 a_dim1], lda);
00196 /* L40: */
00197     }
00198 
00199     if (z_abs(&a[*n + *n * a_dim1]) < smin) {
00200         *info = *n;
00201         i__1 = *n + *n * a_dim1;
00202         z__1.r = smin, z__1.i = 0.;
00203         a[i__1].r = z__1.r, a[i__1].i = z__1.i;
00204     }
00205     return 0;
00206 
00207 /*     End of ZGETC2 */
00208 
00209 } /* zgetc2_ */


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