nlesolver_cholesky_module Module

Sparse direct minimum-norm linear solver, using a Cholesky factorization of (no external dependencies).

Computes the minimum-norm solution of the compatible system , where A is an m x n sparse matrix (normally n >= m) in coordinate (triplet) format:

With damp , this is the solution of the regularized problem subject to (useful if A is rank deficient).

Method

  1. Analysis (done once for a sparsity pattern, see analyze): the graph of is formed, and its rows are reordered with the reverse Cuthill-McKee (RCM) algorithm to reduce the envelope (profile) of the matrix. The envelope storage of the Cholesky factor is then allocated. Since all fill-in of a Cholesky factorization is confined to the envelope, no further symbolic work is needed.
  2. Factorization (each time the values of A change, see factor): is formed directly in the envelope storage from the sparse rows of A (the dense matrix is never formed), and factored as using a row-oriented envelope Cholesky factorization.
  3. Solve (see solve): triangular solves with L, followed by x = A^T y. Since forming squares the condition number, a few steps of iterative refinement are performed using the residual of the original system. Each correction stays in the range of , so the minimum-norm property is kept.

The cost of the factorization is , where b is the (average) bandwidth of the reordered . This is very efficient for banded or "mostly banded" Jacobians (even if the rows are not numbered in banded order). For general sparse matrices with large fill-in (e.g., 2D/3D meshes), a nested-dissection based solver (such as qr_mumps) will be faster.

References

  • A. George and J. W. H. Liu, "Computer Solution of Large Sparse Positive Definite Systems", Prentice-Hall, 1981.
  • E. Cuthill and J. McKee, "Reducing the bandwidth of sparse symmetric matrices", Proc. 24th ACM National Conference, 1969.
  • A. Bjorck, "Numerical Methods for Least Squares Problems", SIAM, 1996.

Uses

  • module~~nlesolver_cholesky_module~~UsesGraph module~nlesolver_cholesky_module nlesolver_cholesky_module iso_fortran_env iso_fortran_env module~nlesolver_cholesky_module->iso_fortran_env

Used by

  • module~~nlesolver_cholesky_module~~UsedByGraph module~nlesolver_cholesky_module nlesolver_cholesky_module module~nlesolver_module nlesolver_module module~nlesolver_module->module~nlesolver_cholesky_module

Variables

Type Visibility Attributes Name Initial
integer, private, parameter :: wp = real64

real kind used by this module [8 bytes]

integer, private, parameter :: ip = int64

integer kind for indexing the envelope storage

real(kind=wp), private, parameter :: zero = 0.0_wp
real(kind=wp), private, parameter :: eps = epsilon(1.0_wp)
integer, public, parameter :: CHOLESKY_SUCCESS = 0

success

integer, public, parameter :: CHOLESKY_ERR_INPUT = -1

invalid inputs (e.g., irow, icol out of range)

integer, public, parameter :: CHOLESKY_ERR_MEMORY = -2

out of memory (envelope too large)

integer, public, parameter :: CHOLESKY_ERR_NOT_PD = -3

is not positive definite (A is rank deficient). Try damp>0.

integer, public, parameter :: CHOLESKY_ERR_NOT_READY = -4

analyze or factor has not been called


Derived Types

type, public ::  cholesky_minnorm_solver

Sparse direct minimum-norm solver class.

Read more…

Components

Type Visibility Attributes Name Initial
logical, private :: analyzed = .false.

if analyze has been called

logical, private :: factored = .false.

if factor has been called

integer, private :: m = 0

number of rows in A

integer, private :: n = 0

number of columns in A

integer, private :: nnz = 0

number of nonzeros in A

real(kind=wp), private :: damp = zero

damping parameter used in the factorization

integer, private, dimension(:), allocatable :: rowptr

row pointers (size m+1)

integer, private, dimension(:), allocatable :: colidx

column indices (size nnz)

integer, private, dimension(:), allocatable :: map

index into the user's a array for each CSR element (size nnz)

real(kind=wp), private, dimension(:), allocatable :: val

values of A in CSR order (size nnz)

integer, private, dimension(:), allocatable :: adjptr

(size m+1)

integer, private, dimension(:), allocatable :: adj

(size adjptr(m+1)-1)

integer, private, dimension(:), allocatable :: perm

perm(new) = old

integer, private, dimension(:), allocatable :: iperm

iperm(old) = new

