Skip to content

Commit 51e4a80

Browse files
committed
kwargs kinda working. still need to standardize across wrappers
1 parent 7537ef9 commit 51e4a80

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/wrappers.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
138138
args = (cache.cacheval, cache.A, cache.b)
139139
kwargs = (atol=abstol, rtol=reltol, itmax=maxiter, alg.kwargs...)
140140

141-
if cache.cacheval == Krylov.CgSolver
141+
if cache.cacheval == Krylov.GmresSolver
142+
Krylov.solve!(args...; M=alg.Pl, N=alg.Pr,
143+
kwargs...)
144+
elseif cache.cacheval == Krylov.CgSolver
142145
alg.Pr != LinearAlgebra.I &&
143146
@warn "$(alg.KrylovAlg) doesn't support right preconditioning."
144147
Krylov.solve!(args...; M=alg.Pl,
145148
kwargs...)
146-
elseif cache.cacheval == Krylov.GmresSolver
147-
Krylov.solve!(args...; M=alg.Pl, N=alg.Pr,
148-
kwargs...)
149149
else
150150
Krylov.solve!(args...; M=alg.Pl, N=alg.Pr,
151151
kwargs...)

test/runtests.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Test
33

44
@testset "LinearSolve.jl" begin
55
using LinearAlgebra
6-
n = 32
6+
n = 8
77

88
A = Matrix(I,n,n)
99
b = ones(n)
@@ -21,25 +21,26 @@ using Test
2121
A3 = prob3.A; b3 = prob3.b; x3 = prob3.u0
2222

2323
@eval begin
24-
y = solve($prob1, $alg($kwargs...))
24+
y = solve($prob1, $alg(;$kwargs...))
2525
@test $A1 * y $b1 # out of place
2626
@test $A1 * $x1 $b1 # in place
2727

28-
y = $alg($kwargs...)($x2, $A2, $b2) # alg is callable
28+
y = $alg(;$kwargs...)($x2, $A2, $b2) # alg is callable
2929
@test $A2 * y $b2
3030
@test $A2 * $x2 $b2
3131

32-
cache = SciMLBase.init($prob1, $alg($kwargs...)) # initialize cache
33-
y = cache($x3, $A1, $b1) # cache is callable
32+
cache = SciMLBase.init($prob1, # initialize cache
33+
$alg(;$kwargs...))
34+
y = cache($x3, $A1, $b1) # cache is callable
3435
@test $A1 * y $b1
3536
@test $A1 * $x3 $b1
3637

37-
y = cache($x3, $A1, $b2) # reuse factorization
38+
y = cache($x3, $A1, $b2) # reuse factorization
3839
@test $A1 * y $b2
3940
@test $A1 * $x3 $b2
4041

41-
y = cache($x3, $A2, $b3) # new factorization
42-
@test $A2 * y $b3 # same old cache
42+
y = cache($x3, $A2, $b3) # new factorization
43+
@test $A2 * y $b3 # same old cache
4344
@test $A2 * $x3 $b3
4445
end
4546

@@ -57,7 +58,7 @@ using Test
5758
end
5859

5960
# KrylovJL
60-
kwargs = :(verbose=1, abstol=1e-1, reltol=1e-1, maxiters=3, restart=5)
61+
kwargs = :(verbose=1, abstol=1e-1, reltol=1e-1, maxiter=3, restart=5)
6162
for alg in (
6263
:KrylovJL,
6364
:KrylovJL_CG,
@@ -69,7 +70,7 @@ using Test
6970
end
7071

7172
# IterativeSolversJL
72-
kwargs = :(abstol=1e-1, reltol=1e-1, maxiters=3, restart=5)
73+
kwargs = :(abstol=1e-1, reltol=1e-1, maxiter=3, restart=5)
7374
for alg in (
7475
:IterativeSolversJL,
7576
:IterativeSolversJL_CG,

0 commit comments

Comments
 (0)