1 *> \brief \b SGETC2 computes the LU factorization with complete pivoting of the general n-by-n matrix.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SGETC2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgetc2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgetc2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgetc2.f">
21 * SUBROUTINE SGETC2( N, A, LDA, IPIV, JPIV, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, LDA, N
26 * .. Array Arguments ..
27 * INTEGER IPIV( * ), JPIV( * )
37 *> SGETC2 computes an LU factorization with complete pivoting of the
38 *> n-by-n matrix A. The factorization has the form A = P * L * U * Q,
39 *> where P and Q are permutation matrices, L is lower triangular with
40 *> unit diagonal elements and U is upper triangular.
42 *> This is the Level 2 BLAS algorithm.
51 *> The order of the matrix A. N >= 0.
56 *> A is REAL array, dimension (LDA, N)
57 *> On entry, the n-by-n matrix A to be factored.
58 *> On exit, the factors L and U from the factorization
59 *> A = P*L*U*Q; the unit diagonal elements of L are not stored.
60 *> If U(k, k) appears to be less than SMIN, U(k, k) is given the
61 *> value of SMIN, i.e., giving a nonsingular perturbed system.
67 *> The leading dimension of the array A. LDA >= max(1,N).
72 *> IPIV is INTEGER array, dimension(N).
73 *> The pivot indices; for 1 <= i <= N, row i of the
74 *> matrix has been interchanged with row IPIV(i).
79 *> JPIV is INTEGER array, dimension(N).
80 *> The pivot indices; for 1 <= j <= N, column j of the
81 *> matrix has been interchanged with column JPIV(j).
87 *> = 0: successful exit
88 *> > 0: if INFO = k, U(k, k) is likely to produce owerflow if
89 *> we try to solve for x in Ax = b. So U is perturbed to
90 *> avoid the overflow.
96 *> \author Univ. of Tennessee
97 *> \author Univ. of California Berkeley
98 *> \author Univ. of Colorado Denver
103 *> \ingroup realGEauxiliary
105 *> \par Contributors:
108 *> Bo Kagstrom and Peter Poromaa, Department of Computing Science,
109 *> Umea University, S-901 87 Umea, Sweden.
111 * =====================================================================
112 SUBROUTINE SGETC2( N, A, LDA, IPIV, JPIV, INFO )
114 * -- LAPACK auxiliary routine (version 3.6.1) --
115 * -- LAPACK is a software package provided by Univ. of Tennessee, --
116 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
119 * .. Scalar Arguments ..
122 * .. Array Arguments ..
123 INTEGER IPIV( * ), JPIV( * )
127 * =====================================================================
131 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
133 * .. Local Scalars ..
134 INTEGER I, IP, IPV, J, JP, JPV
135 REAL BIGNUM, EPS, SMIN, SMLNUM, XMAX
137 * .. External Subroutines ..
138 EXTERNAL SGER, SLABAD, SSWAP
140 * .. External Functions ..
144 * .. Intrinsic Functions ..
147 * .. Executable Statements ..
151 * Quick return if possible
156 * Set constants to control overflow
159 SMLNUM = SLAMCH( 'S' ) / EPS
160 BIGNUM = ONE / SMLNUM
161 CALL SLABAD( SMLNUM, BIGNUM )
163 * Handle the case N=1 by itself
168 IF( ABS( A( 1, 1 ) ).LT.SMLNUM ) THEN
175 * Factorize A using complete pivoting.
176 * Set pivots less than SMIN to SMIN.
180 * Find max element in matrix A
185 IF( ABS( A( IP, JP ) ).GE.XMAX ) THEN
186 XMAX = ABS( A( IP, JP ) )
193 $ SMIN = MAX( EPS*XMAX, SMLNUM )
198 $ CALL SSWAP( N, A( IPV, 1 ), LDA, A( I, 1 ), LDA )
204 $ CALL SSWAP( N, A( 1, JPV ), 1, A( 1, I ), 1 )
207 * Check for singularity
209 IF( ABS( A( I, I ) ).LT.SMIN ) THEN
214 A( J, I ) = A( J, I ) / A( I, I )
216 CALL SGER( N-I, N-I, -ONE, A( I+1, I ), 1, A( I, I+1 ), LDA,
217 $ A( I+1, I+1 ), LDA )
220 IF( ABS( A( N, N ) ).LT.SMIN ) THEN
225 * Set last pivots to N