LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages

◆ cgesc2()

subroutine cgesc2 ( integer n,
complex, dimension( lda, * ) a,
integer lda,
complex, dimension( * ) rhs,
integer, dimension( * ) ipiv,
integer, dimension( * ) jpiv,
real scale )

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

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

Purpose:
!> !> CGESC2 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 CGETC2. !> !>
Parameters
[in]N
!> N is INTEGER !> The number of columns of the matrix A. !>
[in]A
!> A is COMPLEX array, dimension (LDA, N) !> On entry, the LU part of the factorization of the n-by-n !> matrix A computed by CGETC2: 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 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 REAL !> 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 cgesc2.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 REAL SCALE
121* ..
122* .. Array Arguments ..
123 INTEGER IPIV( * ), JPIV( * )
124 COMPLEX A( LDA, * ), RHS( * )
125* ..
126*
127* =====================================================================
128*
129* .. Parameters ..
130 REAL ZERO, ONE, TWO
131 parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0 )
132* ..
133* .. Local Scalars ..
134 INTEGER I, J
135 REAL BIGNUM, EPS, SMLNUM
136 COMPLEX TEMP
137* ..
138* .. External Subroutines ..
139 EXTERNAL claswp, cscal
140* ..
141* .. External Functions ..
142 INTEGER ICAMAX
143 REAL SLAMCH
144 EXTERNAL icamax, slamch
145* ..
146* .. Intrinsic Functions ..
147 INTRINSIC abs, cmplx, real
148* ..
149* .. Executable Statements ..
150*
151* Set constant to control overflow
152*
153 eps = slamch( 'P' )
154 smlnum = slamch( 'S' ) / eps
155 bignum = one / smlnum
156*
157* Apply permutations IPIV to RHS
158*
159 CALL claswp( 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 = icamax( n, rhs, 1 )
176 IF( two*smlnum*abs( rhs( i ) ).GT.abs( a( n, n ) ) ) THEN
177 temp = cmplx( one / two, zero ) / abs( rhs( i ) )
178 CALL cscal( n, temp, rhs( 1 ), 1 )
179 scale = scale*real( temp )
180 END IF
181 DO 40 i = n, 1, -1
182 temp = cmplx( 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 claswp( 1, rhs, lda, 1, n-1, jpiv, -1 )
192 RETURN
193*
194* End of CGESC2
195*
integer function icamax(n, cx, incx)
ICAMAX
Definition icamax.f:71
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
subroutine claswp(n, a, lda, k1, k2, ipiv, incx)
CLASWP performs a series of row interchanges on a general rectangular matrix.
Definition claswp.f:113
subroutine cscal(n, ca, cx, incx)
CSCAL
Definition cscal.f:78
Here is the call graph for this function:
Here is the caller graph for this function: