Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support set of complex numbers by assumptions #1841

Merged
merged 1 commit into from Dec 1, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion symengine/assumptions.cpp
Expand Up @@ -14,7 +14,9 @@ Assumptions::Assumptions(const set_basic &statements)
const auto expr = contains.get_expr();
const auto set = contains.get_set();
if (is_a<Symbol>(*expr)) {
if (is_a<Reals>(*set)) {
if (is_a<Complexes>(*set)) {
complex_symbols_.insert(expr);
} else if (is_a<Reals>(*set)) {
complex_symbols_.insert(expr);
real_symbols_.insert(expr);
} else if (is_a<Rationals>(*set)) {
Expand Down
7 changes: 6 additions & 1 deletion symengine/tests/basic/test_assumptions.cpp
Expand Up @@ -4,6 +4,7 @@

using SymEngine::Assumptions;
using SymEngine::Basic;
using SymEngine::complexes;
using SymEngine::integer;
using SymEngine::integers;
using SymEngine::Number;
Expand Down Expand Up @@ -39,6 +40,10 @@ TEST_CASE("Test assumptions", "[assumptions]")
RCP<const Basic> rel14 = Ne(x, integer(0));
RCP<const Basic> rel;

Assumptions a = Assumptions({complexes()->contains(x)});
REQUIRE(is_true(a.is_complex(x)));
REQUIRE(is_indeterminate(a.is_real(x)));

auto a1 = Assumptions({s1->contains(x)});
REQUIRE(is_true(a1.is_real(x)));
REQUIRE(is_indeterminate(a1.is_integer(x)));
Expand Down Expand Up @@ -204,7 +209,7 @@ TEST_CASE("Test assumptions", "[assumptions]")
REQUIRE(is_false(a18.is_zero(x)));

rel = Eq(x, integer(1));
auto a = Assumptions({rel});
a = Assumptions({rel});
REQUIRE(is_true(a.is_nonzero(x)));
REQUIRE(is_false(a.is_zero(x)));

Expand Down