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

xreplace #1320

Merged
merged 2 commits into from Aug 14, 2017
Merged

xreplace #1320

merged 2 commits into from Aug 14, 2017

Conversation

ranjithkumar007
Copy link
Contributor

cc @isuruf.

symengine/subs.h Outdated
: BaseVisitor<SubsVisitor, XReplaceVisitor>(xreplace_dict_)
{
}

void bvisit(const Derivative &x)
Copy link
Member

Choose a reason for hiding this comment

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

You should move this to xreplace. See sympy's implementation

symengine/subs.h Outdated
@@ -252,8 +363,8 @@ class SubsVisitor : public BaseVisitor<SubsVisitor>
break;
}
} else {
result_
= make_rcp<const Subs>(x.rcp_from_this(), subs_dict_);
result_ = make_rcp<const Subs>(x.rcp_from_this(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@isuruf, If Derivative is moved to xreplace, does returning an instance of Subs class on a call to xreplace make sense?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. SymPy does it as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah. Fine then

@ranjithkumar007
Copy link
Contributor Author

ping @isuruf

symengine/subs.h Outdated
protected:
RCP<const Basic> result_;
const map_basic_basic &subs_dict_;
const map_basic_basic &xreplace_dict_;
Copy link
Member

Choose a reason for hiding this comment

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

Let's leave subs_dict_ as it was.

symengine/subs.h Outdated
and is_a<Pow>(*((*xreplace_dict_.begin()).first))
and not is_a<Add>(
*down_cast<const Pow &>(*(*xreplace_dict_.begin()).first)
.get_exp())) {
Copy link
Member

Choose a reason for hiding this comment

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

What happens to (2**(x+y+z)).subs({2**(x+z): 1})?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

2**(x+y+z), stays as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same in SymPy.

symengine/subs.h Outdated
{
}

void bvisit(const Pow &x)
Copy link
Member

Choose a reason for hiding this comment

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

Only Pow? Isn't Add and Mul also needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on second thought, Add and Mul are not performing any such simplifications. So, It might be better to keep it as it is.

@ranjithkumar007
Copy link
Contributor Author

ranjithkumar007 commented Aug 12, 2017

ping @srajangarg

@ranjithkumar007
Copy link
Contributor Author

can you please have a look @Sumith1896 ?

@srajangarg srajangarg merged commit 67b75b0 into symengine:master Aug 14, 2017
@ranjithkumar007 ranjithkumar007 deleted the xreplace branch August 14, 2017 22:08
isuruf pushed a commit to isuruf/symengine that referenced this pull request Aug 4, 2018
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.

None yet

3 participants