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

◆ zgesc2()

subroutine zgesc2 ( integer n,
complex*16, dimension( lda, * ) a,
integer lda,
complex*16, dimension( * ) rhs,
integer, dimension( * ) ipiv,
integer, dimension( * ) jpiv,
double precision scale )

ZGESC2 solves a system of linear equations using the LU factorization with complete pivoting computed by sgetc2.

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

Purpose:
!>
!> ZGESC2 solves a system of linear equations
!>
!>           A * X = scale* RHS
!>
!> with a general N-by-N matrix A using the LU factorization with
!> complete pivoting computed by ZGETC2.
!>
!> 
Parameters
[in]N
!>          N is INTEGER
!>          The number of columns of the matrix A.
!> 
[in]A
!>          A is COMPLEX*16 array, dimension (LDA, N)
!>          On entry, the  LU part of the factorization of the n-by-n
!>          matrix A computed by ZGETC2:  A = P * L * U * Q
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1, N).
!> 
[in,out]RHS
!>          RHS is COMPLEX*16 array, dimension N.
!>          On entry, the right hand side vector b.
!>          On exit, the solution vector X.
!> 
[in]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).
!> 
[in]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]SCALE
!>          SCALE is DOUBLE PRECISION
!>           On exit, SCALE contains the scale factor. SCALE is chosen
!>           0 <= SCALE <= 1 to prevent overflow in the solution.
!> 
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 112 of file zgesc2.f.

113*
114* -- LAPACK auxiliary routine --
115* -- LAPACK is a software package provided by Univ. of Tennessee, --
116* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
117*
118* .. Scalar Arguments ..
119 INTEGER LDA, N
120 DOUBLE PRECISION SCALE
121* ..
122* .. Array Arguments ..
123 INTEGER IPIV( * ), JPIV( * )
124 COMPLEX*16 A( LDA, * ), RHS( * )
125* ..
126*
127* =====================================================================
128*
129* .. Parameters ..
130 DOUBLE PRECISION ZERO, ONE, TWO
131 parameter( zero = 0.0d+0, one = 1.0d+0, two = 2.0d+0 )
132* ..
133* .. Local Scalars ..
134 INTEGER I, J
135 DOUBLE PRECISION BIGNUM, EPS, SMLNUM
136 COMPLEX*16 TEMP
137* ..
138* .. External Subroutines ..
139 EXTERNAL zlaswp, zscal
140* ..
141* .. External Functions ..
142 INTEGER IZAMAX
143 DOUBLE PRECISION DLAMCH
144 EXTERNAL izamax, dlamch
145* ..
146* .. Intrinsic Functions ..
147 INTRINSIC abs, dble, dcmplx
148* ..
149* .. Executable Statements ..
150*
151* Set constant to control overflow
152*
153 eps = dlamch( 'P' )
154 smlnum = dlamch( 'S' ) / eps
155 bignum = one / smlnum
156*
157* Apply permutations IPIV to RHS
158*
159 CALL zlaswp( 1, rhs, lda, 1, n-1, ipiv, 1 )
160*
161* Solve for L part
162*
163 DO 20 i = 1, n - 1
164 DO 10 j = i + 1, n
165 rhs( j ) = rhs( j ) - a( j, i )*rhs( i )
166 10 CONTINUE
167 20 CONTINUE
168*
169* Solve for U part
170*
171 scale = one
172*
173* Check for scaling
174*
175 i = izamax( n, rhs, 1 )
176 IF( two*smlnum*abs( rhs( i ) ).GT.abs( a( n, n ) ) ) THEN
177 temp = dcmplx( one / two, zero ) / abs( rhs( i ) )
178 CALL zscal( n, temp, rhs( 1 ), 1 )
179 scale = scale*dble( temp )
180 END IF
181 DO 40 i = n, 1, -1
182 temp = dcmplx( one, zero ) / a( i, i )
183 rhs( i ) = rhs( i )*temp
184 DO 30 j = i + 1, n
185 rhs( i ) = rhs( i ) - rhs( j )*( a( i, j )*temp )
186 30 CONTINUE
187 40 CONTINUE
188*
189* Apply permutations JPIV to the solution (RHS)
190*
191 CALL zlaswp( 1, rhs, lda, 1, n-1, jpiv, -1 )
192 RETURN
193*
194* End of ZGESC2
195*
integer function izamax(n, zx, incx)
IZAMAX
Definition izamax.f:71
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
subroutine zlaswp(n, a, lda, k1, k2, ipiv, incx)
ZLASWP performs a series of row interchanges on a general rectangular matrix.
Definition zlaswp.f:113
subroutine zscal(n, za, zx, incx)
ZSCAL
Definition zscal.f:78
Here is the call graph for this function:
Here is the caller graph for this function: