Skip to content

Commit 7f70a6d

Browse files
Merge pull request #65 from vpuri3/smallfixes
small fixes
2 parents 90ea308 + 759b278 commit 7f70a6d

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/SciMLOperators.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import Lazy: @forward
1111
import Setfield: @set!
1212

1313
# overload
14-
import Base: +, -, *, /, \, , ==, one, zero, conj, exp, kron
14+
import Base: zero, one, oneunit
15+
import Base: +, -, *, /, \, , ==, conj, exp, kron
1516
import Base: iszero, inv, adjoint, transpose, size, convert
1617
import LinearAlgebra: mul!, ldiv!, lmul!, rmul!, factorize
1718
import LinearAlgebra: Matrix, Diagonal

src/basic.jl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ struct IdentityOperator{N} <: AbstractSciMLLinearOperator{Bool} end
66
# constructors
77
IdentityOperator(u::AbstractArray) = IdentityOperator{size(u,1)}()
88

9-
function Base.one(A::AbstractSciMLOperator)
10-
@assert issquare(A)
11-
N = size(A, 1)
9+
function Base.one(L::AbstractSciMLOperator)
10+
@assert issquare(L)
11+
N = size(L, 1)
1212
IdentityOperator{N}()
1313
end
1414

@@ -96,9 +96,9 @@ struct NullOperator{N} <: AbstractSciMLLinearOperator{Bool} end
9696
# constructors
9797
NullOperator(u::AbstractArray) = NullOperator{size(u,1)}()
9898

99-
function Base.zero(A::AbstractSciMLOperator)
100-
@assert issquare(A)
101-
N = size(A, 1)
99+
function Base.zero(L::AbstractSciMLOperator)
100+
@assert issquare(L)
101+
N = size(L, 1)
102102
NullOperator{N}()
103103
end
104104

@@ -305,7 +305,7 @@ for op in (
305305
:adjoint,
306306
:transpose,
307307
)
308-
@eval Base.$op(L::ScaledOperator) = ScaledOperator($op(L.λ), $op(L.op))
308+
@eval Base.$op(L::ScaledOperator) = ScaledOperator($op(L.λ), $op(L.L))
309309
end
310310
LinearAlgebra.opnorm(L::ScaledOperator, p::Real=2) = abs(L.λ) * opnorm(L.L, p)
311311

@@ -325,7 +325,7 @@ function cache_internals(L::ScaledOperator, u::AbstractVecOrMat)
325325
end
326326

327327
# getindex
328-
Base.getindex(L::ScaledOperator, i::Int) = L.coeff * L.op[i]
328+
Base.getindex(L::ScaledOperator, i::Int) = L.coeff * L.L[i]
329329
Base.getindex(L::ScaledOperator, I::Vararg{Int, N}) where {N} = L.λ * L.L[I...]
330330
for fact in (
331331
:lu, :lu!,
@@ -649,6 +649,9 @@ has_mul!(L::InvertedOperator) = has_ldiv!(L.L)
649649
has_ldiv(L::InvertedOperator) = has_mul(L.L)
650650
has_ldiv!(L::InvertedOperator) = has_mul!(L.L)
651651

652+
Base.:\(A::AbstractSciMLOperator, B::AbstractSciMLOperator) = inv(A) * B
653+
Base.:/(A::AbstractSciMLOperator, B::AbstractSciMLOperator) = A * inv(B)
654+
652655
@forward InvertedOperator.L (
653656
# LinearAlgebra
654657
LinearAlgebra.issymmetric,

src/interface.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ Base.size(A::AbstractSciMLOperator, d::Integer) = d <= 2 ? size(A)[d] : 1
6666
Base.eltype(::Type{AbstractSciMLOperator{T}}) where T = T
6767
Base.eltype(::AbstractSciMLOperator{T}) where T = T
6868

69+
Base.oneunit(L::AbstractSciMLOperator) = one(L)
70+
Base.oneunit(LType::Type{<:AbstractSciMLOperator}) = one(LType)
71+
6972
issquare(L::AbstractSciMLOperator) = isequal(size(L)...)
7073

7174
Base.iszero(::AbstractSciMLOperator) = false

0 commit comments

Comments
 (0)