Debian Codegraph @

SRC/VARIANTS/lu/LL/dgetrf.f

raw
1 C> \brief \b DGETRF VARIANT: left-looking Level 3 BLAS version of the algorithm.
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE DGETRF ( M, N, A, LDA, IPIV, INFO)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER INFO, LDA, M, N
15 * ..
16 * .. Array Arguments ..
17 * INTEGER IPIV( * )
18 * DOUBLE PRECISION A( LDA, * )
19 * ..
20 *
21 * Purpose
22 * =======
23 *
24 C>\details \b Purpose:
25 C>\verbatim
26 C>
27 C> DGETRF computes an LU factorization of a general M-by-N matrix A
28 C> using partial pivoting with row interchanges.
29 C>
30 C> The factorization has the form
31 C> A = P * L * U
32 C> where P is a permutation matrix, L is lower triangular with unit
33 C> diagonal elements (lower trapezoidal if m > n), and U is upper
34 C> triangular (upper trapezoidal if m < n).
35 C>
36 C> This is the left-looking Level 3 BLAS version of the algorithm.
37 C>
38 C>\endverbatim
39 *
40 * Arguments:
41 * ==========
42 *
43 C> \param[in] M
44 C> \verbatim
45 C> M is INTEGER
46 C> The number of rows of the matrix A. M >= 0.
47 C> \endverbatim
48 C>
49 C> \param[in] N
50 C> \verbatim
51 C> N is INTEGER
52 C> The number of columns of the matrix A. N >= 0.
53 C> \endverbatim
54 C>
55 C> \param[in,out] A
56 C> \verbatim
57 C> A is DOUBLE PRECISION array, dimension (LDA,N)
58 C> On entry, the M-by-N matrix to be factored.
59 C> On exit, the factors L and U from the factorization
60 C> A = P*L*U; the unit diagonal elements of L are not stored.
61 C> \endverbatim
62 C>
63 C> \param[in] LDA
64 C> \verbatim
65 C> LDA is INTEGER
66 C> The leading dimension of the array A. LDA >= max(1,M).
67 C> \endverbatim
68 C>
69 C> \param[out] IPIV
70 C> \verbatim
71 C> IPIV is INTEGER array, dimension (min(M,N))
72 C> The pivot indices; for 1 <= i <= min(M,N), row i of the
73 C> matrix was interchanged with row IPIV(i).
74 C> \endverbatim
75 C>
76 C> \param[out] INFO
77 C> \verbatim
78 C> INFO is INTEGER
79 C> = 0: successful exit
80 C> < 0: if INFO = -i, the i-th argument had an illegal value
81 C> > 0: if INFO = i, U(i,i) is exactly zero. The factorization
82 C> has been completed, but the factor U is exactly
83 C> singular, and division by zero will occur if it is used
84 C> to solve a system of equations.
85 C> \endverbatim
86 C>
87 *
88 * Authors:
89 * ========
90 *
91 C> \author Univ. of Tennessee
92 C> \author Univ. of California Berkeley
93 C> \author Univ. of Colorado Denver
94 C> \author NAG Ltd.
95 *
96 C> \date December 2016
97 *
98 C> \ingroup variantsGEcomputational
99 *
100 * =====================================================================
101 SUBROUTINE DGETRF ( M, N, A, LDA, IPIV, INFO)
102 *
103 * -- LAPACK computational routine --
104 * -- LAPACK is a software package provided by Univ. of Tennessee, --
105 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
106 *
107 * .. Scalar Arguments ..
108 INTEGER INFO, LDA, M, N
109 * ..
110 * .. Array Arguments ..
111 INTEGER IPIV( * )
112 DOUBLE PRECISION A( LDA, * )
113 * ..
114 *
115 * =====================================================================
116 *
117 * .. Parameters ..
118 DOUBLE PRECISION ONE
119 PARAMETER ( ONE = 1.0D+0 )
120 * ..
121 * .. Local Scalars ..
122 INTEGER I, IINFO, J, JB, K, NB
123 * ..
124 * .. External Subroutines ..
125 EXTERNAL DGEMM, DGETF2, DLASWP, DTRSM, XERBLA
126 * ..
127 * .. External Functions ..
128 INTEGER ILAENV
129 EXTERNAL ILAENV
130 * ..
131 * .. Intrinsic Functions ..
132 INTRINSIC MAX, MIN
133 * ..
134 * .. Executable Statements ..
135 *
136 * Test the input parameters.
137 *
138 INFO = 0
139 IF( M.LT.0 ) THEN
140 INFO = -1
141 ELSE IF( N.LT.0 ) THEN
142 INFO = -2
143 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
144 INFO = -4
145 END IF
146 IF( INFO.NE.0 ) THEN
147 CALL XERBLA( 'DGETRF', -INFO )
148 RETURN
149 END IF
150 *
151 * Quick return if possible
152 *
153 IF( M.EQ.0 .OR. N.EQ.0 )
154 $ RETURN
155 *
156 * Determine the block size for this environment.
157 *
158 NB = ILAENV( 1, 'DGETRF', ' ', M, N, -1, -1 )
159 IF( NB.LE.1 .OR. NB.GE.MIN( M, N ) ) THEN
160 *
161 * Use unblocked code.
162 *
163 CALL DGETF2( M, N, A, LDA, IPIV, INFO )
164
165 ELSE
166 *
167 * Use blocked code.
168 *
169 DO 20 J = 1, MIN( M, N ), NB
170 JB = MIN( MIN( M, N )-J+1, NB )
171 *
172 * Update before factoring the current panel
173 *
174 DO 30 K = 1, J-NB, NB
175 *
176 * Apply interchanges to rows K:K+NB-1.
177 *
178 CALL DLASWP( JB, A(1, J), LDA, K, K+NB-1, IPIV, 1 )
179 *
180 * Compute block row of U.
181 *
182 CALL DTRSM( 'Left', 'Lower', 'No transpose', 'Unit',
183 $ NB, JB, ONE, A( K, K ), LDA,
184 $ A( K, J ), LDA )
185 *
186 * Update trailing submatrix.
187 *
188 CALL DGEMM( 'No transpose', 'No transpose',
189 $ M-K-NB+1, JB, NB, -ONE,
190 $ A( K+NB, K ), LDA, A( K, J ), LDA, ONE,
191 $ A( K+NB, J ), LDA )
192 30 CONTINUE
193 *
194 * Factor diagonal and subdiagonal blocks and test for exact
195 * singularity.
196 *
197 CALL DGETF2( M-J+1, JB, A( J, J ), LDA, IPIV( J ), IINFO )
198 *
199 * Adjust INFO and the pivot indices.
200 *
201 IF( INFO.EQ.0 .AND. IINFO.GT.0 )
202 $ INFO = IINFO + J - 1
203 DO 10 I = J, MIN( M, J+JB-1 )
204 IPIV( I ) = J - 1 + IPIV( I )
205 10 CONTINUE
206 *
207 20 CONTINUE
208
209 *
210 * Apply interchanges to the left-overs
211 *
212 DO 40 K = 1, MIN( M, N ), NB
213 CALL DLASWP( K-1, A( 1, 1 ), LDA, K,
214 $ MIN (K+NB-1, MIN ( M, N )), IPIV, 1 )
215 40 CONTINUE
216 *
217 * Apply update to the M+1:N columns when N > M
218 *
219 IF ( N.GT.M ) THEN
220
221 CALL DLASWP( N-M, A(1, M+1), LDA, 1, M, IPIV, 1 )
222
223 DO 50 K = 1, M, NB
224
225 JB = MIN( M-K+1, NB )
226 *
227 CALL DTRSM( 'Left', 'Lower', 'No transpose', 'Unit',
228 $ JB, N-M, ONE, A( K, K ), LDA,
229 $ A( K, M+1 ), LDA )
230
231 *
232 IF ( K+NB.LE.M ) THEN
233 CALL DGEMM( 'No transpose', 'No transpose',
234 $ M-K-NB+1, N-M, NB, -ONE,
235 $ A( K+NB, K ), LDA, A( K, M+1 ), LDA, ONE,
236 $ A( K+NB, M+1 ), LDA )
237 END IF
238 50 CONTINUE
239 END IF
240 *
241 END IF
242 RETURN
243 *
244 * End of DGETRF
245 *
246 END