LFTRG

   more...

   more...
Computes the LU factorization of a real general matrix.
Required Arguments
AN by N matrix to be factored. (Input)
FACTN by N matrix containing the LU factorization of the matrix A. (Output)
If A is not needed, A and FACT can share the same storage locations.
IPVT — Vector of length N containing the pivoting information for the LU factorization. (Output)
Optional Arguments
N — Order of the matrix. (Input)
Default: N = size (A,2).
LDA — Leading dimension of A exactly as specified in the dimension statement of the calling program. (Input)
Default: LDA = size (A,1).
LDFACT — Leading dimension of FACT exactly as specified in the dimension statement of the calling program. (Input)
Default: LDFACT = size (FACT,1).
FORTRAN 90 Interface
Generic: CALL LFTRG (A, FACT, IPVT [])
Specific: The specific interface names are S_LFTRG and D_LFTRG.
FORTRAN 77 Interface
Single: CALL LFTRG (N, A, LDA, FACT, LDFACT, IPVT)
Double: The double precision name is DLFTRG.
ScaLAPACK Interface
Generic: CALL LFTRG (A0, FACT0, IPVT0 [])
Specific: The specific interface names are S_LFTRG and D_LFTRG.
See the ScaLAPACK Usage Notes below for a description of the arguments for distributed computing.
Description
Routine LFTRG performs an LU factorization of a real general coefficient matrix. The underlying code is based on either LINPACK , LAPACK, or ScaLAPACK code depending upon which supporting libraries are used during linking. For a detailed explanation see Using ScaLAPACK, LAPACK, LINPACK, and EISPACK in the Introduction section of this manual. The LU factorization is done using scaled partial pivoting. Scaled partial pivoting differs from partial pivoting in that the pivoting strategy is the same as if each row were scaled to have the same norm. Otherwise, partial pivoting is used.
The routine LFTRG fails if U, the upper triangular part of the factorization, has a zero diagonal element. This can occur only if A is singular or very close to a singular matrix.
The LU factors are returned in a form that is compatible with routines LFIRG, LFSRG and LFDRG. To solve systems of equations with multiple right-hand-side vectors, use LFTRG followed by either LFIRG or LFSRG called once for each right-hand side. The routine LFDRG can be called to compute the determinant of the coefficient matrix after LFTRG has performed the factorization. Let F be the matrix FACT and let p be the vector IPVT. The triangular matrix U is stored in the upper triangle of F. The strict lower triangle of F contains the information needed to reconstruct L-1 using
L-1 = LN-1PN-1 . . . L1 P1
where Pk is the identity matrix with rows k and pk interchanged and Lk is the identity with Fik for i = k + 1,   N inserted below the diagonal. The strict lower half of F can also be thought of as containing the negative of the multipliers.
Routine LFTRG is based on the LINPACK routine SGEFA. See Dongarra et al. (1979). The routine SGEFA uses partial pivoting.
Comments
1. Workspace may be explicitly provided, if desired, by use of L2TRG/ DL2TRG. The reference is:
CALL L2TRG (N, A, LDA, FACT, LDFACT, IPVT, WK)
The additional argument is:
WK — Work vector of length N used for scaling.
2. Informational error
Type
Code
Description
4
2
The input matrix is singular.
ScaLAPACK Usage Notes
The arguments which differ from the standard version of this routine are:
A0MXLDA by MXCOL local matrix containing the local portions of the distributed matrix A. A contains the matrix to be factored. (Input)
FACT0MXLDA by MXCOL local matrix containing the local portions of the distributed matrix FACT. FACT contains the LU factorization of the matrix A. (Output)
IPVT0 — Local vector of length MXLDA containing the local portions of the distributed vector IPVT. IPVT contains the pivoting information for the LU factorization. (Output)
All other arguments are global and are the same as described for the standard version of the routine. In the argument descriptions above, MXLDA and MXCOL can be obtained through a call to SCALAPACK_GETDIM (see Utilities) after a call to SCALAPACK_SETUP (see Utilities) has been made. See the ScaLAPACK Example below.
Examples
Example 1
A linear system with multiple right-hand sides is solved. Routine LFTRG is called to factor the coefficient matrix. The routine LFSRG is called to compute the two solutions for the two right-hand sides. In this case, the coefficient matrix is assumed to be well-conditioned and correctly scaled. Otherwise, it would be better to call LFCRG to perform the factorization, and LFIRG to compute the solutions.
 
