LFSDS

   more...

   more...
Solves a real symmetric positive definite system of linear equations given the RT R Cholesky factorization of the coefficient matrix.
Required Arguments
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.
Optional Arguments
N — Number of equations. (Input)
Default: N = size (FACT,2).
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 LFSDS (FACT, B, X [])
Specific: The specific interface names are S_LFSDS and D_LFSDS.
FORTRAN 77 Interface
Single: CALL LFSDS (N, FACT, LDFACT, B, X)
Double: The double precision name is DLFSDS.
ScaLAPACK Interface
Generic: CALL LFSDS (FACT0, B0, X0 [])
Specific: The specific interface names are S_LFSDS and D_LFSDS.
See the ScaLAPACK Usage Notes below for a description of the arguments for distributed computing.
Description
Routine LFSDS computes the solution for a system of linear algebraic equations having a real symmetric positive definite coefficient matrix. To compute the solution, the coefficient matrix must first undergo an RTR factorization. This may be done by calling either LFCDS or LFTDS. R is an upper triangular matrix.
The solution to Ax = b is found by solving the triangular systems RTy = b and Rx = y.
LFSDS and LFIDS 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.
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.
Comments
Informational error
Type
Code
Description
4
1
The input matrix is singular.
ScaLAPACK Usage Notes
The arguments which differ from the standard version of this routine are:
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.
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. LFTDS is called to factor the coefficient matrix. LFSDS is called to compute the four solutions for the four 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 LFCDS to perform the factorization, and LFIDS to compute the solutions.
 
USE LFSDS_INT
USE LFTDS_INT
USE WRRRN_INT
! Declare variables
INTEGER LDA, LDFACT, N
PARAMETER (LDA=3, LDFACT=3, N=3)
REAL A(LDA,LDA), B(N,4), FACT(LDFACT,LDFACT), X(N,4)
!
! 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.6 -8.0 -9.4)
! ( -3.0 -4.2 11.0 17.6)
! ( -3.0 -5.2 -6.0 -23.4)
!
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, -3.0, 3.6, -4.2, -5.2, -8.0, 11.0, -6.0,&
-9.4, 17.6, -23.4/
! Factor the matrix A
CALL LFTDS (A, FACT)
! Compute the solutions
DO 10 I=1, 4
CALL LFSDS (FACT, B(:,I), X(:,I))
10 CONTINUE
! Print solutions
CALL WRRRN (’The solution vectors are’, X)
!
END
Output
 
The solution vectors are
1 2 3 4
1 -44.0 118.4 -162.0 -71.2
2 -11.0 25.6 -36.0 -16.6
3 5.0 -19.0 23.0 6.0
ScaLAPACK Example
The same set of linear systems is solved successively as a distributed example. Routine LFTDS is called to factor the coefficient matrix. The routine LFSDS is called to compute the four solutions for the four 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 LFCDS to perform the factorization, and LFIDS 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 LFSDS_INT
USE LFTDS_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
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,4), X(N,4))
! 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,:) = (/ -1.0, 3.6, -8.0, -9.4/)
B(2,:) = (/ -3.0, -4.2, 11.0, 17.6/)
B(3,:) = (/ -3.0, -5.2, -6.0, -23.4/)
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))
! Map input arrays to the processor grid
CALL SCALAPACK_MAP(A, DESCA, A0)
! Call the factorization routine
CALL LFTDS (A0, FACT0)
! Set up the columns of the B
! matrix one at a time in X0
DO 10 J=1, 4
CALL SCALAPACK_MAP(B(:,j), DESCL, B0)
! Solve for the J-th column of X
CALL LFSDS (FACT0, 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 (’The solution vectors are’, X)
IF (MP_RANK .EQ. 0) DEALLOCATE(A, B, X)
DEALLOCATE(A0, FACT0, B0, X0)
! Exit Scalapack usage
CALL SCALAPACK_EXIT(MP_ICTXT)
! Shut down MPI
MP_NPROCS = MP_SETUP(‘FINAL’)
END
Output
 
The solution vectors are
1 2 3 4
1 -44.0 118.4 -162.0 -71.2
2 -11.0 25.6 -36.0 -16.6
3 5.0 -19.0 23.0 6.0