diff --git a/src/Symbolics.jl b/src/Symbolics.jl index ee49f05f5..57c03fbdd 100644 --- a/src/Symbolics.jl +++ b/src/Symbolics.jl @@ -23,7 +23,7 @@ RuntimeGeneratedFunctions.init(@__MODULE__) export simplify, substitute -using SciMLBase +using SciMLBase, IfElse export Num include("num.jl") @@ -57,7 +57,7 @@ import Libdl include("build_function.jl") export build_function -using IfElse, Distributions +using Distributions include("extra_functions.jl") using Latexify diff --git a/src/extra_functions.jl b/src/extra_functions.jl index f07a9dd87..300aa5bd0 100644 --- a/src/extra_functions.jl +++ b/src/extra_functions.jl @@ -24,8 +24,6 @@ function derivative(::typeof(max), args::NTuple{2,Any}, ::Val{2}) IfElse.ifelse(x > y, zero(y), one(y)) end -IfElse.ifelse(x::Num,y,z) = Num(Term{Real}(IfElse.ifelse, [value(x), value(y), value(z)])) - @register Base.rand(x) @register Base.randn(x) diff --git a/src/num.jl b/src/num.jl index ba38f9bb7..bcc18b587 100644 --- a/src/num.jl +++ b/src/num.jl @@ -31,6 +31,8 @@ Base.typemin(::Type{Num}) = Num(-Inf) Base.typemax(::Type{Num}) = Num(Inf) Base.float(x::Num) = x +IfElse.ifelse(x::Num,y,z) = Num(IfElse.ifelse(value(x), value(y), value(z))) + Base.promote_rule(::Type{Bool}, ::Type{<:Num}) = Num for C in [Complex, Complex{Bool}] @eval begin