c@427
|
1 /* dgetrf.f -- translated by f2c (version 20061008).
|
c@427
|
2 You must link the resulting object file with libf2c:
|
c@427
|
3 on Microsoft Windows system, link with libf2c.lib;
|
c@427
|
4 on Linux or Unix systems, link with .../path/to/libf2c.a -lm
|
c@427
|
5 or, if you install libf2c.a in a standard place, with -lf2c -lm
|
c@427
|
6 -- in that order, at the end of the command line, as in
|
c@427
|
7 cc *.o -lf2c -lm
|
c@427
|
8 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
|
c@427
|
9
|
c@427
|
10 http://www.netlib.org/f2c/libf2c.zip
|
c@427
|
11 */
|
c@427
|
12
|
c@427
|
13 #include "f2c.h"
|
c@427
|
14 #include "blaswrap.h"
|
c@427
|
15
|
c@427
|
16 /* Table of constant values */
|
c@427
|
17
|
c@427
|
18 static integer c__1 = 1;
|
c@427
|
19 static integer c_n1 = -1;
|
c@427
|
20 static doublereal c_b16 = 1.;
|
c@427
|
21 static doublereal c_b19 = -1.;
|
c@427
|
22
|
c@427
|
23 /* Subroutine */ int dgetrf_(integer *m, integer *n, doublereal *a, integer *
|
c@427
|
24 lda, integer *ipiv, integer *info)
|
c@427
|
25 {
|
c@427
|
26 /* System generated locals */
|
c@427
|
27 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
|
c@427
|
28
|
c@427
|
29 /* Local variables */
|
c@427
|
30 integer i__, j, jb, nb;
|
c@427
|
31 extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *,
|
c@427
|
32 integer *, doublereal *, doublereal *, integer *, doublereal *,
|
c@427
|
33 integer *, doublereal *, doublereal *, integer *);
|
c@427
|
34 integer iinfo;
|
c@427
|
35 extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *,
|
c@427
|
36 integer *, integer *, doublereal *, doublereal *, integer *,
|
c@427
|
37 doublereal *, integer *), dgetf2_(
|
c@427
|
38 integer *, integer *, doublereal *, integer *, integer *, integer
|
c@427
|
39 *), xerbla_(char *, integer *);
|
c@427
|
40 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
|
c@427
|
41 integer *, integer *);
|
c@427
|
42 extern /* Subroutine */ int dlaswp_(integer *, doublereal *, integer *,
|
c@427
|
43 integer *, integer *, integer *, integer *);
|
c@427
|
44
|
c@427
|
45
|
c@427
|
46 /* -- LAPACK routine (version 3.2) -- */
|
c@427
|
47 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
|
c@427
|
48 /* November 2006 */
|
c@427
|
49
|
c@427
|
50 /* .. Scalar Arguments .. */
|
c@427
|
51 /* .. */
|
c@427
|
52 /* .. Array Arguments .. */
|
c@427
|
53 /* .. */
|
c@427
|
54
|
c@427
|
55 /* Purpose */
|
c@427
|
56 /* ======= */
|
c@427
|
57
|
c@427
|
58 /* DGETRF computes an LU factorization of a general M-by-N matrix A */
|
c@427
|
59 /* using partial pivoting with row interchanges. */
|
c@427
|
60
|
c@427
|
61 /* The factorization has the form */
|
c@427
|
62 /* A = P * L * U */
|
c@427
|
63 /* where P is a permutation matrix, L is lower triangular with unit */
|
c@427
|
64 /* diagonal elements (lower trapezoidal if m > n), and U is upper */
|
c@427
|
65 /* triangular (upper trapezoidal if m < n). */
|
c@427
|
66
|
c@427
|
67 /* This is the right-looking Level 3 BLAS version of the algorithm. */
|
c@427
|
68
|
c@427
|
69 /* Arguments */
|
c@427
|
70 /* ========= */
|
c@427
|
71
|
c@427
|
72 /* M (input) INTEGER */
|
c@427
|
73 /* The number of rows of the matrix A. M >= 0. */
|
c@427
|
74
|
c@427
|
75 /* N (input) INTEGER */
|
c@427
|
76 /* The number of columns of the matrix A. N >= 0. */
|
c@427
|
77
|
c@427
|
78 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
|
c@427
|
79 /* On entry, the M-by-N matrix to be factored. */
|
c@427
|
80 /* On exit, the factors L and U from the factorization */
|
c@427
|
81 /* A = P*L*U; the unit diagonal elements of L are not stored. */
|
c@427
|
82
|
c@427
|
83 /* LDA (input) INTEGER */
|
c@427
|
84 /* The leading dimension of the array A. LDA >= max(1,M). */
|
c@427
|
85
|
c@427
|
86 /* IPIV (output) INTEGER array, dimension (min(M,N)) */
|
c@427
|
87 /* The pivot indices; for 1 <= i <= min(M,N), row i of the */
|
c@427
|
88 /* matrix was interchanged with row IPIV(i). */
|
c@427
|
89
|
c@427
|
90 /* INFO (output) INTEGER */
|
c@427
|
91 /* = 0: successful exit */
|
c@427
|
92 /* < 0: if INFO = -i, the i-th argument had an illegal value */
|
c@427
|
93 /* > 0: if INFO = i, U(i,i) is exactly zero. The factorization */
|
c@427
|
94 /* has been completed, but the factor U is exactly */
|
c@427
|
95 /* singular, and division by zero will occur if it is used */
|
c@427
|
96 /* to solve a system of equations. */
|
c@427
|
97
|
c@427
|
98 /* ===================================================================== */
|
c@427
|
99
|
c@427
|
100 /* .. Parameters .. */
|
c@427
|
101 /* .. */
|
c@427
|
102 /* .. Local Scalars .. */
|
c@427
|
103 /* .. */
|
c@427
|
104 /* .. External Subroutines .. */
|
c@427
|
105 /* .. */
|
c@427
|
106 /* .. External Functions .. */
|
c@427
|
107 /* .. */
|
c@427
|
108 /* .. Intrinsic Functions .. */
|
c@427
|
109 /* .. */
|
c@427
|
110 /* .. Executable Statements .. */
|
c@427
|
111
|
c@427
|
112 /* Test the input parameters. */
|
c@427
|
113
|
c@427
|
114 /* Parameter adjustments */
|
c@427
|
115 a_dim1 = *lda;
|
c@427
|
116 a_offset = 1 + a_dim1;
|
c@427
|
117 a -= a_offset;
|
c@427
|
118 --ipiv;
|
c@427
|
119
|
c@427
|
120 /* Function Body */
|
c@427
|
121 *info = 0;
|
c@427
|
122 if (*m < 0) {
|
c@427
|
123 *info = -1;
|
c@427
|
124 } else if (*n < 0) {
|
c@427
|
125 *info = -2;
|
c@427
|
126 } else if (*lda < max(1,*m)) {
|
c@427
|
127 *info = -4;
|
c@427
|
128 }
|
c@427
|
129 if (*info != 0) {
|
c@427
|
130 i__1 = -(*info);
|
c@427
|
131 xerbla_("DGETRF", &i__1);
|
c@427
|
132 return 0;
|
c@427
|
133 }
|
c@427
|
134
|
c@427
|
135 /* Quick return if possible */
|
c@427
|
136
|
c@427
|
137 if (*m == 0 || *n == 0) {
|
c@427
|
138 return 0;
|
c@427
|
139 }
|
c@427
|
140
|
c@427
|
141 /* Determine the block size for this environment. */
|
c@427
|
142
|
c@427
|
143 nb = ilaenv_(&c__1, "DGETRF", " ", m, n, &c_n1, &c_n1);
|
c@427
|
144 if (nb <= 1 || nb >= min(*m,*n)) {
|
c@427
|
145
|
c@427
|
146 /* Use unblocked code. */
|
c@427
|
147
|
c@427
|
148 dgetf2_(m, n, &a[a_offset], lda, &ipiv[1], info);
|
c@427
|
149 } else {
|
c@427
|
150
|
c@427
|
151 /* Use blocked code. */
|
c@427
|
152
|
c@427
|
153 i__1 = min(*m,*n);
|
c@427
|
154 i__2 = nb;
|
c@427
|
155 for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
|
c@427
|
156 /* Computing MIN */
|
c@427
|
157 i__3 = min(*m,*n) - j + 1;
|
c@427
|
158 jb = min(i__3,nb);
|
c@427
|
159
|
c@427
|
160 /* Factor diagonal and subdiagonal blocks and test for exact */
|
c@427
|
161 /* singularity. */
|
c@427
|
162
|
c@427
|
163 i__3 = *m - j + 1;
|
c@427
|
164 dgetf2_(&i__3, &jb, &a[j + j * a_dim1], lda, &ipiv[j], &iinfo);
|
c@427
|
165
|
c@427
|
166 /* Adjust INFO and the pivot indices. */
|
c@427
|
167
|
c@427
|
168 if (*info == 0 && iinfo > 0) {
|
c@427
|
169 *info = iinfo + j - 1;
|
c@427
|
170 }
|
c@427
|
171 /* Computing MIN */
|
c@427
|
172 i__4 = *m, i__5 = j + jb - 1;
|
c@427
|
173 i__3 = min(i__4,i__5);
|
c@427
|
174 for (i__ = j; i__ <= i__3; ++i__) {
|
c@427
|
175 ipiv[i__] = j - 1 + ipiv[i__];
|
c@427
|
176 /* L10: */
|
c@427
|
177 }
|
c@427
|
178
|
c@427
|
179 /* Apply interchanges to columns 1:J-1. */
|
c@427
|
180
|
c@427
|
181 i__3 = j - 1;
|
c@427
|
182 i__4 = j + jb - 1;
|
c@427
|
183 dlaswp_(&i__3, &a[a_offset], lda, &j, &i__4, &ipiv[1], &c__1);
|
c@427
|
184
|
c@427
|
185 if (j + jb <= *n) {
|
c@427
|
186
|
c@427
|
187 /* Apply interchanges to columns J+JB:N. */
|
c@427
|
188
|
c@427
|
189 i__3 = *n - j - jb + 1;
|
c@427
|
190 i__4 = j + jb - 1;
|
c@427
|
191 dlaswp_(&i__3, &a[(j + jb) * a_dim1 + 1], lda, &j, &i__4, &
|
c@427
|
192 ipiv[1], &c__1);
|
c@427
|
193
|
c@427
|
194 /* Compute block row of U. */
|
c@427
|
195
|
c@427
|
196 i__3 = *n - j - jb + 1;
|
c@427
|
197 dtrsm_("Left", "Lower", "No transpose", "Unit", &jb, &i__3, &
|
c@427
|
198 c_b16, &a[j + j * a_dim1], lda, &a[j + (j + jb) *
|
c@427
|
199 a_dim1], lda);
|
c@427
|
200 if (j + jb <= *m) {
|
c@427
|
201
|
c@427
|
202 /* Update trailing submatrix. */
|
c@427
|
203
|
c@427
|
204 i__3 = *m - j - jb + 1;
|
c@427
|
205 i__4 = *n - j - jb + 1;
|
c@427
|
206 dgemm_("No transpose", "No transpose", &i__3, &i__4, &jb,
|
c@427
|
207 &c_b19, &a[j + jb + j * a_dim1], lda, &a[j + (j +
|
c@427
|
208 jb) * a_dim1], lda, &c_b16, &a[j + jb + (j + jb) *
|
c@427
|
209 a_dim1], lda);
|
c@427
|
210 }
|
c@427
|
211 }
|
c@427
|
212 /* L20: */
|
c@427
|
213 }
|
c@427
|
214 }
|
c@427
|
215 return 0;
|
c@427
|
216
|
c@427
|
217 /* End of DGETRF */
|
c@427
|
218
|
c@427
|
219 } /* dgetrf_ */
|