1 *> \brief \b CGESC2 solves a system of linear equations using the LU factorization with complete pivoting computed by sgetc2.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CGESC2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgesc2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgesc2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgesc2.f">
21 * SUBROUTINE CGESC2( N, A, LDA, RHS, IPIV, JPIV, SCALE )
23 * .. Scalar Arguments ..
27 * .. Array Arguments ..
28 * INTEGER IPIV( * ), JPIV( * )
29 * COMPLEX A( LDA, * ), RHS( * )
38 *> CGESC2 solves a system of linear equations
42 *> with a general N-by-N matrix A using the LU factorization with
43 *> complete pivoting computed by CGETC2.
53 *> The number of columns of the matrix A.
58 *> A is COMPLEX array, dimension (LDA, N)
59 *> On entry, the LU part of the factorization of the n-by-n
60 *> matrix A computed by CGETC2: A = P * L * U * Q
66 *> The leading dimension of the array A. LDA >= max(1, N).
71 *> RHS is COMPLEX array, dimension N.
72 *> On entry, the right hand side vector b.
73 *> On exit, the solution vector X.
78 *> IPIV is INTEGER array, dimension (N).
79 *> The pivot indices; for 1 <= i <= N, row i of the
80 *> matrix has been interchanged with row IPIV(i).
85 *> JPIV is INTEGER array, dimension (N).
86 *> The pivot indices; for 1 <= j <= N, column j of the
87 *> matrix has been interchanged with column JPIV(j).
93 *> On exit, SCALE contains the scale factor. SCALE is chosen
94 *> 0 <= SCALE <= 1 to prevent owerflow in the solution.
100 *> \author Univ. of Tennessee
101 *> \author Univ. of California Berkeley
102 *> \author Univ. of Colorado Denver
105 *> \date September 2012
107 *> \ingroup complexGEauxiliary
109 *> \par Contributors:
112 *> Bo Kagstrom and Peter Poromaa, Department of Computing Science,
113 *> Umea University, S-901 87 Umea, Sweden.
115 * =====================================================================
116 SUBROUTINE CGESC2( N, A, LDA, RHS, IPIV, JPIV, SCALE )
118 * -- LAPACK auxiliary routine (version 3.4.2) --
119 * -- LAPACK is a software package provided by Univ. of Tennessee, --
120 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
123 * .. Scalar Arguments ..
127 * .. Array Arguments ..
128 INTEGER IPIV( * ), JPIV( * )
129 COMPLEX A( LDA, * ), RHS( * )
132 * =====================================================================
136 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, TWO = 2.0E+0 )
138 * .. Local Scalars ..
140 REAL BIGNUM, EPS, SMLNUM
143 * .. External Subroutines ..
144 EXTERNAL CLASWP, CSCAL, SLABAD
146 * .. External Functions ..
149 EXTERNAL ICAMAX, SLAMCH
151 * .. Intrinsic Functions ..
152 INTRINSIC ABS, CMPLX, REAL
154 * .. Executable Statements ..
156 * Set constant to control overflow
159 SMLNUM = SLAMCH( 'S' ) / EPS
160 BIGNUM = ONE / SMLNUM
161 CALL SLABAD( SMLNUM, BIGNUM )
163 * Apply permutations IPIV to RHS
165 CALL CLASWP( 1, RHS, LDA, 1, N-1, IPIV, 1 )
171 RHS( J ) = RHS( J ) - A( J, I )*RHS( I )
181 I = ICAMAX( N, RHS, 1 )
182 IF( TWO*SMLNUM*ABS( RHS( I ) ).GT.ABS( A( N, N ) ) ) THEN
183 TEMP = CMPLX( ONE / TWO, ZERO ) / ABS( RHS( I ) )
184 CALL CSCAL( N, TEMP, RHS( 1 ), 1 )
185 SCALE = SCALE*REAL( TEMP )
188 TEMP = CMPLX( ONE, ZERO ) / A( I, I )
189 RHS( I ) = RHS( I )*TEMP
191 RHS( I ) = RHS( I ) - RHS( J )*( A( I, J )*TEMP )
195 * Apply permutations JPIV to the solution (RHS)
197 CALL CLASWP( 1, RHS, LDA, 1, N-1, JPIV, -1 )