LinearSolve.jl
LinearSolve.jl copied to clipboard
make preconditioners part of the solver rather than a random extra
This still needs tests, but I'm putting it up as a PR first to get feedback. The intended goal here is to make the dolinsolve
functionality in OrdinaryDiffEq of being able to pass in a precs
function that takes in A
and possibly some parameters and remakes your preconditioner for the new A
value.
Here's an example of the new functionality in action:
using LinearSolve, Krylov, KrylovPreconditioners, LinearAlgebra, SparseArrays
A, b = sprand(10,10, .5), rand(10);
prob = LinearProblem(A,b)
solver = KrylovJL_CG(precs=(A,p=nothing) -> (BlockJacobiPreconditioner(A, 2), I), ldiv=false)
cache = init(prob, solver)
solve!(cache)
reinit!(cache, A = sprand(10,10, .2), b = rand(10))
solve!(cache)