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

◆ 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 114 of file cgesc2.f.

115*
116* -- LAPACK auxiliary routine --
117* -- LAPACK is a software package provided by Univ. of Tennessee, --
118* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
119*
120* .. Scalar Arguments ..
121 INTEGER LDA, N
122 REAL SCALE
123* ..
124* .. Array Arguments ..
125 INTEGER IPIV( * ), JPIV( * )
126 COMPLEX A( LDA, * ), RHS( * )
127* ..
128*
129* =====================================================================
130*
131* .. Parameters ..
132 REAL ZERO, ONE, TWO
133 parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0 )
134* ..
135* .. Local Scalars ..
136 INTEGER I, J
137 REAL BIGNUM, EPS, SMLNUM
138 COMPLEX TEMP
139* ..
140* .. External Subroutines ..
141 EXTERNAL claswp, cscal
142* ..
143* .. External Functions ..
144 INTEGER ICAMAX
145 REAL SLAMCH
146 EXTERNAL icamax, slamch
147* ..
148* .. Intrinsic Functions ..
149 INTRINSIC abs, cmplx, real
150* ..
151* .. Executable Statements ..
152*
153* Set constant to control overflow
154*
155 eps = slamch( 'P' )
156 smlnum = slamch( 'S' ) / eps
157 bignum = one / smlnum
158*
159* Apply permutations IPIV to RHS
160*
161 CALL claswp( 1, rhs, lda, 1, n-1, ipiv, 1 )
162*
163* Solve for L part
164*
165 DO 20 i = 1, n - 1
166 DO 10 j = i + 1, n
167 rhs( j ) = rhs( j ) - a( j, i )*rhs( i )
168 10 CONTINUE
169 20 CONTINUE
170*
171* Solve for U part
172*
173 scale = one
174*
175* Check for scaling
176*
177 i = icamax( n, rhs, 1 )
178 IF( two*smlnum*abs( rhs( i ) ).GT.abs( a( n, n ) ) ) THEN
179 temp = cmplx( one / two, zero ) / abs( rhs( i ) )
180 CALL cscal( n, temp, rhs( 1 ), 1 )
181 scale = scale*real( temp )
182 END IF
183 DO 40 i = n, 1, -1
184 temp = cmplx( one, zero ) / a( i, i )
185 rhs( i ) = rhs( i )*temp
186 DO 30 j = i + 1, n
187 rhs( i ) = rhs( i ) - rhs( j )*( a( i, j )*temp )
188 30 CONTINUE
189 40 CONTINUE
190*
191* Apply permutations JPIV to the solution (RHS)
192*
193 CALL claswp( 1, rhs, lda, 1, n-1, jpiv, -1 )
194 RETURN
195*
196* End of CGESC2
197*
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:115
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: