LFCCG

   more...

   more...
Computes the LU factorization of a complex general matrix and estimate its L1 condition number.
Required Arguments
A — Complex N by N matrix to be factored. (Input)
FACT — Complex N × 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)
RCOND — Scalar containing an estimate of the reciprocal of the L1 condition number of A. (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 LFCCG (A, FACT, IPVT, RCOND [])
Specific: The specific interface names are S_LFCCG and D_LFCCG.
FORTRAN 77 Interface
Single: CALL LFCCG (N, A, LDA, FACT, LDFACT, IPVT, RCOND)
Double: The double precision name is DLFCCG.
ScaLAPACK Interface
Generic: CALL LFCCG (A0, FACT0, IPVT0, RCOND [])
Specific: The specific interface names are S_LFCCG and D_LFCCG.
See the ScaLAPACK Usage Notes below for a description of the arguments for distributed computing.
Description
Routine LFCCG performs an LU factorization of a complex general coefficient matrix. It also estimates the condition number of the 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.
The L1 condition number of the matrix A is defined to be κ(A) = A1A-11. Since it is expensive to compute A-11, the condition number is only estimated. The estimation algorithm is the same as used by LINPACK and is described by Cline et al. (1979).
If the estimated condition number is greater than 1/ɛ (where ɛ is machine precision), a warning error is issued. This indicates that very small changes in A can cause very large changes in the solution x. Iterative refinement can sometimes find the solution to such a system.
LFCCG fails if U, the upper triangular part of the factorization, has a zero diagonal element. This can occur only if A either is singular or is very close to a singular matrix.
The LU factors are returned in a form that is compatible with routines LFICG, LFSCG and LFDCG. To solve systems of equations with multiple right-hand-side vectors, use LFCCG followed by either LFICG or LFSCG called once for each right-hand side. The routine LFDCG can be called to compute the determinant of the coefficient matrix after LFCCG 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 using
L11= LN-1PN-1  L1P1
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.
Comments
1. Workspace may be explicitly provided, if desired, by use of L2CCG/DL2CCG. The reference is:
CALL L2CCG (N, A, LDA, FACT, LDFACT, IPVT, RCOND, WK)
The additional argument is:
WK — Complex work vector of length N.
2. Informational errors
Type
Code
Description
3
1
The input matrix is algorithmically singular.
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 complex local matrix containing the local portions of the distributed matrix A. A contains the matrix to be factored. (Input)
FACT0MXLDA by MXCOL complex 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
The inverse of a 3 × 3 matrix is computed. LFCCG is called to factor the matrix and to check for singularity or ill-conditioning. LFICG is called to determine the columns of the inverse.
 
USE IMSL_LIBRARIES
 
! Declare variables
PARAMETER (LDA=3, LDFACT=3, N=3)
INTEGER IPVT(N), NOUT
REAL RCOND, THIRD
COMPLEX A(LDA,N), AINV(LDA,N), RJ(N), FACT(LDFACT,N), RES(N)
! Declare functions
COMPLEX CMPLX
! Set values for A
!
! A = ( 1.0+1.0i 2.0+3.0i 3.0+3.0i)
! ( 2.0+1.0i 5.0+3.0i 7.0+4.0i)
! ( -2.0+1.0i -4.0+4.0i -5.0+3.0i)
!
DATA A/(1.0,1.0), (2.0,1.0), (-2.0,1.0), (2.0,3.0), (5.0,3.0),&
(-4.0,4.0), (3.0,3.0), (7.0,4.0), (-5.0,3.0)/
!
! Scale A by dividing by three
THIRD = 1.0/3.0
DO 10 I=1, N
CALL CSSCAL (N, THIRD, A(:,I), 1)
10 CONTINUE
! Factor A
CALL LFCCG (A, FACT, IPVT, RCOND)
! Print the L1 condition number
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) RCOND, 1.0E0/RCOND
! Set up the columns of the identity
! matrix one at a time in RJ
CALL CSET (N, (0.0,0.0), RJ, 1)
DO 20 J=1, N
RJ(J) = CMPLX(1.0,0.0)
! RJ is the J-th column of the identity
! matrix so the following LFIRG
! reference places the J-th column of
! the inverse of A in the J-th column
! of AINV
CALL LFICG (A, FACT, IPVT, RJ, AINV(:,J), RES)
RJ(J) = CMPLX(0.0,0.0)
20 CONTINUE
! Print results
CALL WRCRN (’AINV’, AINV)
!
99999 FORMAT (’ RCOND = ’,F5.3,/,’ L1 Condition number = ’,F6.3)
END
Output
 
