1 *> \brief \b SGESC2 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 SGESC2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgesc2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgesc2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgesc2.f">
21 * SUBROUTINE SGESC2( N, A, LDA, RHS, IPIV, JPIV, SCALE )
23 * .. Scalar Arguments ..
27 * .. Array Arguments ..
28 * INTEGER IPIV( * ), JPIV( * )
29 * REAL A( LDA, * ), RHS( * )
38 *> SGESC2 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 SGETC2.
52 *> The order of the matrix A.
57 *> A is REAL array, dimension (LDA,N)
58 *> On entry, the LU part of the factorization of the n-by-n
59 *> matrix A computed by SGETC2: A = P * L * U * Q
65 *> The leading dimension of the array A. LDA >= max(1, N).
70 *> RHS is REAL array, dimension (N).
71 *> On entry, the right hand side vector b.
72 *> On exit, the solution vector X.
77 *> IPIV is INTEGER array, dimension (N).
78 *> The pivot indices; for 1 <= i <= N, row i of the
79 *> matrix has been interchanged with row IPIV(i).
84 *> JPIV is INTEGER array, dimension (N).
85 *> The pivot indices; for 1 <= j <= N, column j of the
86 *> matrix has been interchanged with column JPIV(j).
92 *> On exit, SCALE contains the scale factor. SCALE is chosen
93 *> 0 <= SCALE <= 1 to prevent owerflow in the solution.
99 *> \author Univ. of Tennessee
100 *> \author Univ. of California Berkeley
101 *> \author Univ. of Colorado Denver
104 *> \date September 2012
106 *> \ingroup realGEauxiliary
108 *> \par Contributors:
111 *> Bo Kagstrom and Peter Poromaa, Department of Computing Science,
112 *> Umea University, S-901 87 Umea, Sweden.
114 * =====================================================================
115 SUBROUTINE SGESC2( N, A, LDA, RHS, IPIV, JPIV, SCALE )
117 * -- LAPACK auxiliary routine (version 3.4.2) --
118 * -- LAPACK is a software package provided by Univ. of Tennessee, --
119 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
122 * .. Scalar Arguments ..
126 * .. Array Arguments ..
127 INTEGER IPIV( * ), JPIV( * )
128 REAL A( LDA, * ), RHS( * )
131 * =====================================================================
135 PARAMETER ( ONE = 1.0E+0, TWO = 2.0E+0 )
137 * .. Local Scalars ..
139 REAL BIGNUM, EPS, SMLNUM, TEMP
141 * .. External Subroutines ..
142 EXTERNAL SLABAD, SLASWP, SSCAL
144 * .. External Functions ..
147 EXTERNAL ISAMAX, SLAMCH
149 * .. Intrinsic Functions ..
152 * .. Executable Statements ..
154 * Set constant to control owerflow
157 SMLNUM = SLAMCH( 'S' ) / EPS
158 BIGNUM = ONE / SMLNUM
159 CALL SLABAD( SMLNUM, BIGNUM )
161 * Apply permutations IPIV to RHS
163 CALL SLASWP( 1, RHS, LDA, 1, N-1, IPIV, 1 )
169 RHS( J ) = RHS( J ) - A( J, I )*RHS( I )
179 I = ISAMAX( N, RHS, 1 )
180 IF( TWO*SMLNUM*ABS( RHS( I ) ).GT.ABS( A( N, N ) ) ) THEN
181 TEMP = ( ONE / TWO ) / ABS( RHS( I ) )
182 CALL SSCAL( N, TEMP, RHS( 1 ), 1 )
187 TEMP = ONE / A( I, I )
188 RHS( I ) = RHS( I )*TEMP
190 RHS( I ) = RHS( I ) - RHS( J )*( A( I, J )*TEMP )
194 * Apply permutations JPIV to the solution (RHS)
196 CALL SLASWP( 1, RHS, LDA, 1, N-1, JPIV, -1 )