LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
zgetf2.f
Go to the documentation of this file.
1 *> \brief \b ZGETF2 computes the LU factorization of a general m-by-n matrix using partial pivoting with row interchanges (unblocked algorithm).
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download ZGETF2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgetf2.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgetf2.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgetf2.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE ZGETF2( M, N, A, LDA, IPIV, INFO )
22 *
23 * .. Scalar Arguments ..
24 * INTEGER INFO, LDA, M, N
25 * ..
26 * .. Array Arguments ..
27 * INTEGER IPIV( * )
28 * COMPLEX*16 A( LDA, * )
29 * ..
30 *
31 *
32 *> \par Purpose:
33 * =============
34 *>
35 *> \verbatim
36 *>
37 *> ZGETF2 computes an LU factorization of a general m-by-n matrix A
38 *> using partial pivoting with row interchanges.
39 *>
40 *> The factorization has the form
41 *> A = P * L * U
42 *> where P is a permutation matrix, L is lower triangular with unit
43 *> diagonal elements (lower trapezoidal if m > n), and U is upper
44 *> triangular (upper trapezoidal if m < n).
45 *>
46 *> This is the right-looking Level 2 BLAS version of the algorithm.
47 *> \endverbatim
48 *
49 * Arguments:
50 * ==========
51 *
52 *> \param[in] M
53 *> \verbatim
54 *> M is INTEGER
55 *> The number of rows of the matrix A. M >= 0.
56 *> \endverbatim
57 *>
58 *> \param[in] N
59 *> \verbatim
60 *> N is INTEGER
61 *> The number of columns of the matrix A. N >= 0.
62 *> \endverbatim
63 *>
64 *> \param[in,out] A
65 *> \verbatim
66 *> A is COMPLEX*16 array, dimension (LDA,N)
67 *> On entry, the m by n matrix to be factored.
68 *> On exit, the factors L and U from the factorization
69 *> A = P*L*U; the unit diagonal elements of L are not stored.
70 *> \endverbatim
71 *>
72 *> \param[in] LDA
73 *> \verbatim
74 *> LDA is INTEGER
75 *> The leading dimension of the array A. LDA >= max(1,M).
76 *> \endverbatim
77 *>
78 *> \param[out] IPIV
79 *> \verbatim
80 *> IPIV is INTEGER array, dimension (min(M,N))
81 *> The pivot indices; for 1 <= i <= min(M,N), row i of the
82 *> matrix was interchanged with row IPIV(i).
83 *> \endverbatim
84 *>
85 *> \param[out] INFO
86 *> \verbatim
87 *> INFO is INTEGER
88 *> = 0: successful exit
89 *> < 0: if INFO = -k, the k-th argument had an illegal value
90 *> > 0: if INFO = k, U(k,k) is exactly zero. The factorization
91 *> has been completed, but the factor U is exactly
92 *> singular, and division by zero will occur if it is used
93 *> to solve a system of equations.
94 *> \endverbatim
95 *
96 * Authors:
97 * ========
98 *
99 *> \author Univ. of Tennessee
100 *> \author Univ. of California Berkeley
101 *> \author Univ. of Colorado Denver
102 *> \author NAG Ltd.
103 *
104 *> \ingroup complex16GEcomputational
105 *
106 * =====================================================================
107  SUBROUTINE zgetf2( M, N, A, LDA, IPIV, INFO )
108 *
109 * -- LAPACK computational routine --
110 * -- LAPACK is a software package provided by Univ. of Tennessee, --
111 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
112 *
113 * .. Scalar Arguments ..
114  INTEGER INFO, LDA, M, N
115 * ..
116 * .. Array Arguments ..
117  INTEGER IPIV( * )
118  COMPLEX*16 A( LDA, * )
119 * ..
120 *
121 * =====================================================================
122 *
123 * .. Parameters ..
124  COMPLEX*16 ONE, ZERO
125  parameter( one = ( 1.0d+0, 0.0d+0 ),
126  $ zero = ( 0.0d+0, 0.0d+0 ) )
127 * ..
128 * .. Local Scalars ..
129  DOUBLE PRECISION SFMIN
130  INTEGER I, J, JP
131 * ..
132 * .. External Functions ..
133  DOUBLE PRECISION DLAMCH
134  INTEGER IZAMAX
135  EXTERNAL dlamch, izamax
136 * ..
137 * .. External Subroutines ..
138  EXTERNAL xerbla, zgeru, zscal, zswap
139 * ..
140 * .. Intrinsic Functions ..
141  INTRINSIC max, min
142 * ..
143 * .. Executable Statements ..
144 *
145 * Test the input parameters.
146 *
147  info = 0
148  IF( m.LT.0 ) THEN
149  info = -1
150  ELSE IF( n.LT.0 ) THEN
151  info = -2
152  ELSE IF( lda.LT.max( 1, m ) ) THEN
153  info = -4
154  END IF
155  IF( info.NE.0 ) THEN
156  CALL xerbla( 'ZGETF2', -info )
157  RETURN
158  END IF
159 *
160 * Quick return if possible
161 *
162  IF( m.EQ.0 .OR. n.EQ.0 )
163  $ RETURN
164 *
165 * Compute machine safe minimum
166 *
167  sfmin = dlamch('S')
168 *
169  DO 10 j = 1, min( m, n )
170 *
171 * Find pivot and test for singularity.
172 *
173  jp = j - 1 + izamax( m-j+1, a( j, j ), 1 )
174  ipiv( j ) = jp
175  IF( a( jp, j ).NE.zero ) THEN
176 *
177 * Apply the interchange to columns 1:N.
178 *
179  IF( jp.NE.j )
180  $ CALL zswap( n, a( j, 1 ), lda, a( jp, 1 ), lda )
181 *
182 * Compute elements J+1:M of J-th column.
183 *
184  IF( j.LT.m ) THEN
185  IF( abs(a( j, j )) .GE. sfmin ) THEN
186  CALL zscal( m-j, one / a( j, j ), a( j+1, j ), 1 )
187  ELSE
188  DO 20 i = 1, m-j
189  a( j+i, j ) = a( j+i, j ) / a( j, j )
190  20 CONTINUE
191  END IF
192  END IF
193 *
194  ELSE IF( info.EQ.0 ) THEN
195 *
196  info = j
197  END IF
198 *
199  IF( j.LT.min( m, n ) ) THEN
200 *
201 * Update trailing submatrix.
202 *
203  CALL zgeru( m-j, n-j, -one, a( j+1, j ), 1, a( j, j+1 ),
204  $ lda, a( j+1, j+1 ), lda )
205  END IF
206  10 CONTINUE
207  RETURN
208 *
209 * End of ZGETF2
210 *
211  END
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
subroutine zswap(N, ZX, INCX, ZY, INCY)
ZSWAP
Definition: zswap.f:81
subroutine zscal(N, ZA, ZX, INCX)
ZSCAL
Definition: zscal.f:78
subroutine zgeru(M, N, ALPHA, X, INCX, Y, INCY, A, LDA)
ZGERU
Definition: zgeru.f:130
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:108