USE LFTRG_INT
USE LFSRG_INT
USE WRRRN_INT
! Declare variables
PARAMETER (LDA=3, LDFACT=3, N=3)
INTEGER IPVT(N), J
REAL A(LDA,LDA), B(N,2), FACT(LDFACT,LDFACT), X(N,2)
!
! Set values for A and B
!
! A = ( 1.0 3.0 3.0)
! ( 1.0 3.0 4.0)
! ( 1.0 4.0 3.0)
!
! B = ( 1.0 10.0)
! ( 4.0 14.0)
! ( -1.0 9.0)
!
DATA A/1.0, 1.0, 1.0, 3.0, 3.0, 4.0, 3.0, 4.0, 3.0/
DATA B/1.0, 4.0, -1.0, 10.0, 14.0, 9.0/
!
CALL LFTRG (A, FACT, IPVT)
! Solve for the two right-hand sides
DO 10 J=1, 2
CALL LFSRG (FACT, IPVT, B(:,J), X(:,J))
10 CONTINUE
! Print results
CALL WRRRN (’X’, X)
END
Output
 
X
1 2
1 -2.000 1.000
2 -2.000 -1.000
3 3.000 4.000
ScaLAPACK Example
A linear system with multiple right-hand sides is solved. Routine LFTRG is called to factor the coefficient matrix. The routine LFSRG is called to compute the two solutions for the two right-hand sides. In this case, the coefficient matrix is assumed to be well-conditioned and correctly scaled. Otherwise, it would be better to call LFCRG to perform the factorization, and LFIRG to compute the solutions. SCALAPACK_MAP and SCALAPACK_UNMAP are IMSL utility routines (see Chapter 11, “Utilities”) used to map and unmap arrays to and from the processor grid. They are used here for brevity. DESCINIT is a ScaLAPACK tools routine which initializes the descriptors for the local arrays.
 
USE MPI_SETUP_INT
USE LFTRG_INT
USE LFSRG_INT
USE WRRRN_INT
USE SCALAPACK_SUPPORT
IMPLICIT NONE
INCLUDE ‘mpif.h’
! Declare variables
INTEGER J, LDA, N, DESCA(9), DESCL(9)
INTEGER INFO, MXCOL, MXLDA
INTEGER, ALLOCATABLE :: IPVT0(:)
REAL, ALLOCATABLE :: A(:,:), B(:,:), X(:,:), X0(:)
REAL, ALLOCATABLE :: A0(:,:), FACT0(:,:), B0(:)
PARAMETER (LDA=3, N=3)
! Set up for MPI
MP_NPROCS = MP_SETUP()
IF(MP_RANK .EQ. 0) THEN
ALLOCATE (A(LDA,N), B(N,2), X(N,2))
! Set values for A and B
A(1,:) = (/ 1.0, 3.0, 3.0/)
A(2,:) = (/ 1.0, 3.0, 4.0/)
A(3,:) = (/ 1.0, 4.0, 3.0/)
!
B(1,:) = (/ 1.0, 10.0/)
B(2,:) = (/ 4.0, 14.0/)
B(3,:) = (/-1.0, 9.0/)
ENDIF
! Set up a 1D processor grid and define
! its context id, MP_ICTXT
CALL SCALAPACK_SETUP(N, N, .TRUE., .TRUE.)
! Get the array descriptor entities MXLDA,
! and MXCOL
CALL SCALAPACK_GETDIM(N, N, MP_MB, MP_NB, MXLDA, MXCOL)
! Set up the array descriptors
CALL DESCINIT(DESCA, N, N, MP_MB, MP_NB, 0, 0, MP_ICTXT, MXLDA, INFO)
CALL DESCINIT(DESCL, N, 1, MP_MB, 1, 0, 0, MP_ICTXT, MXLDA, INFO)
! Allocate space for the local arrays
ALLOCATE(A0(MXLDA,MXCOL), X0(MXLDA),FACT0(MXLDA,MXCOL), B0(MXLDA), &
IPVT0(MXLDA))
! Map input arrays to the processor grid
CALL SCALAPACK_MAP(A, DESCA, A0)
! Call the factorization routine
CALL LFTRG (A0, FACT0, IPVT0)
! Set up the columns of the B
! matrix one at a time in X0
DO 10 J=1, 2
CALL SCALAPACK_MAP(B(:,j), DESCL, B0)
! Solve for the J-th column of X
CALL LFSRG (FACT0, IPVT0, B0, X0)
CALL SCALAPACK_UNMAP(X0, DESCL, X(:,J))
10 CONTINUE
! Print results.
! Only Rank=0 has the solution, X.
IF(MP_RANK.EQ.0) CALL WRRRN (’X’, X)
IF (MP_RANK .EQ. 0) DEALLOCATE(A, B, X)
DEALLOCATE(A0, B0, IPVT0, FACT0, X0)
! Exit ScaLAPACK usage
CALL SCALAPACK_EXIT(MP_ICTXT)
! Shut down MPI
MP_NPROCS = MP_SETUP(‘FINAL’)
END
Output
 
X
1 2
1 -2.000 1.000
2 -2.000 -1.000
3 3.000 4.000