Chris@202: /* dgetf2.f -- translated by f2c (version 20061008). Chris@202: You must link the resulting object file with libf2c: Chris@202: on Microsoft Windows system, link with libf2c.lib; Chris@202: on Linux or Unix systems, link with .../path/to/libf2c.a -lm Chris@202: or, if you install libf2c.a in a standard place, with -lf2c -lm Chris@202: -- in that order, at the end of the command line, as in Chris@202: cc *.o -lf2c -lm Chris@202: Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., Chris@202: Chris@202: http://www.netlib.org/f2c/libf2c.zip Chris@202: */ Chris@202: Chris@202: #include "f2c.h" Chris@202: #include "blaswrap.h" Chris@202: Chris@202: /* Table of constant values */ Chris@202: Chris@202: static integer c__1 = 1; Chris@202: static doublereal c_b8 = -1.; Chris@202: Chris@202: /* Subroutine */ int dgetf2_(integer *m, integer *n, doublereal *a, integer * Chris@202: lda, integer *ipiv, integer *info) Chris@202: { Chris@202: /* System generated locals */ Chris@202: integer a_dim1, a_offset, i__1, i__2, i__3; Chris@202: doublereal d__1; Chris@202: Chris@202: /* Local variables */ Chris@202: integer i__, j, jp; Chris@202: extern /* Subroutine */ int dger_(integer *, integer *, doublereal *, Chris@202: doublereal *, integer *, doublereal *, integer *, doublereal *, Chris@202: integer *), dscal_(integer *, doublereal *, doublereal *, integer Chris@202: *); Chris@202: doublereal sfmin; Chris@202: extern /* Subroutine */ int dswap_(integer *, doublereal *, integer *, Chris@202: doublereal *, integer *); Chris@202: extern doublereal dlamch_(char *); Chris@202: extern integer idamax_(integer *, doublereal *, integer *); Chris@202: extern /* Subroutine */ int xerbla_(char *, integer *); Chris@202: Chris@202: Chris@202: /* -- LAPACK routine (version 3.2) -- */ Chris@202: /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ Chris@202: /* November 2006 */ Chris@202: Chris@202: /* .. Scalar Arguments .. */ Chris@202: /* .. */ Chris@202: /* .. Array Arguments .. */ Chris@202: /* .. */ Chris@202: Chris@202: /* Purpose */ Chris@202: /* ======= */ Chris@202: Chris@202: /* DGETF2 computes an LU factorization of a general m-by-n matrix A */ Chris@202: /* using partial pivoting with row interchanges. */ Chris@202: Chris@202: /* The factorization has the form */ Chris@202: /* A = P * L * U */ Chris@202: /* where P is a permutation matrix, L is lower triangular with unit */ Chris@202: /* diagonal elements (lower trapezoidal if m > n), and U is upper */ Chris@202: /* triangular (upper trapezoidal if m < n). */ Chris@202: Chris@202: /* This is the right-looking Level 2 BLAS version of the algorithm. */ Chris@202: Chris@202: /* Arguments */ Chris@202: /* ========= */ Chris@202: Chris@202: /* M (input) INTEGER */ Chris@202: /* The number of rows of the matrix A. M >= 0. */ Chris@202: Chris@202: /* N (input) INTEGER */ Chris@202: /* The number of columns of the matrix A. N >= 0. */ Chris@202: Chris@202: /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ Chris@202: /* On entry, the m by n matrix to be factored. */ Chris@202: /* On exit, the factors L and U from the factorization */ Chris@202: /* A = P*L*U; the unit diagonal elements of L are not stored. */ Chris@202: Chris@202: /* LDA (input) INTEGER */ Chris@202: /* The leading dimension of the array A. LDA >= max(1,M). */ Chris@202: Chris@202: /* IPIV (output) INTEGER array, dimension (min(M,N)) */ Chris@202: /* The pivot indices; for 1 <= i <= min(M,N), row i of the */ Chris@202: /* matrix was interchanged with row IPIV(i). */ Chris@202: Chris@202: /* INFO (output) INTEGER */ Chris@202: /* = 0: successful exit */ Chris@202: /* < 0: if INFO = -k, the k-th argument had an illegal value */ Chris@202: /* > 0: if INFO = k, U(k,k) is exactly zero. The factorization */ Chris@202: /* has been completed, but the factor U is exactly */ Chris@202: /* singular, and division by zero will occur if it is used */ Chris@202: /* to solve a system of equations. */ Chris@202: Chris@202: /* ===================================================================== */ Chris@202: Chris@202: /* .. Parameters .. */ Chris@202: /* .. */ Chris@202: /* .. Local Scalars .. */ Chris@202: /* .. */ Chris@202: /* .. External Functions .. */ Chris@202: /* .. */ Chris@202: /* .. External Subroutines .. */ Chris@202: /* .. */ Chris@202: /* .. Intrinsic Functions .. */ Chris@202: /* .. */ Chris@202: /* .. Executable Statements .. */ Chris@202: Chris@202: /* Test the input parameters. */ Chris@202: Chris@202: /* Parameter adjustments */ Chris@202: a_dim1 = *lda; Chris@202: a_offset = 1 + a_dim1; Chris@202: a -= a_offset; Chris@202: --ipiv; Chris@202: Chris@202: /* Function Body */ Chris@202: *info = 0; Chris@202: if (*m < 0) { Chris@202: *info = -1; Chris@202: } else if (*n < 0) { Chris@202: *info = -2; Chris@202: } else if (*lda < max(1,*m)) { Chris@202: *info = -4; Chris@202: } Chris@202: if (*info != 0) { Chris@202: i__1 = -(*info); Chris@202: xerbla_("DGETF2", &i__1); Chris@202: return 0; Chris@202: } Chris@202: Chris@202: /* Quick return if possible */ Chris@202: Chris@202: if (*m == 0 || *n == 0) { Chris@202: return 0; Chris@202: } Chris@202: Chris@202: /* Compute machine safe minimum */ Chris@202: Chris@202: sfmin = dlamch_("S"); Chris@202: Chris@202: i__1 = min(*m,*n); Chris@202: for (j = 1; j <= i__1; ++j) { Chris@202: Chris@202: /* Find pivot and test for singularity. */ Chris@202: Chris@202: i__2 = *m - j + 1; Chris@202: jp = j - 1 + idamax_(&i__2, &a[j + j * a_dim1], &c__1); Chris@202: ipiv[j] = jp; Chris@202: if (a[jp + j * a_dim1] != 0.) { Chris@202: Chris@202: /* Apply the interchange to columns 1:N. */ Chris@202: Chris@202: if (jp != j) { Chris@202: dswap_(n, &a[j + a_dim1], lda, &a[jp + a_dim1], lda); Chris@202: } Chris@202: Chris@202: /* Compute elements J+1:M of J-th column. */ Chris@202: Chris@202: if (j < *m) { Chris@202: if ((d__1 = a[j + j * a_dim1], abs(d__1)) >= sfmin) { Chris@202: i__2 = *m - j; Chris@202: d__1 = 1. / a[j + j * a_dim1]; Chris@202: dscal_(&i__2, &d__1, &a[j + 1 + j * a_dim1], &c__1); Chris@202: } else { Chris@202: i__2 = *m - j; Chris@202: for (i__ = 1; i__ <= i__2; ++i__) { Chris@202: a[j + i__ + j * a_dim1] /= a[j + j * a_dim1]; Chris@202: /* L20: */ Chris@202: } Chris@202: } Chris@202: } Chris@202: Chris@202: } else if (*info == 0) { Chris@202: Chris@202: *info = j; Chris@202: } Chris@202: Chris@202: if (j < min(*m,*n)) { Chris@202: Chris@202: /* Update trailing submatrix. */ Chris@202: Chris@202: i__2 = *m - j; Chris@202: i__3 = *n - j; Chris@202: dger_(&i__2, &i__3, &c_b8, &a[j + 1 + j * a_dim1], &c__1, &a[j + ( Chris@202: j + 1) * a_dim1], lda, &a[j + 1 + (j + 1) * a_dim1], lda); Chris@202: } Chris@202: /* L10: */ Chris@202: } Chris@202: return 0; Chris@202: Chris@202: /* End of DGETF2 */ Chris@202: Chris@202: } /* dgetf2_ */