LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
zgetrf.f
Go to the documentation of this file.
1 C> \brief \b ZGETRF 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 ZGETRF ( M, N, A, LDA, IPIV, INFO)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER INFO, LDA, M, N
15 * ..
16 * .. Array Arguments ..
17 * INTEGER IPIV( * )
18 * COMPLEX*16 A( LDA, * )
19 * ..
20 *
21 * Purpose
22 * =======
23 *
24 C>\details \b Purpose:
25 C>\verbatim
26 C>
27 C> ZGETRF 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 COMPLEX*16 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 November 2011
97 *
98 C> \ingroup variantsGEcomputational
99 *
100 * =====================================================================
101  SUBROUTINE zgetrf ( M, N, A, LDA, IPIV, INFO)
102 *
103 * -- LAPACK computational routine (version 3.1) --
104 * -- LAPACK is a software package provided by Univ. of Tennessee, --
105 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
106 * November 2011
107 *
108 * .. Scalar Arguments ..
109  INTEGER INFO, LDA, M, N
110 * ..
111 * .. Array Arguments ..
112  INTEGER IPIV( * )
113  COMPLEX*16 A( lda, * )
114 * ..
115 *
116 * =====================================================================
117 *
118 * .. Parameters ..
119  COMPLEX*16 ONE
120  parameter ( one = (1.0d+0, 0.0d+0) )
121 * ..
122 * .. Local Scalars ..
123  INTEGER I, IINFO, J, JB, K, NB
124 * ..
125 * .. External Subroutines ..
126  EXTERNAL zgemm, zgetf2, zlaswp, ztrsm, xerbla
127 * ..
128 * .. External Functions ..
129  INTEGER ILAENV
130  EXTERNAL ilaenv
131 * ..
132 * .. Intrinsic Functions ..
133  INTRINSIC max, min
134 * ..
135 * .. Executable Statements ..
136 *
137 * Test the input parameters.
138 *
139  info = 0
140  IF( m.LT.0 ) THEN
141  info = -1
142  ELSE IF( n.LT.0 ) THEN
143  info = -2
144  ELSE IF( lda.LT.max( 1, m ) ) THEN
145  info = -4
146  END IF
147  IF( info.NE.0 ) THEN
148  CALL xerbla( 'ZGETRF', -info )
149  RETURN
150  END IF
151 *
152 * Quick return if possible
153 *
154  IF( m.EQ.0 .OR. n.EQ.0 )
155  $ RETURN
156 *
157 * Determine the block size for this environment.
158 *
159  nb = ilaenv( 1, 'ZGETRF', ' ', m, n, -1, -1 )
160  IF( nb.LE.1 .OR. nb.GE.min( m, n ) ) THEN
161 *
162 * Use unblocked code.
163 *
164  CALL zgetf2( m, n, a, lda, ipiv, info )
165 
166  ELSE
167 *
168 * Use blocked code.
169 *
170  DO 20 j = 1, min( m, n ), nb
171  jb = min( min( m, n )-j+1, nb )
172 *
173 *
174 * Update before factoring the current panel
175 *
176  DO 30 k = 1, j-nb, nb
177 *
178 * Apply interchanges to rows K:K+NB-1.
179 *
180  CALL zlaswp( jb, a(1, j), lda, k, k+nb-1, ipiv, 1 )
181 *
182 * Compute block row of U.
183 *
184  CALL ztrsm( 'Left', 'Lower', 'No transpose', 'Unit',
185  $ nb, jb, one, a( k, k ), lda,
186  $ a( k, j ), lda )
187 *
188 * Update trailing submatrix.
189 *
190  CALL zgemm( 'No transpose', 'No transpose',
191  $ m-k-nb+1, jb, nb, -one,
192  $ a( k+nb, k ), lda, a( k, j ), lda, one,
193  $ a( k+nb, j ), lda )
194  30 CONTINUE
195 *
196 * Factor diagonal and subdiagonal blocks and test for exact
197 * singularity.
198 *
199  CALL zgetf2( m-j+1, jb, a( j, j ), lda, ipiv( j ), iinfo )
200 *
201 * Adjust INFO and the pivot indices.
202 *
203  IF( info.EQ.0 .AND. iinfo.GT.0 )
204  $ info = iinfo + j - 1
205  DO 10 i = j, min( m, j+jb-1 )
206  ipiv( i ) = j - 1 + ipiv( i )
207  10 CONTINUE
208 *
209  20 CONTINUE
210 
211 *
212 * Apply interchanges to the left-overs
213 *
214  DO 40 k = 1, min( m, n ), nb
215  CALL zlaswp( k-1, a( 1, 1 ), lda, k,
216  $ min(k+nb-1, min( m, n )), ipiv, 1 )
217  40 CONTINUE
218 *
219 * Apply update to the M+1:N columns when N > M
220 *
221  IF ( n.GT.m ) THEN
222 
223  CALL zlaswp( n-m, a(1, m+1), lda, 1, m, ipiv, 1 )
224 
225  DO 50 k = 1, m, nb
226 
227  jb = min( m-k+1, nb )
228 *
229  CALL ztrsm( 'Left', 'Lower', 'No transpose', 'Unit',
230  $ jb, n-m, one, a( k, k ), lda,
231  $ a( k, m+1 ), lda )
232 
233 *
234  IF ( k+nb.LE.m ) THEN
235  CALL zgemm( 'No transpose', 'No transpose',
236  $ m-k-nb+1, n-m, nb, -one,
237  $ a( k+nb, k ), lda, a( k, m+1 ), lda, one,
238  $ a( k+nb, m+1 ), lda )
239  END IF
240  50 CONTINUE
241  END IF
242 *
243  END IF
244  RETURN
245 *
246 * End of ZGETRF
247 *
248  END
subroutine zgetf2(M, N, A, LDA, IPIV, INFO)
ZGETF2 computes the LU factorization of a general m-by-n matrix using partial pivoting with row inter...
Definition: zgetf2.f:110
subroutine zlaswp(N, A, LDA, K1, K2, IPIV, INCX)
ZLASWP performs a series of row interchanges on a general rectangular matrix.
Definition: zlaswp.f:116
subroutine zgetrf(M, N, A, LDA, IPIV, INFO)
ZGETRF VARIANT: Crout Level 3 BLAS version of the algorithm.
Definition: zgetrf.f:102
subroutine zgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
ZGEMM
Definition: zgemm.f:189
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