|
kusano |
2b45e8 |
SUBROUTINE ZGETRFF( M, N, A, LDA, IPIV, INFO )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* -- LAPACK routine (version 3.0) --
|
|
kusano |
2b45e8 |
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
|
|
kusano |
2b45e8 |
* Courant Institute, Argonne National Lab, and Rice University
|
|
kusano |
2b45e8 |
* September 30, 1994
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Scalar Arguments ..
|
|
kusano |
2b45e8 |
INTEGER INFO, LDA, M, N
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Array Arguments ..
|
|
kusano |
2b45e8 |
INTEGER IPIV( * )
|
|
kusano |
2b45e8 |
COMPLEX*16 A( LDA, * )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Purpose
|
|
kusano |
2b45e8 |
* =======
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* ZGETRF computes an LU factorization of a general M-by-N matrix A
|
|
kusano |
2b45e8 |
* using partial pivoting with row interchanges.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* The factorization has the form
|
|
kusano |
2b45e8 |
* A = P * L * U
|
|
kusano |
2b45e8 |
* where P is a permutation matrix, L is lower triangular with unit
|
|
kusano |
2b45e8 |
* diagonal elements (lower trapezoidal if m > n), and U is upper
|
|
kusano |
2b45e8 |
* triangular (upper trapezoidal if m < n).
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* This is the right-looking Level 3 BLAS version of the algorithm.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Arguments
|
|
kusano |
2b45e8 |
* =========
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* M (input) INTEGER
|
|
kusano |
2b45e8 |
* The number of rows of the matrix A. M >= 0.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* N (input) INTEGER
|
|
kusano |
2b45e8 |
* The number of columns of the matrix A. N >= 0.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* A (input/output) COMPLEX*16 array, dimension (LDA,N)
|
|
kusano |
2b45e8 |
* On entry, the M-by-N matrix to be factored.
|
|
kusano |
2b45e8 |
* On exit, the factors L and U from the factorization
|
|
kusano |
2b45e8 |
* A = P*L*U; the unit diagonal elements of L are not stored.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* LDA (input) INTEGER
|
|
kusano |
2b45e8 |
* The leading dimension of the array A. LDA >= max(1,M).
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* IPIV (output) INTEGER array, dimension (min(M,N))
|
|
kusano |
2b45e8 |
* The pivot indices; for 1 <= i <= min(M,N), row i of the
|
|
kusano |
2b45e8 |
* matrix was interchanged with row IPIV(i).
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* INFO (output) INTEGER
|
|
kusano |
2b45e8 |
* = 0: successful exit
|
|
kusano |
2b45e8 |
* < 0: if INFO = -i, the i-th argument had an illegal value
|
|
kusano |
2b45e8 |
* > 0: if INFO = i, U(i,i) is exactly zero. The factorization
|
|
kusano |
2b45e8 |
* has been completed, but the factor U is exactly
|
|
kusano |
2b45e8 |
* singular, and division by zero will occur if it is used
|
|
kusano |
2b45e8 |
* to solve a system of equations.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* =====================================================================
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Parameters ..
|
|
kusano |
2b45e8 |
COMPLEX*16 ONE
|
|
kusano |
2b45e8 |
PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Local Scalars ..
|
|
kusano |
2b45e8 |
INTEGER I, IINFO, J, JB, NB
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Subroutines ..
|
|
kusano |
2b45e8 |
EXTERNAL XERBLA, ZGEMM, ZGETF2, ZLASWP, ZTRSM
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Intrinsic Functions ..
|
|
kusano |
2b45e8 |
INTRINSIC MAX, MIN
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Executable Statements ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Test the input parameters.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
INFO = 0
|
|
kusano |
2b45e8 |
IF( M.LT.0 ) THEN
|
|
kusano |
2b45e8 |
INFO = -1
|
|
kusano |
2b45e8 |
ELSE IF( N.LT.0 ) THEN
|
|
kusano |
2b45e8 |
INFO = -2
|
|
kusano |
2b45e8 |
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
|
|
kusano |
2b45e8 |
INFO = -4
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
IF( INFO.NE.0 ) THEN
|
|
kusano |
2b45e8 |
CALL XERBLA( 'ZGETRF', -INFO )
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Quick return if possible
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( M.EQ.0 .OR. N.EQ.0 )
|
|
kusano |
2b45e8 |
$ RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Determine the block size for this environment.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
NB = 64
|
|
kusano |
2b45e8 |
IF( NB.LE.1 .OR. NB.GE.MIN( M, N ) ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Use unblocked code.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZGETF2( M, N, A, LDA, IPIV, INFO )
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Use blocked code.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
DO 20 J = 1, MIN( M, N ), NB
|
|
kusano |
2b45e8 |
JB = MIN( MIN( M, N )-J+1, NB )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Factor diagonal and subdiagonal blocks and test for exact
|
|
kusano |
2b45e8 |
* singularity.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZGETF2( M-J+1, JB, A( J, J ), LDA, IPIV( J ), IINFO )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Adjust INFO and the pivot indices.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( INFO.EQ.0 .AND. IINFO.GT.0 )
|
|
kusano |
2b45e8 |
$ INFO = IINFO + J - 1
|
|
kusano |
2b45e8 |
DO 10 I = J, MIN( M, J+JB-1 )
|
|
kusano |
2b45e8 |
IPIV( I ) = J - 1 + IPIV( I )
|
|
kusano |
2b45e8 |
10 CONTINUE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Apply interchanges to columns 1:J-1.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZLASWP( J-1, A, LDA, J, J+JB-1, IPIV, 1 )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( J+JB.LE.N ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Apply interchanges to columns J+JB:N.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZLASWP( N-J-JB+1, A( 1, J+JB ), LDA, J, J+JB-1,
|
|
kusano |
2b45e8 |
$ IPIV, 1 )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute block row of U.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZTRSM( 'Left', 'Lower', 'No transpose', 'Unit', JB,
|
|
kusano |
2b45e8 |
$ N-J-JB+1, ONE, A( J, J ), LDA, A( J, J+JB ),
|
|
kusano |
2b45e8 |
$ LDA )
|
|
kusano |
2b45e8 |
IF( J+JB.LE.M ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Update trailing submatrix.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZGEMM( 'No transpose', 'No transpose', M-J-JB+1,
|
|
kusano |
2b45e8 |
$ N-J-JB+1, JB, -ONE, A( J+JB, J ), LDA,
|
|
kusano |
2b45e8 |
$ A( J, J+JB ), LDA, ONE, A( J+JB, J+JB ),
|
|
kusano |
2b45e8 |
$ LDA )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
20 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* End of ZGETRF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
END
|