Skip to content

Commit 8a4f192

Browse files
committed
krylov precond
1 parent 834f467 commit 8a4f192

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/krylov.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
struct KrylovJL{AT,bT,A,K} <: SciMLLinearSolveAlgorithm
1+
struct KrylovJL{A,K} <: SciMLLinearSolveAlgorithm
22
solver::Function
3-
A::AT
4-
b::bT
53
args::A
64
kwargs::K
75
end
86

9-
function KrylovJL(A, b, args...; solver = gmres, kwargs...)
10-
return KrylovJL(solver, A, b, args, kwargs)
7+
function KrylovJL(args...; solver = gmres, kwargs...)
8+
return KrylovJL(solver, args, kwargs)
119
end
1210

1311
function SciMLBase.solve(cache::LinearCache, alg::KrylovJL,args...;kwargs...)
14-
@unpack A, b = cache
15-
x, stats = alg.solver(A, b, args...; kwargs...)
12+
@unpack A, b, Pl,Pr = cache
13+
x, stats = alg.solver(A, b, args...; M=Pl, N=Pr, kwargs...)
1614
resid = A * x - b
1715
retcode = stats.solved ? :Success : :Failure
1816
return x #SciMLBase.build_solution(prob, alg, x, resid; retcode = retcode)

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ using Test
1919

2020
# make algorithm callable - interoperable with DiffEq ecosystem
2121
@test A * LUFactorization()(x,A,b) b
22+
@test A * KrylovJL()(x,A,b) b
2223
@test_broken A * x b # in place
2324
end

0 commit comments

Comments
 (0)