Chris@202: /* dgetrf.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 integer c_n1 = -1; Chris@202: static doublereal c_b16 = 1.; Chris@202: static doublereal c_b19 = -1.; Chris@202: Chris@202: /* Subroutine */ int dgetrf_(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, i__4, i__5; Chris@202: Chris@202: /* Local variables */ Chris@202: integer i__, j, jb, nb; Chris@202: extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, Chris@202: integer *, doublereal *, doublereal *, integer *, doublereal *, Chris@202: integer *, doublereal *, doublereal *, integer *); Chris@202: integer iinfo; Chris@202: extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *, Chris@202: integer *, integer *, doublereal *, doublereal *, integer *, Chris@202: doublereal *, integer *), dgetf2_( Chris@202: integer *, integer *, doublereal *, integer *, integer *, integer Chris@202: *), xerbla_(char *, integer *); Chris@202: extern integer ilaenv_(integer *, char *, char *, integer *, integer *, Chris@202: integer *, integer *); Chris@202: extern /* Subroutine */ int dlaswp_(integer *, doublereal *, integer *, Chris@202: integer *, integer *, integer *, 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: /* DGETRF 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 3 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 = -i, the i-th argument had an illegal value */ Chris@202: /* > 0: if INFO = i, U(i,i) 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 Subroutines .. */ Chris@202: /* .. */ Chris@202: /* .. External Functions .. */ 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_("DGETRF", &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: /* Determine the block size for this environment. */ Chris@202: Chris@202: nb = ilaenv_(&c__1, "DGETRF", " ", m, n, &c_n1, &c_n1); Chris@202: if (nb <= 1 || nb >= min(*m,*n)) { Chris@202: Chris@202: /* Use unblocked code. */ Chris@202: Chris@202: dgetf2_(m, n, &a[a_offset], lda, &ipiv[1], info); Chris@202: } else { Chris@202: Chris@202: /* Use blocked code. */ Chris@202: Chris@202: i__1 = min(*m,*n); Chris@202: i__2 = nb; Chris@202: for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) { Chris@202: /* Computing MIN */ Chris@202: i__3 = min(*m,*n) - j + 1; Chris@202: jb = min(i__3,nb); Chris@202: Chris@202: /* Factor diagonal and subdiagonal blocks and test for exact */ Chris@202: /* singularity. */ Chris@202: Chris@202: i__3 = *m - j + 1; Chris@202: dgetf2_(&i__3, &jb, &a[j + j * a_dim1], lda, &ipiv[j], &iinfo); Chris@202: Chris@202: /* Adjust INFO and the pivot indices. */ Chris@202: Chris@202: if (*info == 0 && iinfo > 0) { Chris@202: *info = iinfo + j - 1; Chris@202: } Chris@202: /* Computing MIN */ Chris@202: i__4 = *m, i__5 = j + jb - 1; Chris@202: i__3 = min(i__4,i__5); Chris@202: for (i__ = j; i__ <= i__3; ++i__) { Chris@202: ipiv[i__] = j - 1 + ipiv[i__]; Chris@202: /* L10: */ Chris@202: } Chris@202: Chris@202: /* Apply interchanges to columns 1:J-1. */ Chris@202: Chris@202: i__3 = j - 1; Chris@202: i__4 = j + jb - 1; Chris@202: dlaswp_(&i__3, &a[a_offset], lda, &j, &i__4, &ipiv[1], &c__1); Chris@202: Chris@202: if (j + jb <= *n) { Chris@202: Chris@202: /* Apply interchanges to columns J+JB:N. */ Chris@202: Chris@202: i__3 = *n - j - jb + 1; Chris@202: i__4 = j + jb - 1; Chris@202: dlaswp_(&i__3, &a[(j + jb) * a_dim1 + 1], lda, &j, &i__4, & Chris@202: ipiv[1], &c__1); Chris@202: Chris@202: /* Compute block row of U. */ Chris@202: Chris@202: i__3 = *n - j - jb + 1; Chris@202: dtrsm_("Left", "Lower", "No transpose", "Unit", &jb, &i__3, & Chris@202: c_b16, &a[j + j * a_dim1], lda, &a[j + (j + jb) * Chris@202: a_dim1], lda); Chris@202: if (j + jb <= *m) { Chris@202: Chris@202: /* Update trailing submatrix. */ Chris@202: Chris@202: i__3 = *m - j - jb + 1; Chris@202: i__4 = *n - j - jb + 1; Chris@202: dgemm_("No transpose", "No transpose", &i__3, &i__4, &jb, Chris@202: &c_b19, &a[j + jb + j * a_dim1], lda, &a[j + (j + Chris@202: jb) * a_dim1], lda, &c_b16, &a[j + jb + (j + jb) * Chris@202: a_dim1], lda); Chris@202: } Chris@202: } Chris@202: /* L20: */ Chris@202: } Chris@202: } Chris@202: return 0; Chris@202: Chris@202: /* End of DGETRF */ Chris@202: Chris@202: } /* dgetrf_ */