LFICG

   more...

   more...
Uses iterative refinement to improve the solution of a complex general system of linear equations.
Required Arguments
A — Complex N by N matrix containing the coefficient matrix of the linear system. (Input)
FACT — Complex N by N matrix containing the LU factorization of the coefficient matrix A as output from routine LFCCG/DLFCCG or LFTCG/DLFTCG. (Input)
IPVT — Vector of length N containing the pivoting information for the LU factorization of A as output from routine LFCCG/DLFCCG or LFTCG/DLFTCG. (Input)
B — Complex vector of length N containing the right-hand side of the linear system. (Input)
X — Complex vector of length N containing the solution to the linear system. (Output)
RES — Complex vector of length N containing the residual vector at the improved solution. (Output)
Optional Arguments
N — Number of equations. (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).
IPATH — Path indicator. (Input)
IPATH = 1 means the system AX = B is solved.
IPATH = 2 means the system AHX = B is solved.
Default: IPATH = 1.
FORTRAN 90 Interface
Generic: CALL LFICG (A, FACT, IPVT, B, X, RES [])
Specific: The specific interface names are S_LFICG and D_LFICG.
FORTRAN 77 Interface
Single: CALL LFICG (N, A, LDA, FACT, LDFACT, IPVT, B, IPATH, X, RES)
Double: The double precision name is DLFICG.
ScaLAPACK Interface
Generic: CALL LFICG (A0, FACT0, IPVT0, B0, X0, RES0 [])
Specific: The specific interface names are S_LFICG and D_LFICG.
See the ScaLAPACK Usage Notes below for a description of the arguments for distributed computing.
Description
Routine LFICG computes the solution of a system of linear algebraic equations having a complex general coefficient matrix. Iterative refinement is performed on the solution vector to improve the accuracy. Usually almost all of the digits in the solution are accurate, even if the matrix is somewhat ill-conditioned.
To compute the solution, the coefficient matrix must first undergo an LU factorization. This may be done by calling either LFCCG, or LFTCG.
Iterative refinement fails only if the matrix is very ill-conditioned. Routines LFICG and LFSCG both solve a linear system given its LU factorization. LFICG generally takes more time and produces a more accurate answer than LFSCG. Each iteration of the iterative refinement algorithm used by LFICG calls LFSCG.
Comments
Informational error
Type
Code
Description
3
2
The input matrix is too ill-conditioned for iterative refinement to be effective
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 coefficient matrix of the linear system. (Input)
FACT0MXLDA by MXCOL complex local matrix containing the local portions of the distributed matrix FACT as output from routineLFCCG, or LFTCG. FACT contains the LU factorization of the matrix A. (Input)
IPVT0 — Local vector of length MXLDA containing the local portions of the distributed vector IPVT. IPVT contains the pivoting information for the LU factorization as output from subroutine LFCCG, or LFTCG. (Input)
B0 — Complex local vector of length MXLDA containing the local portions of the distributed vector B. B contains the right-hand side of the linear system. (Input)
X0 — Complex local vector of length MXLDA containing the local portions of the distributed vector X. X contains the solution to the linear system. (Output)
RES0 — Complex local vector of length MXLDA containing the local portions of the distributed vector RES. RES contains the final correction at the improved solution to the linear system. (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
A set of linear systems is solved successively. The right-hand-side vector is perturbed after solving the system each of the first two times by adding 0.5 + 0.5i to the second element.
 
USE LFICG_INT
USE LFCCG_INT
USE WRCRN_INT
USE UMACH_INT
! Declare variables
PARAMETER (LDA=3, LDFACT=3, N=3)
INTEGER IPVT(N), NOUT
REAL RCOND
COMPLEX A(LDA,LDA), B(N), X(N), FACT(LDFACT,LDFACT), 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-5.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,-5.0), (5.0,3.0)/
!
! Set values for B
! B = ( 3.0+5.0i 22.0+10.0i -10.0+4.0i)
!
DATA B/(3.0,5.0), (22.0,10.0), (-10.0,4.0)/
! Factor A
CALL LFCCG (A, FACT, IPVT, RCOND)
! Print the L1 condition number
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) RCOND, 1.0E0/RCOND
! Solve the three systems
DO 10 J=1, 3
CALL LFICG (A, FACT, IPVT, B, X, RES)
! Print results
CALL WRCRN (’X’, X, 1, N, 1)
! Perturb B by adding 0.5+0.5i to B(2)
B(2) = B(2) + CMPLX(0.5,0.5)
10 CONTINUE
!
99999 FORMAT (’ RCOND = ’,F5.3,/,’ L1 Condition number = ’,F6.3)
END
Output
 
RCOND < 0.025
L1 Condition number < 75.0
X
1 2 3
( 1.000,-1.000) ( 2.000, 4.000) ( 3.000, 0.000)
 
X
1 2 3
( 0.910,-1.061) ( 1.986, 4.175) ( 3.123, 0.071)
 
X
1 2 3
( 0.821,-1.123) ( 1.972, 4.349) ( 3.245, 0.142)
ScaLAPACK Example
The same set of linear systems is solved successively as a distributed example. The right-hand-side vector is perturbed after solving the system each of the first two times by adding 0.5 + 0.5i to the second element. 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 LFICG_INT
USE LFCCG_INT
USE WRCRN_INT
USE UMACH_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(:,:), B(:), X(:), X0(:), RES(:)
COMPLEX, ALLOCATABLE :: A0(:,:), FACT0(:,:), B0(:), RES0(:)
REAL RCOND
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), X(N), RES(N))
! Set values for A and B
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)/)
!
B = (/ (3.0, 5.0), (22.0, 10.0), (-10.0, 4.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), RES0(MXLDA))
! Map input array to the processor grid
CALL SCALAPACK_MAP(A, DESCA, A0)
! Factor A
CALL LFCCG (A0, FACT0, IPVT0, RCOND)
! Print the L1 condition number
IF (MP_RANK .EQ. 0) THEN
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) RCOND, 1.0E0/RCOND
ENDIF
! Solve the three systems
DO 10 J=1, 3
CALL SCALAPACK_MAP(B, DESCL, B0)
CALL LFICG (A0, FACT0, IPVT0, B0, X0, RES0)
CALL SCALAPACK_UNMAP(X0, DESCL, X)
! Print results
! Only Rank=0 has the solution, X.
IF (MP_RANK .EQ. 0) CALL WRCRN (’X’, X, 1, N, 1)
! Perturb B by adding 0.5+0.5i to B(2)
IF(MP_RANK .EQ. 0) B(2) = B(2) + (0.5,0.5)
10 CONTINUE
IF (MP_RANK .EQ. 0) DEALLOCATE(A, B, X, RES)
DEALLOCATE(A0, B0, FACT0, IPVT0, X0, RES0)
! Exit Scalapack usage
CALL SCALAPACK_EXIT(MP_ICTXT)
! Shut down MPI
MP_NPROCS = MP_SETUP(‘FINAL’)
99999 FORMAT (’ RCOND = ’,F5.3,/,’ L1 Condition number = ’,F6.3)
END
Output
 
RCOND < 0.025
L1 Condition number < 75.0
X
1 2 3
( 1.000,-1.000) ( 2.000, 4.000) ( 3.000, 0.000)
 
X
1 2 3
( 0.910,-1.061) ( 1.986, 4.175) ( 3.123, 0.071)
 
X
1 2 3
( 0.821,-1.123) ( 1.972, 4.349) ( 3.245, 0.142)
Published date: 03/19/2020
Last modified date: 03/19/2020