Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/exceptions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function get_error(error_code::Cuint, str=nothing)
elseif error_code == 3
return ErrorException("Not implemented SymEngine feature")
elseif error_code == 4
return DomainError()
return DomainError(str)
elseif error_code == 5
return Meta.ParseError(str)
else
Expand Down
6 changes: 4 additions & 2 deletions src/mathfuns.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ function IMPLEMENT_ONE_ARG_FUNC(meth, symnm; lib=:basic_)
@eval begin
function ($meth)(b::SymbolicType)
a = Basic()
ccall(($(string(lib,symnm)), libsymengine), Nothing, (Ref{Basic}, Ref{Basic}), a, b)
err_code = ccall(($(string(lib,symnm)), libsymengine), Cuint, (Ref{Basic}, Ref{Basic}), a, b)
throw_if_error(err_code, $meth)
return a
end
end
Expand All @@ -15,7 +16,8 @@ function IMPLEMENT_TWO_ARG_FUNC(meth, symnm; lib=:basic_)
function ($meth)(b1::SymbolicType, b2::Number)
a = Basic()
b1, b2 = promote(b1, b2)
ccall(($(string(lib,symnm)), libsymengine), Nothing, (Ref{Basic}, Ref{Basic}, Ref{Basic}), a, b1, b2)
err_code = ccall(($(string(lib,symnm)), libsymengine), Cuint, (Ref{Basic}, Ref{Basic}, Ref{Basic}), a, b1, b2)
throw_if_error(err_code, $meth)
return a
end
end
Expand Down
3 changes: 2 additions & 1 deletion src/mathops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ for (op, libnm) in ((:+, :add), (:-, :sub), (:*, :mul), (:/, :div), (://, :div),
@eval begin
function ($op)(b1::Basic, b2::Basic)
a = Basic()
ccall($tup, Nothing, (Ref{Basic}, Ref{Basic}, Ref{Basic}), a, b1, b2)
err_code = ccall($tup, Cuint, (Ref{Basic}, Ref{Basic}, Ref{Basic}), a, b1, b2)
throw_if_error(err_code, $(string(libnm)))
return a
end
($op)(b1::BasicType, b2::BasicType) = ($op)(Basic(b1), Basic(b2))
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,8 @@ if SymEngine.libversion >= VersionNumber("0.4.0")
@test coeff(expr, x, Basic(0)) == y^3 + 1
end
end

# Check that infinities are handled correctly
@test_throws DomainError exp(zoo)
@test_throws DomainError sin(zoo)
@test_throws DomainError sin(oo)