RCOND < .02
L1 Condition number < 100.0
 
AINV
1 2 3
1 ( 6.400,-2.800) (-3.800, 2.600) (-2.600, 1.200)
2 (-1.600,-1.800) ( 0.200, 0.600) ( 0.400,-0.800)
3 (-0.600, 2.200) ( 1.200,-1.400) ( 0.400, 0.200)
ScaLAPACK Example
The inverse of the same 3 × 3 matrix is computed as a distributed example. LFCCG is called to factor the matrix and to check for singularity or ill-conditioning. LFICG is called to determine the columns of the inverse. 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 LFCCG_INT
USE UMACH_INT
USE LFICG_INT
USE WRCRN_INT
USE SCALAPACK_SUPPORT
IMPLICIT NONE
INCLUDE ‘mpif.h’
! Declare variables
INTEGER J, LDA, N, DESCA(9), DESCL(9)
INTEGER INFO, MXCOL, MXLDA, NOUT
INTEGER, ALLOCATABLE :: IPVT0(:)
COMPLEX, ALLOCATABLE :: A(:,:), AINV(:,:), X0(:), RJ(:)
COMPLEX, ALLOCATABLE :: A0(:,:), FACT0(:,:), RES0(:), RJ0(:)
REAL RCOND, THIRD
PARAMETER (LDA=3, N=3)
! Set up for MPI
MP_NPROCS = MP_SETUP()
IF(MP_RANK .EQ. 0) THEN
ALLOCATE (A(LDA,N), AINV(LDA,N))
! Set values for A
A(1,:) = (/ ( 1.0, 1.0), ( 2.0, 3.0), ( 3.0, 3.0)/)
A(2,:) = (/ ( 2.0, 1.0), ( 5.0, 3.0), ( 7.0, 4.0)/)
A(3,:) = (/ (-2.0, 1.0), (-4.0, 4.0), (-5.0, 3.0)/)
! Scale A by dividing by three
THIRD = 1.0/3.0
A = A * THIRD
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), RJ(N), &
RJ0(MXLDA), RES0(MXLDA), IPVT0(MXLDA))
! Map input array to the processor grid
CALL SCALAPACK_MAP(A, DESCA, A0)
! Factor A
CALL LFCCG (A0, FACT0, IPVT0, RCOND)
! Print the reciprocal condition number
! and the L1 condition number
IF(MP_RANK .EQ. 0) THEN
CALL UMACH (2, NOUT)
WRITE (NOUT,99998) RCOND, 1.0E0/RCOND
ENDIF
! Set up the columns of the identity
! matrix one at a time in RJ
RJ = (0.0, 0.0)
DO 10 J=1, N
RJ(J) = (1.0, 0.0)
CALL SCALAPACK_MAP(RJ, DESCL, RJ0)
! RJ is the J-th column of the identity
! matrix so the following LFICG
! reference computes the J-th column of
! the inverse of A
CALL LFICG (A0, FACT0, IPVT0, RJ0, X0, RES0)
RJ(J) = (0.0, 0.0)
CALL SCALAPACK_UNMAP(X0, DESCL, AINV(:,J))
10 CONTINUE
! Print results
! Only Rank=0 has the solution, AINV.
IF(MP_RANK.EQ.0) CALL WRCRN (’AINV’, AINV)
IF (MP_RANK .EQ. 0) DEALLOCATE(A, AINV)
DEALLOCATE(A0, FACT0, IPVT0, RJ, RJ0, RES0, X0)
! Exit ScaLAPACK usage
CALL SCALAPACK_EXIT(MP_ICTXT)
! Shut down MPI
MP_NPROCS = MP_SETUP(‘FINAL’)
99998 FORMAT (’ RCOND = ’,F5.3,/,’ L1 Condition number = ’,F6.3)
END
Output
 
RCOND < .02
L1 Condition number < 100.0
 
AINV
1 2 3
1 ( 6.400,-2.800) (-3.800, 2.600) (-2.600, 1.200)
2 (-1.600,-1.800) ( 0.200, 0.600) ( 0.400,-0.800)
3 (-0.600, 2.200) ( 1.200,-1.400) ( 0.400, 0.200)
Published date: 03/19/2020
Last modified date: 03/19/2020