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