integer, private, dimension(:), allocatable :: first

first column in each row (size m)

integer(kind=ip), private, dimension(:), allocatable :: ptr

start of each row in env (size m+1)

real(kind=wp), private, dimension(:), allocatable :: env

envelope values

Type-Bound Procedures

procedure, public :: analyze
procedure, public :: factor
procedure, public :: solve
procedure, public :: destroy
procedure, public :: is_analyzed
procedure, public :: envelope_size
procedure, public :: bandwidth
procedure, public :: get_permutation
procedure, private :: lower_solve

Functions

private pure function is_analyzed(me)

Returns true if analyze has been called successfully.

Arguments

Type IntentOptional Attributes Name
class(cholesky_minnorm_solver), intent(in) :: me

Return Value logical

private pure function envelope_size(me)

Number of elements in the envelope of the Cholesky factor (i.e., the storage required for L, in reals). Returns 0 if not analyzed.

Arguments

Type IntentOptional Attributes Name
class(cholesky_minnorm_solver), intent(in) :: me

Return Value integer(kind=int64)

private pure function bandwidth(me)

Maximum bandwidth of the reordered . Returns -1 if not analyzed.

Arguments

Type IntentOptional Attributes Name
class(cholesky_minnorm_solver), intent(in) :: me

Return Value integer


Subroutines

private subroutine destroy(me)

Destroy the solver (deallocate all the arrays).

Arguments

Type IntentOptional Attributes Name
class(cholesky_minnorm_solver), intent(out) :: me

private subroutine get_permutation(me, perm)

Returns the row ordering computed by analyze: perm(new) = old. Returns an unallocated array if not analyzed.

Arguments

Type IntentOptional Attributes Name
class(cholesky_minnorm_solver), intent(in) :: me
integer, intent(out), dimension(:), allocatable :: perm

private subroutine analyze(me, m, n, irow, icol, istat)

Symbolic analysis of the sparsity pattern of A. This only has to be called once for a given sparsity pattern.

Read more…

Arguments

Type IntentOptional Attributes Name
class(cholesky_minnorm_solver), intent(inout) :: me
integer, intent(in) :: m

number of rows in A

integer, intent(in) :: n

number of columns in A

integer, intent(in), dimension(:) :: irow

row indices of the nonzero elements of A

integer, intent(in), dimension(:) :: icol

column indices of the nonzero elements of A (same size as irow)

integer, intent(out) :: istat

status code (CHOLESKY_SUCCESS if no errors)

private subroutine rcm(m, adjptr, adj, perm)

Reverse Cuthill-McKee ordering of a symmetric graph.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: m

number of nodes

integer, intent(in), dimension(:) :: adjptr

adjacency pointers (size m+1)

integer, intent(in), dimension(:) :: adj

adjacency lists

integer, intent(out), dimension(m) :: perm

the ordering: perm(new) = old

private subroutine factor(me, a, damp, istat)

Numeric factorization: form in the envelope storage and compute its Cholesky factorization .

Read more…

Arguments

Type IntentOptional Attributes Name
class(cholesky_minnorm_solver), intent(inout) :: me
real(kind=wp), intent(in), dimension(:) :: a

nonzero elements of A (in the same order as irow and icol in analyze)

real(kind=wp), intent(in) :: damp

damping parameter (0 for none)

integer, intent(out) :: istat

status code (CHOLESKY_SUCCESS if no errors)

private subroutine lower_solve(me, c, y)

Solve using the Cholesky factor. c and y are in the original row ordering.

Arguments

Type IntentOptional Attributes Name
class(cholesky_minnorm_solver), intent(in) :: me
real(kind=wp), intent(in), dimension(me%m) :: c
real(kind=wp), intent(out), dimension(me%m) :: y

private subroutine solve(me, b, x, istat, n_refine, rnorm)

Solve for the minimum-norm solution: , .

Read more…

Arguments

Type IntentOptional Attributes Name
class(cholesky_minnorm_solver), intent(inout) :: me
real(kind=wp), intent(in), dimension(:) :: b

right-hand side (size m)

real(kind=wp), intent(out), dimension(:) :: x

minimum-norm solution (size n)

integer, intent(out) :: istat

status code (CHOLESKY_SUCCESS if no errors)

integer, intent(in), optional :: n_refine

maximum number of iterative refinement steps (default is 2)

real(kind=wp), intent(out), optional :: rnorm

final residual norm