LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ cgetc2()

subroutine cgetc2 ( integer n,
complex, dimension( lda, * ) a,
integer lda,
integer, dimension( * ) ipiv,
integer, dimension( * ) jpiv,
integer info )

CGETC2 computes the LU factorization with complete pivoting of the general n-by-n matrix.

Download CGETC2 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> CGETC2 computes an LU factorization, using complete pivoting, of the
!> n-by-n matrix A. The factorization has the form A = P * L * U * Q,
!> where P and Q are permutation matrices, L is lower triangular with
!> unit diagonal elements and U is upper triangular.
!>
!> This is a level 1 BLAS version of the algorithm.
!> 
Parameters
[in]N
!>          N is INTEGER
!>          The order of the matrix A. N >= 0.
!> 
[in,out]A
!>          A is COMPLEX array, dimension (LDA, N)
!>          On entry, the n-by-n matrix to be factored.
!>          On exit, the factors L and U from the factorization
!>          A = P*L*U*Q; the unit diagonal elements of L are not stored.
!>          If U(k, k) appears to be less than SMIN, U(k, k) is given the
!>          value of SMIN, giving a nonsingular perturbed system.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1, N).
!> 
[out]IPIV
!>          IPIV is INTEGER array, dimension (N).
!>          The pivot indices; for 1 <= i <= N, row i of the
!>          matrix has been interchanged with row IPIV(i).
!> 
[out]JPIV
!>          JPIV is INTEGER array, dimension (N).
!>          The pivot indices; for 1 <= j <= N, column j of the
!>          matrix has been interchanged with column JPIV(j).
!> 
[out]INFO
!>          INFO is INTEGER
!>           = 0: successful exit
!>           > 0: if INFO = k, U(k, k) is likely to produce overflow if
!>                one tries to solve for x in Ax = b. So U is perturbed
!>                to avoid the overflow.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Contributors:
Bo Kagstrom and Peter Poromaa, Department of Computing Science, Umea University, S-901 87 Umea, Sweden.

Definition at line 108 of file cgetc2.f.

109*
110* -- LAPACK auxiliary routine --
111* -- LAPACK is a software package provided by Univ. of Tennessee, --
112* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
113*
114* .. Scalar Arguments ..
115 INTEGER INFO, LDA, N
116* ..
117* .. Array Arguments ..
118 INTEGER IPIV( * ), JPIV( * )
119 COMPLEX A( LDA, * )
120* ..
121*
122* =====================================================================
123*
124* .. Parameters ..
125 REAL ZERO, ONE
126 parameter( zero = 0.0e+0, one = 1.0e+0 )
127* ..
128* .. Local Scalars ..
129 INTEGER I, IP, IPV, J, JP, JPV
130 REAL BIGNUM, EPS, SMIN, SMLNUM, XMAX
131* ..
132* .. External Subroutines ..
133 EXTERNAL cgeru, cswap
134* ..
135* .. External Functions ..
136 REAL SLAMCH
137 EXTERNAL slamch
138* ..
139* .. Intrinsic Functions ..
140 INTRINSIC abs, cmplx, max
141* ..
142* .. Executable Statements ..
143*
144 info = 0
145*
146* Quick return if possible
147*
148 IF( n.EQ.0 )
149 $ RETURN
150*
151* Set constants to control overflow
152*
153 eps = slamch( 'P' )
154 smlnum = slamch( 'S' ) / eps
155 bignum = one / smlnum
156*
157* Handle the case N=1 by itself
158*
159 IF( n.EQ.1 ) THEN
160 ipiv( 1 ) = 1
161 jpiv( 1 ) = 1
162 IF( abs( a( 1, 1 ) ).LT.smlnum ) THEN
163 info = 1
164 a( 1, 1 ) = cmplx( smlnum, zero )
165 END IF
166 RETURN
167 END IF
168*
169* Factorize A using complete pivoting.
170* Set pivots less than SMIN to SMIN
171*
172 DO 40 i = 1, n - 1
173*
174* Find max element in matrix A
175*
176 xmax = zero
177 DO 20 jp = i, n
178 DO 10 ip = i, n
179 IF( abs( a( ip, jp ) ).GE.xmax ) THEN
180 xmax = abs( a( ip, jp ) )
181 ipv = ip
182 jpv = jp
183 END IF
184 10 CONTINUE
185 20 CONTINUE
186 IF( i.EQ.1 )
187 $ smin = max( eps*xmax, smlnum )
188*
189* Swap rows
190*
191 IF( ipv.NE.i )
192 $ CALL cswap( n, a( ipv, 1 ), lda, a( i, 1 ), lda )
193 ipiv( i ) = ipv
194*
195* Swap columns
196*
197 IF( jpv.NE.i )
198 $ CALL cswap( n, a( 1, jpv ), 1, a( 1, i ), 1 )
199 jpiv( i ) = jpv
200*
201* Check for singularity
202*
203 IF( abs( a( i, i ) ).LT.smin ) THEN
204 info = i
205 a( i, i ) = cmplx( smin, zero )
206 END IF
207 DO 30 j = i + 1, n
208 a( j, i ) = a( j, i ) / a( i, i )
209 30 CONTINUE
210 CALL cgeru( n-i, n-i, -cmplx( one ), a( i+1, i ), 1,
211 $ a( i, i+1 ), lda, a( i+1, i+1 ), lda )
212 40 CONTINUE
213*
214 IF( abs( a( n, n ) ).LT.smin ) THEN
215 info = n
216 a( n, n ) = cmplx( smin, zero )
217 END IF
218*
219* Set last pivots to N
220*
221 ipiv( n ) = n
222 jpiv( n ) = n
223*
224 RETURN
225*
226* End of CGETC2
227*
subroutine cgeru(m, n, alpha, x, incx, y, incy, a, lda)
CGERU
Definition cgeru.f:130
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
subroutine cswap(n, cx, incx, cy, incy)
CSWAP
Definition cswap.f:81
Here is the call graph for this function:
Here is the caller graph for this function: