Skip to content

Commit ffda841

Browse files
authored
Merge pull request #222 from JuliaDiffEq/myb/muladd
Add `conj` as a special case and add promotion rule
2 parents 5f8c8ad + 7b898c9 commit ffda841

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

Diff for: Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkit"
22
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "1.1.2"
4+
version = "1.1.3"
55

66
[deps]
77
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"

Diff for: src/function_registration.jl

+1
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ end
5656
Base.:^(x::Expression,y::T) where T <: Integer = Operation(Base.:^, Expression[x, y])
5757
Base.:^(x::Expression,y::T) where T <: Rational = Operation(Base.:^, Expression[x, y])
5858

59+
@register Base.conj(x)
5960
@register Base.getindex(x,i)
6061
Base.getindex(x::Operation,i::Int64) = Operation(getindex,[x,i])

Diff for: src/operations.jl

+4
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ Operation(x) = convert(Operation, x)
6666
#convert to Expr
6767
Base.Expr(op::Operation) = simplified_expr(op)
6868
Base.convert(::Type{Expr},x::Operation) = Expr(x)
69+
70+
# promotion
71+
Base.promote_rule(::Type{<:Constant}, ::Type{<:Operation}) = Operation
72+
Base.promote_rule(::Type{<:Operation}, ::Type{<:Constant}) = Operation

Diff for: test/direct.jl

+4
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@ function test_worldage()
8181
f_iip(out,[1.0,2,3])
8282
end
8383
test_worldage()
84+
85+
@test_nowarn muladd(x, y, ModelingToolkit.Constant(0))
86+
@test promote(x, ModelingToolkit.Constant(0)) == (x, identity(0))
87+
@test_nowarn [x, y, z]'

0 commit comments

Comments
 (0)