-
Notifications
You must be signed in to change notification settings - Fork 273
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
Handle Piecewise in TransformVisitor (for e.g. cse) #1953
Changes from all commits
89cf167
fed0938
0d291d9
6c644fa
bef5874
83877e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,19 @@ | |
#include <symengine/add.h> | ||
#include <symengine/mul.h> | ||
#include <symengine/functions.h> | ||
#include <symengine/logic.h> | ||
|
||
using SymEngine::add; | ||
using SymEngine::Basic; | ||
using SymEngine::boolTrue; | ||
using SymEngine::cse; | ||
using SymEngine::div; | ||
using SymEngine::Gt; | ||
using SymEngine::integer; | ||
using SymEngine::mul; | ||
using SymEngine::neg; | ||
using SymEngine::one; | ||
using SymEngine::piecewise; | ||
using SymEngine::pow; | ||
using SymEngine::RCP; | ||
using SymEngine::sin; | ||
|
@@ -302,6 +306,30 @@ TEST_CASE("CSE: simple", "[cse]") | |
REQUIRE(unified_eq(substs, {{x0, add(x, y)}, {x1, add(x0, z)}})); | ||
REQUIRE(unified_eq(reduced, {x0, add(i2, x0), x1, add(i3, x1)})); | ||
} | ||
{ | ||
auto pw1 = piecewise( | ||
{{pow(add(x, y), i2), Gt(x, y)}, {sqrt(add(x, y)), boolTrue}}); | ||
|
||
vec_pair substs; | ||
vec_basic reduced; | ||
cse(substs, reduced, {pw1}); | ||
REQUIRE(unified_eq(substs, {{x0, add(x, y)}})); | ||
REQUIRE(unified_eq(reduced, {piecewise({{pow(x0, i2), Gt(x, y)}, | ||
{sqrt(x0), boolTrue}})})); | ||
} | ||
{ | ||
auto pw2 = piecewise({{pow(x, i2), Gt(add(x, y), i2)}, | ||
{sqrt(y), Gt(add(x, y), i3)}, | ||
Comment on lines
+321
to
+322
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you swap the two conditions? They don't make much sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry about that, fixed in 3570b30 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you only changed one part of the test |
||
{sqrt(x), boolTrue}}); | ||
|
||
vec_pair substs; | ||
vec_basic reduced; | ||
cse(substs, reduced, {pw2}); | ||
REQUIRE(unified_eq(substs, {{x0, add(x, y)}})); | ||
REQUIRE(unified_eq(reduced, {piecewise({{pow(x, i2), Gt(x0, i2)}, | ||
{sqrt(y), Gt(x0, i3)}, | ||
{sqrt(x), boolTrue}})})); | ||
} | ||
} | ||
|
||
TEST_CASE("CSE: regression test gh-1463", "[cse]") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows me to set the environment variable
FLINT_ROOT
for example. I think this is rather harmless to enable, no?