Skip to content

Commit 01ff629

Browse files
committed
base zero, one
1 parent 495f1c5 commit 01ff629

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/SciMLOperators.jl

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

1313
# overload
14-
import Base: +, -, *, /, \, , ==
15-
import Base: conj, one, iszero, inv, adjoint, transpose, size, convert, Matrix
14+
import Base: +, -, *, /, \, , ==, one, zero
15+
import Base: conj, iszero, inv, adjoint, transpose, size, convert, Matrix
1616
import LinearAlgebra: mul!, ldiv!, lmul!, rmul!, factorize, exp, Diagonal
1717
import SparseArrays: sparse
1818

src/basic.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ function Base.one(A::AbstractSciMLOperator)
1212
IdentityOperator{N}()
1313
end
1414

15-
# TODO - sparse diagonal
1615
Base.convert(::Type{AbstractMatrix}, ::IdentityOperator{N}) where{N} = Diagonal(ones(Bool, N))
1716

1817
# traits
@@ -187,6 +186,8 @@ function Base.adjoint(α::ScalarOperator) # TODO - test
187186
ScalarOperator(val; update_func=update_func)
188187
end
189188
Base.transpose::ScalarOperator) = α
189+
Base.one(::Type{AbstractSciMLOperator}) = ScalarOperator(true)
190+
Base.zero(::Type{AbstractSciMLOperator}) = ScalarOperator(false)
190191

191192
getops::ScalarOperator) =.val,)
192193
islinear(L::ScalarOperator) = true

0 commit comments

Comments
 (0)