Sparse direct minimum-norm solver class.
type(cholesky_minnorm_solver) :: solver
call solver%analyze(m, n, irow, icol, istat) ! once for the sparsity pattern
call solver%factor(a, damp, istat) ! each time the values of A change
call solver%solve(b, x, istat) ! for each right-hand side
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | private | :: | analyzed | = | .false. |
if |
|
| logical, | private | :: | factored | = | .false. |
if |
|
| integer, | private | :: | m | = | 0 |
number of rows in |
|
| integer, | private | :: | n | = | 0 |
number of columns in |
|
| integer, | private | :: | nnz | = | 0 |
number of nonzeros in |
|
| real(kind=wp), | private | :: | damp | = | zero |
damping parameter used in the factorization |
|
| integer, | private, | dimension(:), allocatable | :: | rowptr |
row pointers (size |
||
| integer, | private, | dimension(:), allocatable | :: | colidx |
column indices (size |
||
| integer, | private, | dimension(:), allocatable | :: | map |
index into the user's |
||
| real(kind=wp), | private, | dimension(:), allocatable | :: | val |
values of |
||
| integer, | private, | dimension(:), allocatable | :: | adjptr |
(size |
||
| integer, | private, | dimension(:), allocatable | :: | adj |
(size |
||
| integer, | private, | dimension(:), allocatable | :: | perm |
|
||
| integer, | private, | dimension(:), allocatable | :: | iperm |
|
||
| integer, | private, | dimension(:), allocatable | :: | first |
first column in each row (size |
||
| integer(kind=ip), | private, | dimension(:), allocatable | :: | ptr |
start of each row in |
||
| real(kind=wp), | private, | dimension(:), allocatable | :: | env |
envelope values |
Symbolic analysis of the sparsity pattern of A.
This only has to be called once for a given sparsity pattern.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cholesky_minnorm_solver), | intent(inout) | :: | me | |||
| integer, | intent(in) | :: | m |
number of rows in |
||
| integer, | intent(in) | :: | n |
number of columns in |
||
| integer, | intent(in), | dimension(:) | :: | irow |
row indices of the nonzero elements of |
|
| integer, | intent(in), | dimension(:) | :: | icol |
column indices of the nonzero elements of |
|
| integer, | intent(out) | :: | istat |
status code ( |
Numeric factorization: form in the envelope storage and compute its Cholesky factorization .
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cholesky_minnorm_solver), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | a |
nonzero elements of |
|
| real(kind=wp), | intent(in) | :: | damp |
damping parameter ( |
||
| integer, | intent(out) | :: | istat |
status code ( |
Solve for the minimum-norm solution: , .
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cholesky_minnorm_solver), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | b |
right-hand side (size |
|
| real(kind=wp), | intent(out), | dimension(:) | :: | x |
minimum-norm solution (size |
|
| integer, | intent(out) | :: | istat |
status code ( |
||
| 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 |
Destroy the solver (deallocate all the arrays).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cholesky_minnorm_solver), | intent(out) | :: | me |
Returns true if analyze has been called successfully.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cholesky_minnorm_solver), | intent(in) | :: | 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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cholesky_minnorm_solver), | intent(in) | :: | me |
Maximum bandwidth of the reordered . Returns -1 if not analyzed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cholesky_minnorm_solver), | intent(in) | :: | me |
Returns the row ordering computed by analyze:
perm(new) = old. Returns an unallocated array if not analyzed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cholesky_minnorm_solver), | intent(in) | :: | me | |||
| integer, | intent(out), | dimension(:), allocatable | :: | perm |
Solve using the Cholesky factor.
c and y are in the original row ordering.
| Type | Intent | Optional | 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 |
type,public :: cholesky_minnorm_solver !! Sparse direct minimum-norm solver class. !! !!### Example !!```fortran !! type(cholesky_minnorm_solver) :: solver !! call solver%analyze(m, n, irow, icol, istat) ! once for the sparsity pattern !! call solver%factor(a, damp, istat) ! each time the values of A change !! call solver%solve(b, x, istat) ! for each right-hand side !!``` private logical :: analyzed = .false. !! if `analyze` has been called logical :: factored = .false. !! if `factor` has been called integer :: m = 0 !! number of rows in `A` integer :: n = 0 !! number of columns in `A` integer :: nnz = 0 !! number of nonzeros in `A` real(wp) :: damp = zero !! damping parameter used in the factorization ! `A` stored by rows (CSR): integer,dimension(:),allocatable :: rowptr !! row pointers (size `m+1`) integer,dimension(:),allocatable :: colidx !! column indices (size `nnz`) integer,dimension(:),allocatable :: map !! index into the user's `a` array for each CSR element (size `nnz`) real(wp),dimension(:),allocatable :: val !! values of `A` in CSR order (size `nnz`) ! graph of `A*A^T` (off-diagonal nonzeros), CSR: integer,dimension(:),allocatable :: adjptr !! (size `m+1`) integer,dimension(:),allocatable :: adj !! (size `adjptr(m+1)-1`) ! row ordering: integer,dimension(:),allocatable :: perm !! `perm(new) = old` integer,dimension(:),allocatable :: iperm !! `iperm(old) = new` ! envelope storage of the lower triangle of L (in the new ordering): ! row `r` holds columns `first(r):r`, stored contiguously starting at `ptr(r)`. integer,dimension(:),allocatable :: first !! first column in each row (size `m`) integer(ip),dimension(:),allocatable :: ptr !! start of each row in `env` (size `m+1`) real(wp),dimension(:),allocatable :: env !! envelope values contains private 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 :: lower_solve end type cholesky_minnorm_solver