3 /* Table of constant values */
5 static integer c__1 = 1;
6 static doublereal c_b8 = -1.;
8 /* Subroutine */ int dgetf2_(integer *m, integer *n, doublereal *a, integer *
9 lda, integer *ipiv, integer *info)
11 /* System generated locals */
12 integer a_dim1, a_offset, i__1, i__2, i__3;
17 extern /* Subroutine */ int dger_(integer *, integer *, doublereal *,
18 doublereal *, integer *, doublereal *, integer *, doublereal *,
19 integer *), dscal_(integer *, doublereal *, doublereal *, integer
22 extern /* Subroutine */ int dswap_(integer *, doublereal *, integer *,
23 doublereal *, integer *);
24 extern doublereal dlamch_(char *);
25 extern integer idamax_(integer *, doublereal *, integer *);
26 extern /* Subroutine */ int xerbla_(char *, integer *);
29 /* -- LAPACK routine (version 3.1) -- */
30 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
33 /* .. Scalar Arguments .. */
35 /* .. Array Arguments .. */
41 /* DGETF2 computes an LU factorization of a general m-by-n matrix A */
42 /* using partial pivoting with row interchanges. */
44 /* The factorization has the form */
46 /* where P is a permutation matrix, L is lower triangular with unit */
47 /* diagonal elements (lower trapezoidal if m > n), and U is upper */
48 /* triangular (upper trapezoidal if m < n). */
50 /* This is the right-looking Level 2 BLAS version of the algorithm. */
55 /* M (input) INTEGER */
56 /* The number of rows of the matrix A. M >= 0. */
58 /* N (input) INTEGER */
59 /* The number of columns of the matrix A. N >= 0. */
61 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
62 /* On entry, the m by n matrix to be factored. */
63 /* On exit, the factors L and U from the factorization */
64 /* A = P*L*U; the unit diagonal elements of L are not stored. */
66 /* LDA (input) INTEGER */
67 /* The leading dimension of the array A. LDA >= max(1,M). */
69 /* IPIV (output) INTEGER array, dimension (min(M,N)) */
70 /* The pivot indices; for 1 <= i <= min(M,N), row i of the */
71 /* matrix was interchanged with row IPIV(i). */
73 /* INFO (output) INTEGER */
74 /* = 0: successful exit */
75 /* < 0: if INFO = -k, the k-th argument had an illegal value */
76 /* > 0: if INFO = k, U(k,k) is exactly zero. The factorization */
77 /* has been completed, but the factor U is exactly */
78 /* singular, and division by zero will occur if it is used */
79 /* to solve a system of equations. */
81 /* ===================================================================== */
83 /* .. Parameters .. */
85 /* .. Local Scalars .. */
87 /* .. External Functions .. */
89 /* .. External Subroutines .. */
91 /* .. Intrinsic Functions .. */
93 /* .. Executable Statements .. */
95 /* Test the input parameters. */
97 /* Parameter adjustments */
99 a_offset = 1 + a_dim1;
109 } else if (*lda < max(1,*m)) {
114 xerbla_("DGETF2", &i__1);
118 /* Quick return if possible */
120 if (*m == 0 || *n == 0) {
124 /* Compute machine safe minimum */
126 sfmin = dlamch_("S");
129 for (j = 1; j <= i__1; ++j) {
131 /* Find pivot and test for singularity. */
134 jp = j - 1 + idamax_(&i__2, &a[j + j * a_dim1], &c__1);
136 if (a[jp + j * a_dim1] != 0.) {
138 /* Apply the interchange to columns 1:N. */
141 dswap_(n, &a[j + a_dim1], lda, &a[jp + a_dim1], lda);
144 /* Compute elements J+1:M of J-th column. */
147 if ((d__1 = a[j + j * a_dim1], abs(d__1)) >= sfmin) {
149 d__1 = 1. / a[j + j * a_dim1];
150 dscal_(&i__2, &d__1, &a[j + 1 + j * a_dim1], &c__1);
153 for (i__ = 1; i__ <= i__2; ++i__) {
154 a[j + i__ + j * a_dim1] /= a[j + j * a_dim1];
160 } else if (*info == 0) {
165 if (j < min(*m,*n)) {
167 /* Update trailing submatrix. */
171 dger_(&i__2, &i__3, &c_b8, &a[j + 1 + j * a_dim1], &c__1, &a[j + (
172 j + 1) * a_dim1], lda, &a[j + 1 + (j + 1) * a_dim1], lda);