Skip to content

Commit 3575cb2

Browse files
committed
implemented adjoint, inv
1 parent e020ce0 commit 3575cb2

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/LinearSolve.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ module LinearSolve
33
using ArrayInterface
44
using RecursiveFactorization
55
using Base: cache_dependencies, Bool
6-
import Base: eltype, *
6+
import Base: eltype, adjoint, inv
77
using LinearAlgebra
88
using SparseArrays
99
using SciMLBase: AbstractDiffEqOperator, AbstractLinearAlgorithm
1010
using Setfield
1111
using UnPack
12-
using FastBroadcast
1312

1413
# wrap
1514
import Krylov

src/wrappers.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
P * x = x .* (1/P.s)
77
Pi * x = x .* (P.s)
88
9-
Right
9+
RIGHT
1010
P * x = x .* (P.s)
1111
Pi * x = x .* (1/P.s)
1212
"""
@@ -16,19 +16,15 @@ struct ScaleVector{T}
1616
end
1717

1818
Base.eltype(A::ScaleVector) = eltype(A.s)
19-
20-
#function Base.*(A::ScaleVector, x)
21-
# y = similar(x)
22-
# mul!(y, A, x)
23-
#end
19+
Base.adjoint(A::ScaleVector) = copy(A)
20+
Base.inv(A::ScaleVector) = ScaleVector(1/A.s, A.isleft)
2421

2522
# y = A x
2623
function LinearAlgebra.mul!(y, A::ScaleVector, x)
2724
A.s == one(eltype(A.s)) && return y = x
2825

2926
s = A.isleft ? 1/A.s : A.s
3027
mul!(y, s, x)
31-
3228
end
3329

3430
# A B α + C β
@@ -63,6 +59,8 @@ struct ComposePreconditioner{Ti,To}
6359
end
6460

6561
Base.eltype(A::ComposePreconditioner) = Float64 #eltype(A.inner)
62+
Base.adjoint(A::ComposePreconditioner) = ComposePreconditioner(A.outer', A.inner')
63+
Base.inv(A::ComposePreconditioner) = ComposePreconditioner(inv(A.outer), inv(A.inner))
6664

6765
# y = A x
6866
function LinearAlgebra.mul!(y, A::ComposePreconditioner, x)
@@ -200,6 +198,10 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
200198
M = alg.Pl
201199
N = alg.Pr
202200

201+
"""
202+
TODO - pass in inv(Pl), inv(Pr) to Krylov.jl
203+
"""
204+
203205
# M = ComposePreconditioner(alg.Pl, cache.Pl) # left precond
204206
# N = ComposePreconditioner(alg.Pr, cache.Pr) # right
205207

0 commit comments

Comments
 (0)