Linear Solve
NonlinearSolve.AbstractLinearSolverCache
— TypeAbstractLinearSolverCache <: Function
Abstract Type for all Linear Solvers used in NonlinearSolve.jl.
NonlinearSolve.LinearSolverCache
— TypeLinearSolverCache(alg, linsolve, A, b, u; kwargs...)
Construct a cache for solving linear systems of the form A * u = b
. Following cases are handled:
A
is Number, then we solve it withu = b / A
A
isSMatrix
, then we solve it withu = A \ b
(using the defaults from base Julia)A
isDiagonal
, then we solve it withu = b ./ A.diag
- In all other cases, we use
alg
to solve the linear system using LinearSolve.jl.
Solving the System
(cache::LinearSolverCache)(; A = nothing, b = nothing, linu = nothing,
du = nothing, p = nothing, weight = nothing, cachedata = nothing,
reuse_A_if_factorization = false, kwargs...)
Returns the solution of the system u
and stores the updated cache in cache.lincache
.
Keyword Arguments
reuse_A_if_factorization
: Iftrue
, then the factorization ofA
is reused if possible. This is useful when solving the same system with differentb
values. If the algorithm is an iterative solver, then we reset the internal linear solve cache.
One distinct feature of this compared to the cache from LinearSolve is that it respects the aliasing arguments even after cache construction, i.e., if we passed in an A
that A
is not mutated, we do this by copying over A
to a preconstructed cache.