LAPACK 3.11.0 LAPACK: Linear Algebra PACKage
Searching...
No Matches

## ◆ dgetrf2()

 recursive subroutine dgetrf2 ( integer M, integer N, double precision, dimension( lda, * ) A, integer LDA, integer, dimension( * ) IPIV, integer INFO )

DGETRF2

Purpose:
``` DGETRF2 computes an LU factorization of a general M-by-N matrix A
using partial pivoting with row interchanges.

The factorization has the form
A = P * L * U
where P is a permutation matrix, L is lower triangular with unit
diagonal elements (lower trapezoidal if m > n), and U is upper
triangular (upper trapezoidal if m < n).

This is the recursive version of the algorithm. It divides
the matrix into four submatrices:

[  A11 | A12  ]  where A11 is n1 by n1 and A22 is n2 by n2
A = [ -----|----- ]  with n1 = min(m,n)/2
[  A21 | A22  ]       n2 = n-n1

[ A11 ]
The subroutine calls itself to factor [ --- ],
[ A12 ]
[ A12 ]
do the swaps on [ --- ], solve A12, update A22,
[ A22 ]

then calls itself to factor A22 and do the swaps on A21.```
Parameters
 [in] M ``` M is INTEGER The number of rows of the matrix A. M >= 0.``` [in] N ``` N is INTEGER The number of columns of the matrix A. N >= 0.``` [in,out] A ``` A is DOUBLE PRECISION array, dimension (LDA,N) On entry, the M-by-N matrix to be factored. On exit, the factors L and U from the factorization A = P*L*U; the unit diagonal elements of L are not stored.``` [in] LDA ``` LDA is INTEGER The leading dimension of the array A. LDA >= max(1,M).``` [out] IPIV ``` IPIV is INTEGER array, dimension (min(M,N)) The pivot indices; for 1 <= i <= min(M,N), row i of the matrix was interchanged with row IPIV(i).``` [out] INFO ``` INFO is INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = i, U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.```

Definition at line 112 of file dgetrf2.f.

113*
114* -- LAPACK computational routine --
115* -- LAPACK is a software package provided by Univ. of Tennessee, --
116* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
117*
118* .. Scalar Arguments ..
119 INTEGER INFO, LDA, M, N
120* ..
121* .. Array Arguments ..
122 INTEGER IPIV( * )
123 DOUBLE PRECISION A( LDA, * )
124* ..
125*
126* =====================================================================
127*
128* .. Parameters ..
129 DOUBLE PRECISION ONE, ZERO
130 parameter( one = 1.0d+0, zero = 0.0d+0 )
131* ..
132* .. Local Scalars ..
133 DOUBLE PRECISION SFMIN, TEMP
134 INTEGER I, IINFO, N1, N2
135* ..
136* .. External Functions ..
137 DOUBLE PRECISION DLAMCH
138 INTEGER IDAMAX
139 EXTERNAL dlamch, idamax
140* ..
141* .. External Subroutines ..
142 EXTERNAL dgemm, dscal, dlaswp, dtrsm, xerbla
143* ..
144* .. Intrinsic Functions ..
145 INTRINSIC max, min
146* ..
147* .. Executable Statements ..
148*
149* Test the input parameters
150*
151 info = 0
152 IF( m.LT.0 ) THEN
153 info = -1
154 ELSE IF( n.LT.0 ) THEN
155 info = -2
156 ELSE IF( lda.LT.max( 1, m ) ) THEN
157 info = -4
158 END IF
159 IF( info.NE.0 ) THEN
160 CALL xerbla( 'DGETRF2', -info )
161 RETURN
162 END IF
163*
164* Quick return if possible
165*
166 IF( m.EQ.0 .OR. n.EQ.0 )
167 \$ RETURN
168
169 IF ( m.EQ.1 ) THEN
170*
171* Use unblocked code for one row case
172* Just need to handle IPIV and INFO
173*
174 ipiv( 1 ) = 1
175 IF ( a(1,1).EQ.zero )
176 \$ info = 1
177*
178 ELSE IF( n.EQ.1 ) THEN
179*
180* Use unblocked code for one column case
181*
182*
183* Compute machine safe minimum
184*
185 sfmin = dlamch('S')
186*
187* Find pivot and test for singularity
188*
189 i = idamax( m, a( 1, 1 ), 1 )
190 ipiv( 1 ) = i
191 IF( a( i, 1 ).NE.zero ) THEN
192*
193* Apply the interchange
194*
195 IF( i.NE.1 ) THEN
196 temp = a( 1, 1 )
197 a( 1, 1 ) = a( i, 1 )
198 a( i, 1 ) = temp
199 END IF
200*
201* Compute elements 2:M of the column
202*
203 IF( abs(a( 1, 1 )) .GE. sfmin ) THEN
204 CALL dscal( m-1, one / a( 1, 1 ), a( 2, 1 ), 1 )
205 ELSE
206 DO 10 i = 1, m-1
207 a( 1+i, 1 ) = a( 1+i, 1 ) / a( 1, 1 )
208 10 CONTINUE
209 END IF
210*
211 ELSE
212 info = 1
213 END IF
214*
215 ELSE
216*
217* Use recursive code
218*
219 n1 = min( m, n ) / 2
220 n2 = n-n1
221*
222* [ A11 ]
223* Factor [ --- ]
224* [ A21 ]
225*
226 CALL dgetrf2( m, n1, a, lda, ipiv, iinfo )
227
228 IF ( info.EQ.0 .AND. iinfo.GT.0 )
229 \$ info = iinfo
230*
231* [ A12 ]
232* Apply interchanges to [ --- ]
233* [ A22 ]
234*
235 CALL dlaswp( n2, a( 1, n1+1 ), lda, 1, n1, ipiv, 1 )
236*
237* Solve A12
238*
239 CALL dtrsm( 'L', 'L', 'N', 'U', n1, n2, one, a, lda,
240 \$ a( 1, n1+1 ), lda )
241*
242* Update A22
243*
244 CALL dgemm( 'N', 'N', m-n1, n2, n1, -one, a( n1+1, 1 ), lda,
245 \$ a( 1, n1+1 ), lda, one, a( n1+1, n1+1 ), lda )
246*
247* Factor A22
248*
249 CALL dgetrf2( m-n1, n2, a( n1+1, n1+1 ), lda, ipiv( n1+1 ),
250 \$ iinfo )
251*
252* Adjust INFO and the pivot indices
253*
254 IF ( info.EQ.0 .AND. iinfo.GT.0 )
255 \$ info = iinfo + n1
256 DO 20 i = n1+1, min( m, n )
257 ipiv( i ) = ipiv( i ) + n1
258 20 CONTINUE
259*
260* Apply interchanges to A21
261*
262 CALL dlaswp( n1, a( 1, 1 ), lda, n1+1, min( m, n), ipiv, 1 )
263*
264 END IF
265 RETURN
266*
267* End of DGETRF2
268*
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:69
integer function idamax(N, DX, INCX)
IDAMAX
Definition: idamax.f:71
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
subroutine dscal(N, DA, DX, INCX)
DSCAL
Definition: dscal.f:79
subroutine dtrsm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
DTRSM
Definition: dtrsm.f:181
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DGEMM
Definition: dgemm.f:187
recursive subroutine dgetrf2(M, N, A, LDA, IPIV, INFO)
DGETRF2
Definition: dgetrf2.f:113
subroutine dlaswp(N, A, LDA, K1, K2, IPIV, INCX)
DLASWP performs a series of row interchanges on a general rectangular matrix.
Definition: dlaswp.f:115
Here is the call graph for this function:
Here is the caller graph for this function: