module Custom:sig
..end
Custom linear solvers.
type('data, 'kind)
atimesfn =('data, 'kind) Nvector.t -> ('data, 'kind) Nvector.t -> unit
A function atimesfn v z
computes the action of the system
matrix on the vector v
, storing the result in z
. The matrix is
represented implicitly by the effect of the function.
If a problem occurs the function raises Sundials_LinearSolver.ATimesFailure
.
typepsetupfn =
unit -> unit
Functions that set up any problem data in preparation for calls to
psolvefn
.
If a problem occurs the function raises Sundials_LinearSolver.PSetFailure
.
type('data, 'kind)
psolvefn =('data, 'kind) Nvector.t -> ('data, 'kind) Nvector.t -> float -> bool -> unit
A function psolvefn r z tol lr
that solves the preconditioner
equation $Pz = r$ for the vector z
such that
$\left\lVert Pz - r \right\rVert_\mathrm{wrms} < \mathit{tol}$ .
If lr
is true
then $P$ should be treated as a left
preconditioner and otherwise as a right preconditioner.
If a problem occurs the function raises Sundials_LinearSolver.PSolveFailure
.
type ('matrix, 'data, 'kind, 'lsolver)
ops = {
|
solver_type : |
(* | Broadly classifies the operations provided by a linear solver and its operating principle. | *) |
|
solver_id : |
(* | Identifies the linear solver. This value should normally be set to Custom. | *) |
|
init : |
(* | Performs linear solver initalization. | *) |
|
setup : |
(* | Performs linear solver setup. | *) |
|
solve : |
(* | The call Direct solvers can ignore | *) |
|
set_atimes : |
(* | Provides the linear solver with a problem-specific | *) |
|
set_preconditioner : |
(* | Provides the linear solver with preconditioner routines.
The given functions may only be used within | *) |
|
set_scaling_vectors : |
(* | Passes the left/right scaling vectors for use in | *) |
|
set_zero_guess : |
(* | Used to indicate whether the next call to the solve function will be made with a zero initial guess. | *) |
|
get_num_iters : |
(* | The number of linear iterations performed in the last | *) |
|
get_res_norm : |
(* | The final residual norm from the last | *) |
|
get_res_id : |
(* | The preconditioned initial residual vector. This vector may be
requested if the iterative method computes the preconditioned
initial residual and returns from | *) |
|
get_last_flag : |
(* | Use to indicate the last error encountered by the linear solver. | *) |
|
get_work_space : |
(* | Return the storage requirements for the linear solver.
The result | *) |
|
set_prec_type : |
(* | Called by Iterative.set_prec_type and when a linear solver is associated with an integrator. | *) |
}
The operations required to implement an iterative linear solver.
Failure should be indicated by raising an exception (preferably
one of the exceptions in this package). Raising
Sundials.RecoverableFailure
indicates a generic
recoverable failure.
val make_ops : ?solver_id:Sundials_LinearSolver.linear_solver_id ->
?init:('lsolver -> unit) ->
?setup:('lsolver -> 'matrix -> unit) ->
?set_atimes:('lsolver ->
('data, 'kind) atimesfn -> unit) ->
?set_preconditioner:('lsolver ->
psetupfn option ->
('data, 'kind) psolvefn
option -> unit) ->
?set_scaling_vectors:('lsolver -> 'data option -> 'data option -> unit) ->
?set_zero_guess:('lsolver -> bool -> unit) ->
?get_num_iters:('lsolver -> int) ->
?get_res_norm:('lsolver -> float) ->
?get_res_id:('lsolver -> ('data, 'kind) Nvector.t) ->
?get_last_flag:('lsolver -> int) ->
?get_work_space:('lsolver -> int * int) ->
?set_prec_type:('lsolver ->
Sundials_LinearSolver.Iterative.preconditioning_type -> unit) ->
solver_type:Sundials_LinearSolver.linear_solver_type ->
solve:('lsolver -> 'matrix -> 'data -> 'data -> float -> unit) ->
unit -> ('matrix, 'data, 'kind, 'lsolver) ops
Convenience function for constructing a Sundials_LinearSolver.Custom.ops
value.
val make_with_matrix : ('matrix, 'data, 'kind, 'lsolver) ops ->
?context:Sundials.Context.t ->
'lsolver ->
('matrixkind, 'matrix, 'data, 'kind) Sundials.Matrix.t ->
('matrix, 'data, 'kind, [ `Custom of 'lsolver | `Dls | `Iter ])
Sundials_LinearSolver.t
Create a linear solver given a set of operations and an internal state.
The resulting solver is tagged with both `Dls
and `Iter
, although
its suitability depends on which operations are defined.
Use a type cast to filter inappropriate tags.
The solver_type
may not be MatrixEmbedded.
NB: This feature is only available for Config.sundials_version >= 3.0.0.
val make_without_matrix : (unit, 'data, 'kind, 'lsolver) ops ->
?context:Sundials.Context.t ->
'lsolver ->
(unit, 'data, 'kind, [ `Custom of 'lsolver | `Iter | `MatE ])
Sundials_LinearSolver.t
Create a linear solver given a set of operations and an internal state.
The resulting solver is tagged with both `Dls
and `Iter
, although
its suitability depends on which operations are defined.
Use a type cast to filter inappropriate tags.
The solver_type
may not be Direct.
This feature is only available for Config.sundials_version >= 3.0.0.
The MatrixEmbedded solver_type is only available for Config.sundials_version >= 5.8.0.
val unwrap : ('m, 'data, 'kind, [> `Custom of 'lsolver ]) Sundials_LinearSolver.t ->
'lsolver
Return the internal state from an custom iterative linear solver.
type ('matrix, 'data, 'kind, 'lsolver)
dls_ops = {
|
init : |
(* | Performs linear solver initalization. | *) |
|
setup : |
(* | Performs linear solver setup based on an updated matrix. | *) |
|
solve : |
(* | The call | *) |
|
space : |
(* | Return the storage requirements for the linear solver.
The result | *) |
}
The operations required to implement a direct linear solver.
Failure should be indicated by raising an exception (preferably
one of the exceptions in this package). Raising
Sundials.RecoverableFailure
indicates a generic
recoverable failure.
val make_dls : ('matrix, 'data, 'kind, 'lsolver) dls_ops ->
?context:Sundials.Context.t ->
'lsolver ->
('matrixkind, 'matrix, 'data, 'kind) Sundials.Matrix.t ->
('matrix, 'data, 'kind, [ `Custom of 'lsolver | `Dls ])
Sundials_LinearSolver.t
Create a direct linear solver given a set of operations and an internal state.
NB: This feature is only available for Config.sundials_version >= 3.0.0.