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

## ◆ sgesc2()

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

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

Purpose:
``` SGESC2 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 SGETC2.```
Parameters
 [in] N ``` N is INTEGER The order of the matrix A.``` [in] A ``` A is REAL array, dimension (LDA,N) On entry, the LU part of the factorization of the n-by-n matrix A computed by SGETC2: 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 REAL 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.```
Contributors:
Bo Kagstrom and Peter Poromaa, Department of Computing Science, Umea University, S-901 87 Umea, Sweden.

Definition at line 113 of file sgesc2.f.

114*
115* -- LAPACK auxiliary routine --
116* -- LAPACK is a software package provided by Univ. of Tennessee, --
117* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
118*
119* .. Scalar Arguments ..
120 INTEGER LDA, N
121 REAL SCALE
122* ..
123* .. Array Arguments ..
124 INTEGER IPIV( * ), JPIV( * )
125 REAL A( LDA, * ), RHS( * )
126* ..
127*
128* =====================================================================
129*
130* .. Parameters ..
131 REAL ONE, TWO
132 parameter( one = 1.0e+0, two = 2.0e+0 )
133* ..
134* .. Local Scalars ..
135 INTEGER I, J
136 REAL BIGNUM, EPS, SMLNUM, TEMP
137* ..
138* .. External Subroutines ..
139 EXTERNAL slaswp, sscal
140* ..
141* .. External Functions ..
142 INTEGER ISAMAX
143 REAL SLAMCH
144 EXTERNAL isamax, slamch
145* ..
146* .. Intrinsic Functions ..
147 INTRINSIC abs
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 slaswp( 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 = isamax( n, rhs, 1 )
176 IF( two*smlnum*abs( rhs( i ) ).GT.abs( a( n, n ) ) ) THEN
177 temp = ( one / two ) / abs( rhs( i ) )
178 CALL sscal( n, temp, rhs( 1 ), 1 )
179 scale = scale*temp
180 END IF
181*
182 DO 40 i = n, 1, -1
183 temp = one / a( i, i )
184 rhs( i ) = rhs( i )*temp
185 DO 30 j = i + 1, n
186 rhs( i ) = rhs( i ) - rhs( j )*( a( i, j )*temp )
187 30 CONTINUE
188 40 CONTINUE
189*
190* Apply permutations JPIV to the solution (RHS)
191*
192 CALL slaswp( 1, rhs, lda, 1, n-1, jpiv, -1 )
193 RETURN
194*
195* End of SGESC2
196*
integer function isamax(n, sx, incx)
ISAMAX
Definition isamax.f:71
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
subroutine slaswp(n, a, lda, k1, k2, ipiv, incx)
SLASWP performs a series of row interchanges on a general rectangular matrix.
Definition slaswp.f:115
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
Here is the call graph for this function:
Here is the caller graph for this function: