3 /* Table of constant values */
5 static integer c__1 = 1;
6 static integer c_n1 = -1;
7 static real c_b16 = 1.f;
8 static real c_b19 = -1.f;
10 /* Subroutine */ int sgetrf_(integer *m, integer *n, real *a, integer *lda,
11 integer *ipiv, integer *info)
13 /* System generated locals */
14 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
17 integer i__, j, jb, nb, iinfo;
18 extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *,
19 integer *, real *, real *, integer *, real *, integer *, real *,
20 real *, integer *), strsm_(char *, char *, char *,
21 char *, integer *, integer *, real *, real *, integer *, real *,
22 integer *), sgetf2_(integer *,
23 integer *, real *, integer *, integer *, integer *), xerbla_(char
25 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
26 integer *, integer *);
27 extern /* Subroutine */ int slaswp_(integer *, real *, integer *, integer
28 *, integer *, integer *, integer *);
31 /* -- LAPACK routine (version 3.1) -- */
32 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
35 /* .. Scalar Arguments .. */
37 /* .. Array Arguments .. */
43 /* SGETRF computes an LU factorization of a general M-by-N matrix A */
44 /* using partial pivoting with row interchanges. */
46 /* The factorization has the form */
48 /* where P is a permutation matrix, L is lower triangular with unit */
49 /* diagonal elements (lower trapezoidal if m > n), and U is upper */
50 /* triangular (upper trapezoidal if m < n). */
52 /* This is the right-looking Level 3 BLAS version of the algorithm. */
57 /* M (input) INTEGER */
58 /* The number of rows of the matrix A. M >= 0. */
60 /* N (input) INTEGER */
61 /* The number of columns of the matrix A. N >= 0. */
63 /* A (input/output) REAL array, dimension (LDA,N) */
64 /* On entry, the M-by-N matrix to be factored. */
65 /* On exit, the factors L and U from the factorization */
66 /* A = P*L*U; the unit diagonal elements of L are not stored. */
68 /* LDA (input) INTEGER */
69 /* The leading dimension of the array A. LDA >= max(1,M). */
71 /* IPIV (output) INTEGER array, dimension (min(M,N)) */
72 /* The pivot indices; for 1 <= i <= min(M,N), row i of the */
73 /* matrix was interchanged with row IPIV(i). */
75 /* INFO (output) INTEGER */
76 /* = 0: successful exit */
77 /* < 0: if INFO = -i, the i-th argument had an illegal value */
78 /* > 0: if INFO = i, U(i,i) is exactly zero. The factorization */
79 /* has been completed, but the factor U is exactly */
80 /* singular, and division by zero will occur if it is used */
81 /* to solve a system of equations. */
83 /* ===================================================================== */
85 /* .. Parameters .. */
87 /* .. Local Scalars .. */
89 /* .. External Subroutines .. */
91 /* .. External Functions .. */
93 /* .. Intrinsic Functions .. */
95 /* .. Executable Statements .. */
97 /* Test the input parameters. */
99 /* Parameter adjustments */
101 a_offset = 1 + a_dim1;
111 } else if (*lda < max(1,*m)) {
116 xerbla_("SGETRF", &i__1);
120 /* Quick return if possible */
122 if (*m == 0 || *n == 0) {
126 /* Determine the block size for this environment. */
128 nb = ilaenv_(&c__1, "SGETRF", " ", m, n, &c_n1, &c_n1);
129 if (nb <= 1 || nb >= min(*m,*n)) {
131 /* Use unblocked code. */
133 sgetf2_(m, n, &a[a_offset], lda, &ipiv[1], info);
136 /* Use blocked code. */
140 for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
142 i__3 = min(*m,*n) - j + 1;
145 /* Factor diagonal and subdiagonal blocks and test for exact */
149 sgetf2_(&i__3, &jb, &a[j + j * a_dim1], lda, &ipiv[j], &iinfo);
151 /* Adjust INFO and the pivot indices. */
153 if (*info == 0 && iinfo > 0) {
154 *info = iinfo + j - 1;
157 i__4 = *m, i__5 = j + jb - 1;
158 i__3 = min(i__4,i__5);
159 for (i__ = j; i__ <= i__3; ++i__) {
160 ipiv[i__] = j - 1 + ipiv[i__];
164 /* Apply interchanges to columns 1:J-1. */
168 slaswp_(&i__3, &a[a_offset], lda, &j, &i__4, &ipiv[1], &c__1);
172 /* Apply interchanges to columns J+JB:N. */
174 i__3 = *n - j - jb + 1;
176 slaswp_(&i__3, &a[(j + jb) * a_dim1 + 1], lda, &j, &i__4, &
179 /* Compute block row of U. */
181 i__3 = *n - j - jb + 1;
182 strsm_("Left", "Lower", "No transpose", "Unit", &jb, &i__3, &
183 c_b16, &a[j + j * a_dim1], lda, &a[j + (j + jb) *
187 /* Update trailing submatrix. */
189 i__3 = *m - j - jb + 1;
190 i__4 = *n - j - jb + 1;
191 sgemm_("No transpose", "No transpose", &i__3, &i__4, &jb,
192 &c_b19, &a[j + jb + j * a_dim1], lda, &a[j + (j +
193 jb) * a_dim1], lda, &c_b16, &a[j + jb + (j + jb) *