LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ zgetrf2()

recursive subroutine zgetrf2 ( integer  M,
integer  N,
complex*16, dimension( lda, * )  A,
integer  LDA,
integer, dimension( * )  IPIV,
integer  INFO 
)

ZGETRF2

Purpose:
 ZGETRF2 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 COMPLEX*16 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.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
June 2016

Definition at line 115 of file zgetrf2.f.

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