1
SUBROUTINE ZGESC2( N, A, LDA, RHS, IPIV, JPIV, SCALE )
3
* -- LAPACK auxiliary routine (version 3.0) --
4
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5
* Courant Institute, Argonne National Lab, and Rice University
8
* .. Scalar Arguments ..
10
DOUBLE PRECISION SCALE
12
* .. Array Arguments ..
13
INTEGER IPIV( * ), JPIV( * )
14
COMPLEX*16 A( LDA, * ), RHS( * )
20
* ZGESC2 solves a system of linear equations
24
* with a general N-by-N matrix A using the LU factorization with
25
* complete pivoting computed by ZGETC2.
32
* The number of columns of the matrix A.
34
* A (input) COMPLEX*16 array, dimension (LDA, N)
35
* On entry, the LU part of the factorization of the n-by-n
36
* matrix A computed by ZGETC2: A = P * L * U * Q
39
* The leading dimension of the array A. LDA >= max(1, N).
41
* RHS (input/output) COMPLEX*16 array, dimension N.
42
* On entry, the right hand side vector b.
43
* On exit, the solution vector X.
45
* IPIV (iput) INTEGER array, dimension (N).
46
* The pivot indices; for 1 <= i <= N, row i of the
47
* matrix has been interchanged with row IPIV(i).
49
* JPIV (iput) INTEGER array, dimension (N).
50
* The pivot indices; for 1 <= j <= N, column j of the
51
* matrix has been interchanged with column JPIV(j).
53
* SCALE (output) DOUBLE PRECISION
54
* On exit, SCALE contains the scale factor. SCALE is chosen
55
* 0 <= SCALE <= 1 to prevent owerflow in the solution.
60
* Based on contributions by
61
* Bo Kagstrom and Peter Poromaa, Department of Computing Science,
62
* Umea University, S-901 87 Umea, Sweden.
64
* =====================================================================
67
DOUBLE PRECISION ZERO, ONE, TWO
68
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0 )
72
DOUBLE PRECISION BIGNUM, EPS, SMLNUM
75
* .. External Subroutines ..
76
EXTERNAL ZLASWP, ZSCAL
78
* .. External Functions ..
80
DOUBLE PRECISION DLAMCH
81
EXTERNAL IZAMAX, DLAMCH
83
* .. Intrinsic Functions ..
84
INTRINSIC ABS, DBLE, DCMPLX
86
* .. Executable Statements ..
88
* Set constant to control overflow
91
SMLNUM = DLAMCH( 'S' ) / EPS
93
CALL DLABAD( SMLNUM, BIGNUM )
95
* Apply permutations IPIV to RHS
97
CALL ZLASWP( 1, RHS, LDA, 1, N-1, IPIV, 1 )
103
RHS( J ) = RHS( J ) - A( J, I )*RHS( I )
113
I = IZAMAX( N, RHS, 1 )
114
IF( TWO*SMLNUM*ABS( RHS( I ) ).GT.ABS( A( N, N ) ) ) THEN
115
TEMP = DCMPLX( ONE / TWO, ZERO ) / ABS( RHS( I ) )
116
CALL ZSCAL( N, TEMP, RHS( 1 ), 1 )
117
SCALE = SCALE*DBLE( TEMP )
120
TEMP = DCMPLX( ONE, ZERO ) / A( I, I )
121
RHS( I ) = RHS( I )*TEMP
123
RHS( I ) = RHS( I ) - RHS( J )*( A( I, J )*TEMP )
127
* Apply permutations JPIV to the solution (RHS)
129
CALL ZLASWP( 1, RHS, LDA, 1, N-1, JPIV, -1 )