LFIDH

more...

more...

Uses iterative refinement to improve the solution of a complex Hermitian positive definite system of linear equations.

Required Arguments

A — Complex N by N matrix containing the coefficient matrix of the linear system. (Input)
Only the upper triangle of A is referenced.

FACT — Complex N by N matrix containing the factorization of the coefficient matrix A as output from routine LFCDH/DLFCDH or LFTDH/DLFTDH. (Input)
Only the upper triangle of FACT is used.

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

FORTRAN 90 Interface

Generic: CALL LFIDH (A, FACT, B, X, RES [, …])

Specific: The specific interface names are S_LFIDH and D_LFIDH.

FORTRAN 77 Interface

Single: CALL LFIDH (N, A, LDA, FACT, LDFACT, B, X, RES)

Double: The double precision name is DLFIDH.

ScaLAPACK Interface

Generic: CALL LFIDH (A0, FACT0, B0, X0, RES0 [])

Specific: The specific interface names are S_LFIDH and D_LFIDH.

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

Description

Routine LFIDH computes the solution of a system of linear algebraic equations having a complex Hermitian 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.

To compute the solution, the coefficient matrix must first undergo an RH R factorization. This may be done by calling either LFCDH or LFTDH.

Iterative refinement fails only if the matrix is very ill-conditioned.

LFIDH and LFSDH both solve a linear system given its RH R factorization. LFIDH generally takes more time and produces a more accurate answer than LFSDH. Each iteration of the iterative refinement algorithm used by LFIDH calls LFSDH.

Comments

Informational error

 

Type

Code

Description

3

3

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)
Only the upper triangle of A is referenced.

