LSLRG

   more...

   more...
Solves a real general system of linear equations without iterative refinement.
Required Arguments
AN by N matrix containing the coefficients of the linear system. (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 (A,2).
LDA — Leading dimension of A exactly as specified in the dimension statement of the calling program. (Input)
Default: LDA = size (A,1).
IPATH — Path indicator. (Input)
IPATH = 1 means the system AX = B is solved. IPATH = 2 means the system ATX = B is solved.
Default: IPATH = 1.
FORTRAN 90 Interface
Generic: CALL LSLRG (A, B, X [])
Specific: The specific interface names are S_LSLRG and D_LSLRG.
FORTRAN 77 Interface
Single: CALL LSLRG (N, A, LDA, B, IPATH, X)
Double: The double precision name is DLSLRG.
ScaLAPACK Interface
Generic: CALL LSLRG (A0, B0, X0 [])
Specific: The specific interface names are S_LSLRG and D_LSLRG.
See the ScaLAPACK Usage Notes below for a description of the arguments for distributed computing.
Description
Routine LSLRG solves a system of linear algebraic equations having a real general 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. LSLRG first uses the routine LFCRG to compute an LU factorization of the coefficient matrix based on Gauss elimination with partial pivoting. Experiments were analyzed to determine efficient implementations on several different computers. For some supercomputers, particularly those with efficient vendor-supplied BLAS, versions that call Level 1, 2 and 3 BLAS are used. The remaining computers use a factorization method provided to us by Dr. Leonard J. Harding of the University of Michigan. Harding’s work involves “loop unrolling and jamming” techniques that achieve excellent performance on many computers. Using an option, LSLRG will estimate the condition number of the matrix. The solution of the linear system is then found using LFSRG.
The routine LSLRG fails if U, the upper triangular part of the factorization, has a zero diagonal element. This occurs only if A is close to a singular matrix.
If the estimated condition number is greater than 1/ɛ (where ɛ is machine precision), a warning error is issued. This indicates that small changes in A can cause large changes in the solution x. If the coefficient matrix is ill-conditioned or poorly scaled, it is recommended that either LIN_SOL_SVD or LSARG be used.
Comments
1. Workspace may be explicitly provided, if desired, by use of L2LRG/DL2LRG. The reference is:
CALL L2LRG (N, A, LDA, B, IPATH, X, FACT, IPVT, WK)
The additional arguments are as follows:
FACTN × N work array containing the LU factorization of A on output. If A is not needed, A and FACT can share the same storage locations. See Item 3 below to avoid memory bank conflicts.
IPVT — Integer work vector of length N containing the pivoting information for the LU 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 singular.
3. Integer Options with Chapter 11, Options Manager
16 This option uses four values to solve memory bank conflict (access inefficiency) problems. In routine L2LRG 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 LSLRG. Additional memory allocation for FACT and option value restoration are done automatically in LSLRG. Users directly calling L2LRG 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 LSLRG or L2LRG. 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 LSLRG temporarily replaces IVAL(2) by IVAL(1). The routine L2CRG computes the condition number if IVAL(2) = 2. Otherwise L2CRG skips this computation. LSLRG 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:
A0MXLDA by MXCOL local matrix containing the local portions of the distributed matrix A. A contains the coefficients of the 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 1
A system of three linear equations is solved. The coefficient matrix has real general form and the right-hand-side vector b has three elements.
 
USE LSLRG_INT
USE WRRRN_INT
IMPLICIT NONE
! Declare variables
INTEGER LDA, N
PARAMETER (LDA=3, N=3)
 
REAL A(LDA,N), B(N), X(N)
! Set values for A and B
A(1,:) = (/ 33.0, 16.0, 72.0/)
A(2,:) = (/-24.0, -10.0, -57.0/)
A(3,:) = (/ 18.0, -11.0, 7.0/)
!
B = (/129.0 -96.0 8.5/)
 
! Solve the system of equations
CALL LSLRG (A, B, X)
! Print results
CALL WRRRN (’X’, X, 1, N, 1)
END
Output
 
X
1 2 3
1.000 1.500 1.000
Example 2
A system of N = 16 linear equations is solved using the routine L2LRG. The option manager is used to eliminate memory bank conflict inefficiencies that may occur when the matrix dimension is a multiple of 16. The leading dimension of FACT=A is increased from N to N+IVAL(3)=17, since N=16=IVAL(4). The data used for the test is a nonsymmetric Hadamard matrix and a right-hand side generated by a known solution, xj = j,  j = 1, N.
 
USE L2LRG_INT
USE IUMAG_INT
USE WRRRN_INT
USE SGEMV_INT
IMPLICIT NONE
! Declare variables
INTEGER LDA, N
PARAMETER (LDA=17, N=16)
! SPECIFICATIONS FOR PARAMETERS
INTEGER ICHP, IPATH, IPUT, KBANK
REAL ONE, ZERO
PARAMETER (ICHP=1, IPATH=1, IPUT=2, KBANK=16, ONE=1.0E0, &
ZERO=0.0E0)
! SPECIFICATIONS FOR LOCAL VARIABLES
INTEGER I, IPVT(N), J, K, NN
REAL A(LDA,N), B(N), WK(N), X(N)
! SPECIFICATIONS FOR SAVE VARIABLES
INTEGER IOPT(1), IVAL(4)
SAVE IVAL
! Data for option values.
DATA IVAL/1, 16, 1, 16/
! Set values for A and B:
A(1,1) = ONE
NN = 1
! Generate Hadamard matrix.
DO 20 K=1, 4
DO 10 J=1, NN
DO 10 I=1, NN
A(NN+I,J) = -A(I,J)
A(I,NN+J) = A(I,J)
A(NN+I,NN+J) = A(I,J)
10 CONTINUE
NN = NN + NN
20 CONTINUE
! Generate right-hand-side.
DO 30 J=1, N
X(J) = J
30 CONTINUE
! Set B = A*X.
CALL SGEMV (’N’, N, N, ONE, A, LDA, X, 1, ZERO, B, 1)
! Clear solution array.
X = ZERO
 
! Set option to avoid memory
! bank conflicts.
IOPT(1) = KBANK
CALL IUMAG (’MATH’, ICHP, IPUT, 1, IOPT, IVAL)
! Solve A*X = B.
CALL L2LRG (N, A, LDA, B, IPATH, X, A, IPVT, WK)
! Print results
CALL WRRRN (’X’, X, 1, N, 1)
END
Output
 
X
1 2 3 4 5 6 7 8 9 10
1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00
 
11 12 13 14 15 16
11.00 12.00 13.00 14.00 15.00 16.00
ScaLAPACK Example
The same system of three linear equations is solved as a distributed computing example. The coefficient matrix has real general 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 LSLRG_INT
USE WRRRN_INT
USE SCALAPACK_SUPPORT
IMPLICIT NONE
INCLUDE ‘mpif.h’
! Declare variables
INTEGER N, DESCA(9), DESCX(9)
INTEGER INFO, MXCOL, MXLDA
REAL, ALLOCATABLE :: A(:,:), B(:), X(:)
REAL, ALLOCATABLE :: A0(:,:), B0(:), X0(:)
PARAMETER (N=3)
! Set up for MPI
MP_NPROCS = MP_SETUP()
IF(MP_RANK .EQ. 0) THEN
ALLOCATE (A(N,N), B(N), X(N))
! Set values for A and B
A(1,:) = (/ 33.0, 16.0, 72.0/)
A(2,:) = (/-24.0, -10.0, -57.0/)
A(3,:) = (/ 18.0, -11.0, 7.0/)
!
B = (/129.0, -96.0, 8.5/)
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 LSLRG (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 1.500 1.000
Published date: 03/19/2020
Last modified date: 03/19/2020