1 *> \brief \b SGETF2 computes the LU factorization of a general m-by-n matrix using partial pivoting with row interchanges (unblocked algorithm).
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SGETF2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgetf2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgetf2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgetf2.f">
21 * SUBROUTINE SGETF2( M, N, A, LDA, IPIV, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, LDA, M, N
26 * .. Array Arguments ..
37 *> SGETF2 computes an LU factorization of a general m-by-n matrix A
38 *> using partial pivoting with row interchanges.
40 *> The factorization has the form
42 *> where P is a permutation matrix, L is lower triangular with unit
43 *> diagonal elements (lower trapezoidal if m > n), and U is upper
44 *> triangular (upper trapezoidal if m < n).
46 *> This is the right-looking Level 2 BLAS version of the algorithm.
55 *> The number of rows of the matrix A. M >= 0.
61 *> The number of columns of the matrix A. N >= 0.
66 *> A is REAL array, dimension (LDA,N)
67 *> On entry, the m by n matrix to be factored.
68 *> On exit, the factors L and U from the factorization
69 *> A = P*L*U; the unit diagonal elements of L are not stored.
75 *> The leading dimension of the array A. LDA >= max(1,M).
80 *> IPIV is INTEGER array, dimension (min(M,N))
81 *> The pivot indices; for 1 <= i <= min(M,N), row i of the
82 *> matrix was interchanged with row IPIV(i).
88 *> = 0: successful exit
89 *> < 0: if INFO = -k, the k-th argument had an illegal value
90 *> > 0: if INFO = k, U(k,k) is exactly zero. The factorization
91 *> has been completed, but the factor U is exactly
92 *> singular, and division by zero will occur if it is used
93 *> to solve a system of equations.
99 *> \author Univ. of Tennessee
100 *> \author Univ. of California Berkeley
101 *> \author Univ. of Colorado Denver
104 *> \date September 2012
106 *> \ingroup realGEcomputational
108 * =====================================================================
109 SUBROUTINE SGETF2( M, N, A, LDA, IPIV, INFO )
111 * -- LAPACK computational routine (version 3.4.2) --
112 * -- LAPACK is a software package provided by Univ. of Tennessee, --
113 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
116 * .. Scalar Arguments ..
117 INTEGER INFO, LDA, M, N
119 * .. Array Arguments ..
124 * =====================================================================
128 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
130 * .. Local Scalars ..
134 * .. External Functions ..
137 EXTERNAL SLAMCH, ISAMAX
139 * .. External Subroutines ..
140 EXTERNAL SGER, SSCAL, SSWAP, XERBLA
142 * .. Intrinsic Functions ..
145 * .. Executable Statements ..
147 * Test the input parameters.
152 ELSE IF( N.LT.0 ) THEN
154 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
158 CALL XERBLA( 'SGETF2', -INFO )
162 * Quick return if possible
164 IF( M.EQ.0 .OR. N.EQ.0 )
167 * Compute machine safe minimum
171 DO 10 J = 1, MIN( M, N )
173 * Find pivot and test for singularity.
175 JP = J - 1 + ISAMAX( M-J+1, A( J, J ), 1 )
177 IF( A( JP, J ).NE.ZERO ) THEN
179 * Apply the interchange to columns 1:N.
182 $ CALL SSWAP( N, A( J, 1 ), LDA, A( JP, 1 ), LDA )
184 * Compute elements J+1:M of J-th column.
187 IF( ABS(A( J, J )) .GE. SFMIN ) THEN
188 CALL SSCAL( M-J, ONE / A( J, J ), A( J+1, J ), 1 )
191 A( J+I, J ) = A( J+I, J ) / A( J, J )
196 ELSE IF( INFO.EQ.0 ) THEN
201 IF( J.LT.MIN( M, N ) ) THEN
203 * Update trailing submatrix.
205 CALL SGER( M-J, N-J, -ONE, A( J+1, J ), 1, A( J, J+1 ), LDA,
206 $ A( J+1, J+1 ), LDA )