Skip to content

Commit 49132bc

Browse files
committed
deprecate preconditioner interface and use scimloperators
1 parent 9d8bb18 commit 49132bc

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

src/LinearSolve.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import Base: eltype, adjoint, inv
1010
using LinearAlgebra
1111
using IterativeSolvers: Identity
1212
using SparseArrays
13-
using SciMLBase: AbstractSciMLOperator, AbstractLinearAlgorithm
13+
using SciMLBase: AbstractLinearAlgorithm, DiffEqIdentity
14+
using SciMLOperators: AbstractSciMLOperator, IdentityOperator,
15+
InvertedOperator, ComposedOperator
1416
using Setfield
1517
using UnPack
1618
using SuiteSparse

src/iterative_wrappers.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
151151
N = cache.Pr
152152

153153
# use no-op preconditioner for Krylov.jl (LinearAlgebra.I) when M/N is identity
154-
M = _isidentity_struct(M) ? I : InvPreconditioner(M)
155-
N = _isidentity_struct(M) ? I : InvPreconditioner(N)
154+
M = _isidentity_struct(M) ? I : InvertedOperator(M)
155+
N = _isidentity_struct(M) ? I : InvertedOperator(N)
156156

157157
atol = float(cache.abstol)
158158
rtol = float(cache.reltol)

src/preconditioners.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# Tooling Preconditioners
2+
#
3+
# TODO - update Preconditioner docs
4+
# TODO - replace ComposePreconditoner with ComposedOperator after
5+
# ComposePreconditioner is deprecated in OrdinaryDiffEq
6+
7+
#const ComposePreconditioner = ComposedOperator
8+
#@deprecate ComposePreconditioner ComposedOperator
29

310
struct ComposePreconditioner{Ti, To}
411
inner::Ti
@@ -21,11 +28,5 @@ function LinearAlgebra.ldiv!(y, A::ComposePreconditioner, x)
2128
ldiv!(outer, y)
2229
end
2330

24-
struct InvPreconditioner{T}
25-
P::T
26-
end
27-
28-
Base.eltype(A::InvPreconditioner) = Base.eltype(A.P)
29-
LinearAlgebra.ldiv!(A::InvPreconditioner, x) = mul!(x, A.P, x)
30-
LinearAlgebra.ldiv!(y, A::InvPreconditioner, x) = mul!(y, A.P, x)
31-
LinearAlgebra.mul!(y, A::InvPreconditioner, x) = ldiv!(y, A.P, x)
31+
#const InvPreconditioner = InvertedOperator
32+
#@deprecate InvPreconditioner InvertedOperator

test/basictests.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,18 @@ end
271271

272272
@testset "Preconditioners" begin
273273
@testset "Vector Diagonal Preconditioner" begin
274-
s = rand(n)
275-
Pl, Pr = Diagonal(s), LinearSolve.InvPreconditioner(Diagonal(s))
274+
using SciMLOperators
276275

277276
x = rand(n, n)
278277
y = rand(n, n)
279278

279+
s = rand(n)
280+
Pl = Diagonal(s)
281+
Pr = Diagonal(s)
282+
Pr = LinearSolve.InvertedOperator(MatrixOperator(Pr))
283+
Pr = cache_operator(Pr, x)
284+
#@test Pr == (@test_deprecated LinearSolve.InvPreconditioner(Diagonal(s)))
285+
280286
mul!(y, Pl, x)
281287
@test y s .* x
282288
mul!(y, Pr, x)

0 commit comments

Comments
 (0)