3 /* Table of constant values */
5 static integer c__1 = 1;
6 static real c_b8 = -1.f;
8 /* Subroutine */ int sgetf2_(integer *m, integer *n, real *a, integer *lda,
9 integer *ipiv, integer *info)
11 /* System generated locals */
12 integer a_dim1, a_offset, i__1, i__2, i__3;
17 extern /* Subroutine */ int sger_(integer *, integer *, real *, real *,
18 integer *, real *, integer *, real *, integer *), sscal_(integer *
19 , real *, real *, integer *);
21 extern /* Subroutine */ int sswap_(integer *, real *, integer *, real *,
23 extern doublereal slamch_(char *);
24 extern /* Subroutine */ int xerbla_(char *, integer *);
25 extern integer isamax_(integer *, real *, integer *);
28 /* -- LAPACK routine (version 3.1) -- */
29 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
32 /* .. Scalar Arguments .. */
34 /* .. Array Arguments .. */
40 /* SGETF2 computes an LU factorization of a general m-by-n matrix A */
41 /* using partial pivoting with row interchanges. */
43 /* The factorization has the form */
45 /* where P is a permutation matrix, L is lower triangular with unit */
46 /* diagonal elements (lower trapezoidal if m > n), and U is upper */
47 /* triangular (upper trapezoidal if m < n). */
49 /* This is the right-looking Level 2 BLAS version of the algorithm. */
54 /* M (input) INTEGER */
55 /* The number of rows of the matrix A. M >= 0. */
57 /* N (input) INTEGER */
58 /* The number of columns of the matrix A. N >= 0. */
60 /* A (input/output) REAL array, dimension (LDA,N) */
61 /* On entry, the m by n matrix to be factored. */
62 /* On exit, the factors L and U from the factorization */
63 /* A = P*L*U; the unit diagonal elements of L are not stored. */
65 /* LDA (input) INTEGER */
66 /* The leading dimension of the array A. LDA >= max(1,M). */
68 /* IPIV (output) INTEGER array, dimension (min(M,N)) */
69 /* The pivot indices; for 1 <= i <= min(M,N), row i of the */
70 /* matrix was interchanged with row IPIV(i). */
72 /* INFO (output) INTEGER */
73 /* = 0: successful exit */
74 /* < 0: if INFO = -k, the k-th argument had an illegal value */
75 /* > 0: if INFO = k, U(k,k) is exactly zero. The factorization */
76 /* has been completed, but the factor U is exactly */
77 /* singular, and division by zero will occur if it is used */
78 /* to solve a system of equations. */
80 /* ===================================================================== */
82 /* .. Parameters .. */
84 /* .. Local Scalars .. */
86 /* .. External Functions .. */
88 /* .. External Subroutines .. */
90 /* .. Intrinsic Functions .. */
92 /* .. Executable Statements .. */
94 /* Test the input parameters. */
96 /* Parameter adjustments */
98 a_offset = 1 + a_dim1;
108 } else if (*lda < max(1,*m)) {
113 xerbla_("SGETF2", &i__1);
117 /* Quick return if possible */
119 if (*m == 0 || *n == 0) {
123 /* Compute machine safe minimum */
125 sfmin = slamch_("S");
128 for (j = 1; j <= i__1; ++j) {
130 /* Find pivot and test for singularity. */
133 jp = j - 1 + isamax_(&i__2, &a[j + j * a_dim1], &c__1);
135 if (a[jp + j * a_dim1] != 0.f) {
137 /* Apply the interchange to columns 1:N. */
140 sswap_(n, &a[j + a_dim1], lda, &a[jp + a_dim1], lda);
143 /* Compute elements J+1:M of J-th column. */
146 if ((r__1 = a[j + j * a_dim1], dabs(r__1)) >= sfmin) {
148 r__1 = 1.f / a[j + j * a_dim1];
149 sscal_(&i__2, &r__1, &a[j + 1 + j * a_dim1], &c__1);
152 for (i__ = 1; i__ <= i__2; ++i__) {
153 a[j + i__ + j * a_dim1] /= a[j + j * a_dim1];
159 } else if (*info == 0) {
164 if (j < min(*m,*n)) {
166 /* Update trailing submatrix. */
170 sger_(&i__2, &i__3, &c_b8, &a[j + 1 + j * a_dim1], &c__1, &a[j + (
171 j + 1) * a_dim1], lda, &a[j + 1 + (j + 1) * a_dim1], lda);