Skip to content

Commit

Permalink
Merge pull request #1841 from rikardn/complexesassump
Browse files Browse the repository at this point in the history
Support set of complex numbers by assumptions
  • Loading branch information
rikardn committed Dec 1, 2021
2 parents 6f70858 + 194f4a1 commit e250bf7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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

0 comments on commit e250bf7

Please sign in to comment.