3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * RECURSIVE SUBROUTINE CGETRF2( M, N, A, LDA, IPIV, INFO )
13 * .. Scalar Arguments ..
14 * INTEGER INFO, LDA, M, N
16 * .. Array Arguments ..
27 *> CGETRF2 computes an LU factorization of a general M-by-N matrix A
28 *> using partial pivoting with row interchanges.
30 *> The factorization has the form
32 *> where P is a permutation matrix, L is lower triangular with unit
33 *> diagonal elements (lower trapezoidal if m > n), and U is upper
34 *> triangular (upper trapezoidal if m < n).
36 *> This is the recursive version of the algorithm. It divides
37 *> the matrix into four submatrices:
39 *> [ A11 | A12 ] where A11 is n1 by n1 and A22 is n2 by n2
40 *> A = [ -----|----- ] with n1 = min(m,n)/2
41 *> [ A21 | A22 ] n2 = n-n1
44 *> The subroutine calls itself to factor [ --- ],
47 *> do the swaps on [ --- ], solve A12, update A22,
50 *> then calls itself to factor A22 and do the swaps on A21.
60 *> The number of rows of the matrix A. M >= 0.
66 *> The number of columns of the matrix A. N >= 0.
71 *> A is COMPLEX array, dimension (LDA,N)
72 *> On entry, the M-by-N matrix to be factored.
73 *> On exit, the factors L and U from the factorization
74 *> A = P*L*U; the unit diagonal elements of L are not stored.
80 *> The leading dimension of the array A. LDA >= max(1,M).
85 *> IPIV is INTEGER array, dimension (min(M,N))
86 *> The pivot indices; for 1 <= i <= min(M,N), row i of the
87 *> matrix was interchanged with row IPIV(i).
93 *> = 0: successful exit
94 *> < 0: if INFO = -i, the i-th argument had an illegal value
95 *> > 0: if INFO = i, U(i,i) is exactly zero. The factorization
96 *> has been completed, but the factor U is exactly
97 *> singular, and division by zero will occur if it is used
98 *> to solve a system of equations.
104 *> \author Univ. of Tennessee
105 *> \author Univ. of California Berkeley
106 *> \author Univ. of Colorado Denver
111 *> \ingroup complexGEcomputational
113 * =====================================================================
114 RECURSIVE SUBROUTINE CGETRF2( M, N, A, LDA, IPIV, INFO )
116 * -- LAPACK computational routine (version 3.6.1) --
117 * -- LAPACK is a software package provided by Univ. of Tennessee, --
118 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
121 * .. Scalar Arguments ..
122 INTEGER INFO, LDA, M, N
124 * .. Array Arguments ..
129 * =====================================================================
133 PARAMETER ( ONE = ( 1.0E+0, 0.0E+0 ),
134 $ ZERO = ( 0.0E+0, 0.0E+0 ) )
136 * .. Local Scalars ..
139 INTEGER I, IINFO, N1, N2
141 * .. External Functions ..
144 EXTERNAL SLAMCH, ICAMAX
146 * .. External Subroutines ..
147 EXTERNAL CGEMM, CSCAL, CLASWP, CTRSM, XERBLA
149 * .. Intrinsic Functions ..
152 * .. Executable Statements ..
154 * Test the input parameters
159 ELSE IF( N.LT.0 ) THEN
161 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
165 CALL XERBLA( 'CGETRF2', -INFO )
169 * Quick return if possible
171 IF( M.EQ.0 .OR. N.EQ.0 )
176 * Use unblocked code for one row case
177 * Just need to handle IPIV and INFO
180 IF ( A(1,1).EQ.ZERO )
183 ELSE IF( N.EQ.1 ) THEN
185 * Use unblocked code for one column case
188 * Compute machine safe minimum
192 * Find pivot and test for singularity
194 I = ICAMAX( M, A( 1, 1 ), 1 )
196 IF( A( I, 1 ).NE.ZERO ) THEN
198 * Apply the interchange
202 A( 1, 1 ) = A( I, 1 )
206 * Compute elements 2:M of the column
208 IF( ABS(A( 1, 1 )) .GE. SFMIN ) THEN
209 CALL CSCAL( M-1, ONE / A( 1, 1 ), A( 2, 1 ), 1 )
212 A( 1+I, 1 ) = A( 1+I, 1 ) / A( 1, 1 )
231 CALL CGETRF2( M, N1, A, LDA, IPIV, IINFO )
233 IF ( INFO.EQ.0 .AND. IINFO.GT.0 )
237 * Apply interchanges to [ --- ]
240 CALL CLASWP( N2, A( 1, N1+1 ), LDA, 1, N1, IPIV, 1 )
244 CALL CTRSM( 'L', 'L', 'N', 'U', N1, N2, ONE, A, LDA,
245 $ A( 1, N1+1 ), LDA )
249 CALL CGEMM( 'N', 'N', M-N1, N2, N1, -ONE, A( N1+1, 1 ), LDA,
250 $ A( 1, N1+1 ), LDA, ONE, A( N1+1, N1+1 ), LDA )
254 CALL CGETRF2( M-N1, N2, A( N1+1, N1+1 ), LDA, IPIV( N1+1 ),
257 * Adjust INFO and the pivot indices
259 IF ( INFO.EQ.0 .AND. IINFO.GT.0 )
261 DO 20 I = N1+1, MIN( M, N )
262 IPIV( I ) = IPIV( I ) + N1
265 * Apply interchanges to A21
267 CALL CLASWP( N1, A( 1, 1 ), LDA, N1+1, MIN( M, N), IPIV, 1 )