FACT0MXLDA by MXCOL complex local matrix containing the local portions of the distributed matrix FACT as output from routine LFCDH or LFTDH. FACT contains the factorization of the matrix A. (Input)
Only the upper triangle of FACT is referenced.

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 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 (Utilities) after a call to SCALAPACK_SETUP
(Chapter 11, ”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 by adding (1 + i)/2 to the second element after each call to LFIDH.

 

USE LFIDH_INT

USE LFCDH_INT

USE UMACH_INT

USE WRCRN_INT

! Declare variables

INTEGER LDA, LDFACT, N

PARAMETER (LDA=5, LDFACT=5, N=5)

REAL RCOND

COMPLEX A(LDA,LDA), B(N), FACT(LDFACT,LDFACT), RES(N,3), X(N,3)

!

! Set values for A and B

!

! A = ( 2.0+0.0i -1.0+1.0i 0.0+0.0i 0.0+0.0i 0.0+0.0i )

! ( 4.0+0.0i 1.0+2.0i 0.0+0.0i 0.0+0.0i )

! ( 10.0+0.0i 0.0+4.0i 0.0+0.0i )

! ( 6.0+0.0i 1.0+1.0i )

! ( 9.0+0.0i )

!

! B = ( 3.0+3.0i 5.0-5.0i 5.0+4.0i 9.0+7.0i -22.0+1.0i )

!

DATA A /(2.0,0.0), 4*(0.0,0.0), (-1.0,1.0), (4.0,0.0),&

4*(0.0,0.0), (1.0,2.0), (10.0,0.0), 4*(0.0,0.0),&

(0.0,4.0), (6.0,0.0), 4*(0.0,0.0), (1.0,1.0), (9.0,0.0)/

DATA B /(3.0,3.0), (5.0,-5.0), (5.0,4.0), (9.0,7.0), (-22.0,1.0)/

! Factor the matrix A

CALL LFCDH (A, FACT, RCOND)

! Print the estimated condition number

CALL UMACH (2, NOUT)

WRITE (NOUT,99999) RCOND, 1.0E0/RCOND

! Compute the solutions, then perturb B

DO 10 I=1, 3

CALL LFIDH (A, FACT, B, X(:,I), RES(:,I))

B(2) = B(2) + (0.5E0,0.5E0)

10 CONTINUE

! Print solutions and residuals

CALL WRCRN (’X’, X)

CALL WRCRN (’RES’, RES)

!

99999 FORMAT (’ RCOND = ’,F5.3,/,’ L1 Condition number = ’,F6.3)

END

Output

 

RCOND < 0.07

L1 Condition number < 25.0

X

1 2 3

1 ( 1.000, 0.000) ( 1.217, 0.000) ( 1.433, 0.000)

2 ( 1.000,-2.000) ( 1.217,-1.783) ( 1.433,-1.567)

3 ( 2.000, 0.000) ( 1.910, 0.030) ( 1.820, 0.060)

4 ( 2.000, 3.000) ( 1.979, 2.938) ( 1.959, 2.876)

5 (-3.000, 0.000) (-2.991, 0.005) (-2.982, 0.009)

 

RES

1 2 3

1 ( 1.192E-07, 0.000E+00) ( 6.592E-08, 1.686E-07) ( 1.318E-07, 2.010E-14)

2 ( 1.192E-07,-2.384E-07) (-5.329E-08,-5.329E-08) ( 1.318E-07,-2.258E-07)

3 ( 2.384E-07, 8.259E-08) ( 2.390E-07,-3.309E-08) ( 2.395E-07, 1.015E-07)

4 (-2.384E-07, 2.814E-14) (-8.240E-08,-8.790E-09) (-1.648E-07,-1.758E-08)

5 (-2.384E-07,-1.401E-08) (-2.813E-07, 6.981E-09) (-3.241E-07,-2.795E-08)

ScaLAPACK Example

As in the preceding example, a set of linear systems is solved successively as a distributed computing example. The right-hand-side vector is perturbed by adding (1 + i)/2 to the second element after each call to LFIDH. SCALAPACK_MAP and SCALAPACK_UNMAP are IMSL utility routines (see 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 LFCDH_INT

USE LFIDH_INT

USE UMACH_INT

USE WRCRN_INT

USE SCALAPACK_SUPPORT

IMPLICIT NONE

INCLUDE ‘mpif.h’

! Declare variables

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

INTEGER INFO, MXCOL, MXLDA

REAL RCOND

COMPLEX, ALLOCATABLE :: A(:,:), B(:), B0(:), RES(:,:), X(:,:)

COMPLEX, ALLOCATABLE :: A0(:,:), FACT0(:,:), X0(:), RES0(:)

PARAMETER (LDA=5, N=5)

! Set up for MPI

MP_NPROCS = MP_SETUP()

IF(MP_RANK .EQ. 0) THEN

ALLOCATE (A(LDA,N), B(N), RES(N,3), X(N,3))

! Set values for A and B

A(1,:) = (/(2.0, 0.0),(-1.0, 1.0),( 0.0, 0.0),(0.0, 0.0),(0.0, 0.0)/)

A(2,:) = (/(0.0, 0.0),( 4.0, 0.0),( 1.0, 2.0),(0.0, 0.0),(0.0, 0.0)/)

A(3,:) = (/(0.0, 0.0),( 0.0, 0.0),(10.0, 0.0),(0.0, 4.0),(0.0, 0.0)/)

A(4,:) = (/(0.0, 0.0),( 0.0, 0.0),( 0.0, 0.0),(6.0, 0.0),(1.0, 1.0)/)

A(5,:) = (/(0.0, 0.0),( 0.0, 0.0),( 0.0, 0.0),(0.0, 0.0),(9.0, 0.0)/)

!

B = (/(3.0, 3.0),( 5.0,-5.0),( 5.0, 4.0),(9.0, 7.0),(-22.0,1.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), X0(MXLDA),FACT0(MXLDA,MXCOL), &

B0(MXLDA), RES0(MXLDA))

! Map input arrays to the processor grid

CALL SCALAPACK_MAP(A, DESCA, A0)

! Factor the matrix A

CALL LFCDH (A0, FACT0, RCOND)

! Print the estimated condition number

IF(MP_RANK .EQ. 0) THEN

CALL UMACH (2, NOUT)

WRITE (NOUT,99999) RCOND, 1.0E0/RCOND

ENDIF

! Compute the solutions

DO 10 J=1, 3

CALL SCALAPACK_MAP(B, DESCX, B0)

CALL LFIDH (A0, FACT0, B0, X0, RES0)

! Unmap the results from the distributed

! array back to a non-distributed array

CALL SCALAPACK_UNMAP(X0, DESCX, X(:,J))

CALL SCALAPACK_UNMAP(RES0, DESCX, RES(:,J))

IF(MP_RANK .EQ. 0) B(2) = B(2) + (0.5E0, 0.5E0)

10 CONTINUE

! Print the results.

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

! array.

IF(MP_RANK .EQ. 0) THEN

CALL WRCRN (’X’, X)

CALL WRCRN (’RES’, RES)

ENDIF

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

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 = ’,F6.3)

END

Output

 

RCOND < 0.07

L1 Condition number < 25.0

X

1 2 3

1 ( 1.000, 0.000) ( 1.217, 0.000) ( 1.433, 0.000)

2 ( 1.000,-2.000) ( 1.217,-1.783) ( 1.433,-1.567)

3 ( 2.000, 0.000) ( 1.910, 0.030) ( 1.820, 0.060)

4 ( 2.000, 3.000) ( 1.979, 2.938) ( 1.959, 2.876)

5 (-3.000, 0.000) (-2.991, 0.005) (-2.982, 0.009)

RES

1 2 3

1 ( 1.192E-07, 0.000E+00) ( 6.592E-08, 1.686E-07) ( 1.318E-07, 2.010E-14)

2 ( 1.192E-07,-2.384E-07) (-5.329E-08,-5.329E-08) ( 1.318E-07,-2.258E-07)

3 ( 2.384E-07, 8.259E-08) ( 2.390E-07,-3.309E-08) ( 2.395E-07, 1.015E-07)

4 (-2.384E-07, 2.814E-14) (-8.240E-08,-8.790E-09) (-1.648E-07,-1.758E-08)

5 (-2.384E-07,-1.401E-08) (-2.813E-07, 6.981E-09) (-3.241E-07,-2.795E-08)