zgetf2.c
Go to the documentation of this file.
00001 /* zgetf2.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 doublecomplex c_b1 = {1.,0.};
00019 static integer c__1 = 1;
00020 
00021 /* Subroutine */ int zgetf2_(integer *m, integer *n, doublecomplex *a, 
00022         integer *lda, integer *ipiv, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, i__1, i__2, i__3;
00026     doublecomplex z__1;
00027 
00028     /* Builtin functions */
00029     double z_abs(doublecomplex *);
00030     void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00031 
00032     /* Local variables */
00033     integer i__, j, jp;
00034     doublereal sfmin;
00035     extern /* Subroutine */ int zscal_(integer *, doublecomplex *, 
00036             doublecomplex *, integer *), zgeru_(integer *, integer *, 
00037             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00038             integer *, doublecomplex *, integer *), zswap_(integer *, 
00039             doublecomplex *, integer *, doublecomplex *, integer *);
00040     extern doublereal dlamch_(char *);
00041     extern /* Subroutine */ int xerbla_(char *, integer *);
00042     extern integer izamax_(integer *, doublecomplex *, integer *);
00043 
00044 
00045 /*  -- LAPACK routine (version 3.2) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  ZGETF2 computes an LU factorization of a general m-by-n matrix A */
00058 /*  using partial pivoting with row interchanges. */
00059 
00060 /*  The factorization has the form */
00061 /*     A = P * L * U */
00062 /*  where P is a permutation matrix, L is lower triangular with unit */
00063 /*  diagonal elements (lower trapezoidal if m > n), and U is upper */
00064 /*  triangular (upper trapezoidal if m < n). */
00065 
00066 /*  This is the right-looking Level 2 BLAS version of the algorithm. */
00067 
00068 /*  Arguments */
00069 /*  ========= */
00070 
00071 /*  M       (input) INTEGER */
00072 /*          The number of rows of the matrix A.  M >= 0. */
00073 
00074 /*  N       (input) INTEGER */
00075 /*          The number of columns of the matrix A.  N >= 0. */
00076 
00077 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N) */
00078 /*          On entry, the m by n matrix to be factored. */
00079 /*          On exit, the factors L and U from the factorization */
00080 /*          A = P*L*U; the unit diagonal elements of L are not stored. */
00081 
00082 /*  LDA     (input) INTEGER */
00083 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00084 
00085 /*  IPIV    (output) INTEGER array, dimension (min(M,N)) */
00086 /*          The pivot indices; for 1 <= i <= min(M,N), row i of the */
00087 /*          matrix was interchanged with row IPIV(i). */
00088 
00089 /*  INFO    (output) INTEGER */
00090 /*          = 0: successful exit */
00091 /*          < 0: if INFO = -k, the k-th argument had an illegal value */
00092 /*          > 0: if INFO = k, U(k,k) is exactly zero. The factorization */
00093 /*               has been completed, but the factor U is exactly */
00094 /*               singular, and division by zero will occur if it is used */
00095 /*               to solve a system of equations. */
00096 
00097 /*  ===================================================================== */
00098 
00099 /*     .. Parameters .. */
00100 /*     .. */
00101 /*     .. Local Scalars .. */
00102 /*     .. */
00103 /*     .. External Functions .. */
00104 /*     .. */
00105 /*     .. External Subroutines .. */
00106 /*     .. */
00107 /*     .. Intrinsic Functions .. */
00108 /*     .. */
00109 /*     .. Executable Statements .. */
00110 
00111 /*     Test the input parameters. */
00112 
00113     /* Parameter adjustments */
00114     a_dim1 = *lda;
00115     a_offset = 1 + a_dim1;
00116     a -= a_offset;
00117     --ipiv;
00118 
00119     /* Function Body */
00120     *info = 0;
00121     if (*m < 0) {
00122         *info = -1;
00123     } else if (*n < 0) {
00124         *info = -2;
00125     } else if (*lda < max(1,*m)) {
00126         *info = -4;
00127     }
00128     if (*info != 0) {
00129         i__1 = -(*info);
00130         xerbla_("ZGETF2", &i__1);
00131         return 0;
00132     }
00133 
00134 /*     Quick return if possible */
00135 
00136     if (*m == 0 || *n == 0) {
00137         return 0;
00138     }
00139 
00140 /*     Compute machine safe minimum */
00141 
00142     sfmin = dlamch_("S");
00143 
00144     i__1 = min(*m,*n);
00145     for (j = 1; j <= i__1; ++j) {
00146 
00147 /*        Find pivot and test for singularity. */
00148 
00149         i__2 = *m - j + 1;
00150         jp = j - 1 + izamax_(&i__2, &a[j + j * a_dim1], &c__1);
00151         ipiv[j] = jp;
00152         i__2 = jp + j * a_dim1;
00153         if (a[i__2].r != 0. || a[i__2].i != 0.) {
00154 
00155 /*           Apply the interchange to columns 1:N. */
00156 
00157             if (jp != j) {
00158                 zswap_(n, &a[j + a_dim1], lda, &a[jp + a_dim1], lda);
00159             }
00160 
00161 /*           Compute elements J+1:M of J-th column. */
00162 
00163             if (j < *m) {
00164                 if (z_abs(&a[j + j * a_dim1]) >= sfmin) {
00165                     i__2 = *m - j;
00166                     z_div(&z__1, &c_b1, &a[j + j * a_dim1]);
00167                     zscal_(&i__2, &z__1, &a[j + 1 + j * a_dim1], &c__1);
00168                 } else {
00169                     i__2 = *m - j;
00170                     for (i__ = 1; i__ <= i__2; ++i__) {
00171                         i__3 = j + i__ + j * a_dim1;
00172                         z_div(&z__1, &a[j + i__ + j * a_dim1], &a[j + j * 
00173                                 a_dim1]);
00174                         a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00175 /* L20: */
00176                     }
00177                 }
00178             }
00179 
00180         } else if (*info == 0) {
00181 
00182             *info = j;
00183         }
00184 
00185         if (j < min(*m,*n)) {
00186 
00187 /*           Update trailing submatrix. */
00188 
00189             i__2 = *m - j;
00190             i__3 = *n - j;
00191             z__1.r = -1., z__1.i = -0.;
00192             zgeru_(&i__2, &i__3, &z__1, &a[j + 1 + j * a_dim1], &c__1, &a[j + 
00193                     (j + 1) * a_dim1], lda, &a[j + 1 + (j + 1) * a_dim1], lda)
00194                     ;
00195         }
00196 /* L10: */
00197     }
00198     return 0;
00199 
00200 /*     End of ZGETF2 */
00201 
00202 } /* zgetf2_ */


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