LSADS

Solves a real symmetric positive definite system of linear equations with iterative refinement.

Required Arguments

A — N by N matrix containing the coefficient matrix of the symmetric positive definite linear system. (Input)

Only the upper triangle of A is referenced.

Only the upper triangle of A is referenced.

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)

Optional Arguments

N — Number of equations. (Input)

Default: N = size (A,2).

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).

Default: LDA = size (A,1).

FORTRAN 90 Interface

Generic: CALL LSADS (A, B, X [,…])

Specific: The specific interface names are S_LSADS and D_LSADS.

FORTRAN 77 Interface

Single: CALL LSADS (N, A, LDA, B, X)

Double: The double precision name is DLSADS.

ScaLAPACK Interface

Generic: CALL LSADS (A0, B0, X0 [,…])

Specific: The specific interface names are S_LSADS and D_LSADS.

See the ScaLAPACK Usage Notes below for a description of the arguments for distributed computing.

Description

Routine LSADS solves a system of linear algebraic equations having a real symmetric positive definite 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. LSADS first uses the routine LFCDS to compute an RTR Cholesky factorization of the coefficient matrix and to estimate the condition number of the matrix. The matrix R is upper triangular. The solution of the linear system is then found using the iterative refinement routine LFIDS. LSADS fails if any submatrix of R is not positive definite, if R has a zero diagonal element or if the iterative refinement algorithm fails to converge. These errors occur only if A is either very close to a singular matrix or a matrix which is not positive definite. 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. LSADS solves the problem that is represented in the computer; however, this problem may differ from the problem whose solution is desired.

Comments

1. Workspace may be explicitly provided, if desired, by use of L2ADS/DL2ADS. The reference is:

CALL L2ADS (N, A, LDA, B, X, FACT, WK)

The additional arguments are as follows:

FACT— Work vector of length N2 containing the RTR factorization of A on output.

WK — Work vector of length N.

2. Informational errors

Type | Code | Description |
---|---|---|

3 | 1 | The input matrix is too ill-conditioned. The solution might not be accurate. |

4 | 2 | The input matrix is not positive definite. |

3. Integer Options with Chapter 11 Options Manager

16 This option uses four values to solve memory bank conflict (access inefficiency) problems. In routine L2ADS the leading dimension of FACT is increased by IVAL(3) when N is a multiple of IVAL(4). The values IVAL(3) and IVAL(4) are temporarily replaced by IVAL(1) and IVAL(2), respectively, in LSADS. Additional memory allocation for FACT and option value restoration are done automatically in LSADS. Users directly calling L2ADS can allocate additional space for FACT and set IVAL(3) and IVAL(4) so that memory bank conflicts no longer cause inefficiencies. There is no requirement that users change existing applications that use LSADS or L2ADS. Default values for the option are IVAL(*) = 1, 16, 0, 1.

17 This option has two values that determine if the L1 condition number is to be computed. Routine LSADS temporarily replaces IVAL(2) by IVAL(1). The routine L2CDS computes the condition number if IVAL(2) = 2. Otherwise L2CDS skips this computation. LSADS restores the option. Default values for the option are IVAL(*) = 1, 2.

ScaLAPACK Usage Notes

The arguments which differ from the standard version of this routine are:

A0 — MXLDA by MXCOL local matrix containing the local portions of the distributed matrix A. A contains the coefficient matrix of the symmetric positive definite linear system. (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)

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 system of three linear equations is solved. The coefficient matrix has real positive definite form and the right-hand-side vector b has three elements.

USE LSADS_INT

USE WRRRN_INT

! Declare variables

INTEGER LDA, N

PARAMETER (LDA=3, N=3)

REAL A(LDA,LDA), B(N), X(N)

!

! 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 = ( 27.0 -78.0 64.0)

!

DATA A/1.0, -3.0, 2.0, -3.0, 10.0, -5.0, 2.0, -5.0, 6.0/

DATA B/27.0, -78.0, 64.0/

!

CALL LSADS (A, B, X)

! Print results

CALL WRRRN (’X’, X, 1, N, 1)

!

END

Output

X

1 2 3

1.000 -4.000 7.000

ScaLAPACK Example

The same system of three linear equations is solved as a distributed computing example. The coefficient matrix has real positive definite form and the right-hand-side vector b has three elements. 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 LSADS_INT

USE WRRRN_INT

USE SCALAPACK_SUPPORT

IMPLICIT NONE

INCLUDE ‘mpif.h’

! Declare variables

INTEGER LDA, N, DESCA(9), DESCX(9)

INTEGER INFO, MXCOL, MXLDA

REAL, ALLOCATABLE :: A(:,:), B(:), X(:)

REAL, ALLOCATABLE :: A0(:,:), B0(:), X0(:)

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))

! 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 = (/27.0, -78.0, 64.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(DESCX, N, 1, MP_MB, 1, 0, 0, MP_ICTXT, MXLDA, INFO)

! Allocate space for the local arrays

ALLOCATE (A0(MXLDA,MXCOL), B0(MXLDA), X0(MXLDA))

! Map input arrays to the processor grid

CALL SCALAPACK_MAP(A, DESCA, A0)

CALL SCALAPACK_MAP(B, DESCX, B0)

! Solve the system of equations

CALL LSADS (A0, B0, X0)

! Unmap the results from the distributed

! arrays back to a non-distributed array.

! After the unmap, only Rank=0 has the full

! array.

CALL SCALAPACK_UNMAP(X0, DESCX, X)

! Print results.

! Only Rank=0 has the solution, X.

IF(MP_RANK .EQ. 0)CALL WRRRN (’X’, X, 1, N, 1)

IF (MP_RANK .EQ. 0) DEALLOCATE(A, B, X)

DEALLOCATE(A0, B0, X0)

! Exit ScaLAPACK usage

CALL SCALAPACK_EXIT(MP_ICTXT)

! Shut down MPI

MP_NPROCS = MP_SETUP(‘FINAL’)

END

Output

X

1 2 3

1.000 -4.000 7.000