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

Handle Piecewise in TransformVisitor (for e.g. cse) #1953

Merged
merged 6 commits into from Mar 16, 2023

Conversation

bjodah
Copy link
Contributor

@bjodah bjodah commented Mar 14, 2023

This should enable cse to also pierce into Piecewise instances.
Fixed gh-1952.

Thank you @isuruf for the pointer!

@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)

if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
Copy link
Contributor Author

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?

auto new_branch = apply(branch);
// decltype(cond) new_cond =
// rcp_static_cast<some-kind-of-boolean-cse-symbol?>(apply(rcp_static_cast<const
// Basic>(cond)));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't figure out how to do subexpression elimination on the conditionals, so before merging I should probably just delete these comments...

@@ -1,19 +1,25 @@
#include "catch.hpp"
#include "symengine/dict.h"
#include "symengine/logic.h"
Copy link
Member

Choose a reason for hiding this comment

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

Duplicate

@@ -1,19 +1,25 @@
#include "catch.hpp"
#include "symengine/dict.h"
Copy link
Member

Choose a reason for hiding this comment

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

Use < instead of "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, my IDE seem to have "helped" me here... dropping those includes.

@isuruf isuruf merged commit ba4a049 into symengine:master Mar 16, 2023
@isuruf
Copy link
Member

isuruf commented Mar 16, 2023

TransformVisitor seems to be missing other classes as well. Can you open an issue?

Comment on lines +321 to +322
auto pw2 = piecewise({{pow(x, i2), Gt(add(x, y), i2)},
{sqrt(y), Gt(add(x, y), i3)},
Copy link
Member

Choose a reason for hiding this comment

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

Can you swap the two conditions? They don't make much sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that, fixed in 3570b30

Copy link
Member

@isuruf isuruf Mar 17, 2023

Choose a reason for hiding this comment

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

Looks like you only changed one part of the test

@bjodah bjodah deleted the cse-piecewise branch March 17, 2023 15:46
@bjodah
Copy link
Contributor Author

bjodah commented Mar 17, 2023

TransformVisitor seems to be missing other classes as well. Can you open an issue?

Sure, but it's not obvious to me what other classes you are referring to?

@isuruf
Copy link
Member

isuruf commented Mar 20, 2023

Sure, but it's not obvious to me what other classes you are referring to?

I didn't do a thorough check, but found classes like Contains are not implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cse does not seem to handle Piecewise well?
2 participants