1
SUBROUTINE GAL_DGETF2( M, N, A, LDA, IPIV, INFO )
3
* -- LAPACK routine (version 1.1) --
4
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5
* Courant Institute, Argonne National Lab, and Rice University
8
* .. Scalar Arguments ..
9
INTEGER INFO, LDA, M, N
11
* .. Array Arguments ..
13
DOUBLE PRECISION A( LDA, * )
19
* GAL_DGETF2 computes an LU factorization of a general m-by-n matrix A
20
* using partial pivoting with row interchanges.
22
* The factorization has the form
24
* where P is a permutation matrix, L is lower triangular with unit
25
* diagonal elements (lower trapezoidal if m > n), and U is upper
26
* triangular (upper trapezoidal if m < n).
28
* This is the right-looking Level 2 BLAS version of the algorithm.
34
* The number of rows of the matrix A. M >= 0.
37
* The number of columns of the matrix A. N >= 0.
39
* A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
40
* On entry, the m by n matrix to be factored.
41
* On exit, the factors L and U from the factorization
42
* A = P*L*U; the unit diagonal elements of L are not stored.
45
* The leading dimension of the array A. LDA >= max(1,M).
47
* IPIV (output) INTEGER array, dimension (min(M,N))
48
* The pivot indices; for 1 <= i <= min(M,N), row i of the
49
* matrix was interchanged with row IPIV(i).
51
* INFO (output) INTEGER
52
* = 0: successful exit
53
* < 0: if INFO = -k, the k-th argument had an illegal value
54
* > 0: if INFO = k, U(k,k) is exactly zero. The factorization
55
* has been completed, but the factor U is exactly
56
* singular, and division by zero will occur if it is used
57
* to solve a system of equations.
59
* =====================================================================
62
DOUBLE PRECISION ONE, ZERO
63
PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
68
* .. External Functions ..
72
* .. External Subroutines ..
73
EXTERNAL GAL_DGER, GAL_DSCAL, GAL_DSWAP, GAL_XERBLA
75
* .. Intrinsic Functions ..
78
* .. Executable Statements ..
80
* Test the input parameters.
85
ELSE IF( N.LT.0 ) THEN
87
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
91
CALL GAL_XERBLA( 'GAL_DGETF2', -INFO )
95
* Quick return if possible
97
IF( M.EQ.0 .OR. N.EQ.0 )
100
DO 10 J = 1, MIN( M, N )
102
* Find pivot and test for singularity.
104
JP = J - 1 + GAL_IDAMAX( M-J+1, A( J, J ), 1 )
106
IF( A( JP, J ).NE.ZERO ) THEN
108
* Apply the interchange to columns 1:N.
111
$ CALL GAL_DSWAP( N, A( J, 1 ), LDA, A( JP, 1 ), LDA )
113
* Compute elements J+1:M of J-th column.
116
$ CALL GAL_DSCAL( M-J, ONE / A( J, J ), A( J+1, J ), 1 )
118
ELSE IF( INFO.EQ.0 ) THEN
123
IF( J.LT.MIN( M, N ) ) THEN
125
* Update trailing submatrix.
127
CALL GAL_DGER( M-J, N-J, -ONE, A( J+1, J ), 1, A( J, J+1 ),
128
$ LDA, A( J+1, J+1 ), LDA )