Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Basic(x::Basic) = x
Base.promote_rule(::Type{Basic}, ::Type{S}) where {S<:Number} = Basic
Base.promote_rule(::Type{S}, ::Type{Basic}) where {S<:Number} = Basic
Base.promote_rule(::Type{S}, ::Type{Basic}) where {S<:AbstractIrrational} = Basic
Base.promote_rule(::Type{Bool}, ::Type{Basic}) = Basic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should promote true to 1 or True in SymEngine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is a good question. Right now, neither True or False values are exposed. If True, is there some idiomatic way to make an expression like this evaluate to a number?

julia> True = Basic();

julia> ccall((:bool_set_true, SymEngine.libsymengine), Nothing, (Ref{Basic},), True)

julia> v = Basic(4) + True
4 + True

julia> SymEngine.evalf(v)
ERROR: ArgumentError: symbolic value cannot be evaluated to a numeric value


## Class ID
get_type(s::Basic) = ccall((:basic_get_type, libsymengine), UInt, (Ref{Basic},), s)
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ c = prod(convert(SymEngine.CVecBasic, [x, x, 2]))
@test 2 * x * 3 == 6 * x
@test 3 * 2 * x == 6 * x


# Issue #146
@test x + true == x + 1
@test x + false == x
@test x * true == x
@test x * false == 0

# https://github.com/symengine/SymEngine.jl/issues/259
@testset "Issue #259" begin
let (a, b, c) = symbols("a b c")
Expand All @@ -59,6 +66,7 @@ c = prod(convert(SymEngine.CVecBasic, [x, x, 2]))
end
end


c = x ^ 5
@test diff(c, x) == 5 * x ^ 4

Expand Down
Loading