LFIDS

   more...

   more...
Uses iterative refinement to improve the solution of a real symmetric positive definite system of linear equations.
Required Arguments
AN by N matrix containing the symmetric positive definite coefficient matrix of the linear system. (Input)
Only the upper triangle of A is referenced.
FACTN by N matrix containing the RT R factorization of the coefficient matrix A as output from routine LFCDS/DLFCDS or LFTDS/DLFTDS. (Input)
B — Vector of length N containing the right-hand side of the linear system. (Input)
X — Vector of length N containing the solution to the linear system. (Output)
If B is not needed, B and X can share the same storage locations.
RES — 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 dimesion 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 LFIDS (A, FACT, B, X, RES [])
Specific: The specific interface names are S_LFIDS and D_LFIDS.
FORTRAN 77 Interface
Single: CALL LFIDS (N, A, LDA, FACT, LDFACT, B, X, RES)
Double: The double precision name is DLFIDS.
ScaLAPACK Interface
Generic: CALL LFIDS (A0, FACT0, B0, X0, RES0 [, …])
Specific: The specific interface names are S_LFIDS and D_LFIDS.
See the ScaLAPACK Usage Notes below for a description of the arguments for distributed computing.
Description
Routine LFIDS computes the solution of a system of linear algebraic equations having a real symmetric positive definite 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. 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.
To compute the solution, the coefficient matrix must first undergo an RTR factorization. This may be done by calling either LFCDS or LFTDS.
Iterative refinement fails only if the matrix is very ill-conditioned.
LFIDS and LFSDS both solve a linear system given its RTR factorization. LFIDS generally takes more time and produces a more accurate answer than LFSDS. Each iteration of the iterative refinement algorithm used by LFIDS calls LFSDS.
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 local matrix containing the local portions of the distributed matrix A. A contains the symmetric positive definite coefficient matrix of the linear system. (Input)
FACT0MXLDA by MXCOL local matrix containing the local portions of the distributed matrix FACT. FACT contains the RT R factorization of the coefficient matrix A as output from routine LFCDS/DLFCDS or LFTDS/DLFTDS. (Input)
B0 — 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 — Local vector of length MXLDA containing the local portions of the distributed vector X. X contains the solution to the linear system. (Output)
If B is not needed, B and X can share the same storage locations.
RES0 — Local vector of length MXLDA containing the local portions of the distributed vector RES. RES contains the residual vector 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.2 to the second element.
 
USE LFIDS_INT
USE LFCDS_INT
USE UMACH_INT
USE WRRRN_INT
! Declare variables
INTEGER LDA, LDFACT, N
PARAMETER (LDA=3, LDFACT=3, N=3)
REAL A(LDA,LDA), B(N), RCOND, FACT(LDFACT,LDFACT), RES(N,3),&
X(N,3)
!
! Set values for A and B
!
! A = ( 1.0 -3.0 2.0)
! ( -3.0 10.0 -5.0)
! ( 2.0 -5.0 6.0)
!
! B = ( 1.0 -3.0 2.0)
!
DATA A/1.0, -3.0, 2.0, -3.0, 10.0, -5.0, 2.0, -5.0, 6.0/
DATA B/1.0, -3.0, 2.0/
! Factor the matrix A
CALL LFCDS (A, FACT, RCOND)
! Print the estimated condition number
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) RCOND, 1.0E0/RCOND
! Compute the solutions
DO 10 I=1, 3
CALL LFIDS (A, FACT, B, X(:,I), RES(:,I))
B(2) = B(2) + .2E0
10 CONTINUE
! Print solutions and residuals
CALL WRRRN (’The solution vectors are’, X)
CALL WRRRN (’The residual vectors are’, RES)
!
99999 FORMAT (’ RCOND = ’,F5.3,/,’ L1 Condition number = ’,F9.3)
END
Output
 
RCOND = 0.001
L1 Condition number = 674.727
 
The solution vectors are
1 2 3
1 1.000 2.600 4.200
2 0.000 0.400 0.800
3 0.000 -0.200 -0.400
 
The residual vectors are
1 2 3
1 0.0000 0.0000 0.0000
2 0.0000 0.0000 0.0000
3 0.0000 0.0000 0.0000
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.2 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 LFIDS_INT
USE LFCDS_INT
USE UMACH_INT
USE WRRRN_INT
USE SCALAPACK_SUPPORT
IMPLICIT NONE
INCLUDE ‘mpif.h’
! Declare variables
INTEGER J, LDA, N, NOUT, DESCA(9), DESCL(9)
INTEGER INFO, MXCOL, MXLDA
REAL RCOND
REAL, ALLOCATABLE :: A(:,:), B(:), X(:,:), RES(:,:), X0(:)
REAL, ALLOCATABLE :: A0(:,:), FACT0(:,:), B0(:), RES0(:)
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,3), RES(N,3))
! Set values for A and B
A(1,:) = (/ 1.0, -3.0, 2.0/)
A(2,:) = (/-3.0, 10.0, -5.0/)
A(3,:) = (/ 2.0, -5.0, 6.0/)
!
B = (/ 1.0, -3.0, 2.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), &
RES0(MXLDA))
! Map input arrays to the processor grid
CALL SCALAPACK_MAP(A, DESCA, A0)
! Call the factorization routine
CALL LFCDS (A0, FACT0, RCOND)
! Print the estimated condition number
CALL UMACH (2, NOUT)
IF(MP_RANK .EQ. 0) WRITE (NOUT,99999) RCOND, 1.0E0/RCOND
! Set up the columns of the B
! matrix one at a time in X0
DO 10 J=1, 3
CALL SCALAPACK_MAP(B, DESCL, B0)
! Solve for the J-th column of X
CALL LFIDS (A0, FACT0, B0, X0, RES0)
CALL SCALAPACK_UNMAP(X0, DESCL, X(:,J))
CALL SCALAPACK_UNMAP(RES0, DESCL, RES(:,J))
IF(MP_RANK .EQ. 0) B(2) = B(2) + .2E0
10 CONTINUE
! Print results.
! Only Rank=0 has the full arrays
IF(MP_RANK.EQ.0) CALL WRRRN (’The solution vectors are’, X)
IF(MP_RANK.EQ.0) CALL WRRRN (’The residual vectors are’, RES)
IF (MP_RANK .EQ. 0) DEALLOCATE(A, B, X, RES)
DEALLOCATE(A0, B0, FACT0, RES0, X0)
! Exit ScaLAPACK usage
CALL SCALAPACK_EXIT(MP_ICTXT)
! Shut down MPI
MP_NPROCS = MP_SETUP(‘FINAL’)
99999 FORMAT (’ RCOND = ’,F5.3,/,’ L1 Condition number = ’,F9.3)
END
Output
 
RCOND = 0.001
L1 Condition number = 674.727
 
The solution vectors are
1 2 3
1 1.000 2.600 4.200
2 0.000 0.400 0.800
3 0.000 -0.200 -0.400
 
The residual vectors are
1 2 3
1 0.0000 0.0000 0.0000
2 0.0000 0.0000 0.0000
3 0.0000 0.0000 0.0000
Published date: 03/19/2020
Last modified date: 03/19/2020