Implemented Infty::pow and Infty::rpow functions#1160
Implemented Infty::pow and Infty::rpow functions#1160isuruf merged 4 commits intosymengine:masterfrom
Conversation
|
Thanks for implementing these. Please do not forget to also add some tests. |
|
ping @isuruf |
symengine/infinity.cpp
Outdated
| RCP<const Number> Infty::rpow(const Number &other) const | ||
| { | ||
| return zero; | ||
| if (is_a<Infty>(other)) { |
There was a problem hiding this comment.
rpow doesn't need this case, it is handled in pow
| REQUIRE(n1->__str__() == "zoo"); | ||
| n1 = b->rpow(*a); | ||
| REQUIRE(eq(*n1, *zero)); | ||
| n1 = b->rpow(*c); |
There was a problem hiding this comment.
Don't use rpow directly. Use c->rpow(*b)
de1ec99 to
3404ba5
Compare
symengine/infinity.cpp
Outdated
| { | ||
| return zero; | ||
| if (is_a<Infty>(other)) { | ||
| return other.pow(*this); |
There was a problem hiding this comment.
You should not need this at all, since rpow is not directly called.
symengine/infinity.cpp
Outdated
| throw SymEngineException("Indeterminate Expression: `0 ** +- " | ||
| "unsigned Infty` encountered"); | ||
| } else { | ||
| const RealDouble &s = static_cast<const RealDouble &>(other); |
There was a problem hiding this comment.
How do you know that other is a RealDouble?
There was a problem hiding this comment.
Actually I wanted to down-cast the value held by the object into a double and compare with 1. But using 'down_cast()' is raising an error. I'll look for other workarounds.
| RCP<const Infty> c = ComplexInf; | ||
|
|
||
| RCP<const Number> n1; | ||
| n1 = a->rpow(*integer(10)); |
symengine/infinity.cpp
Outdated
| throw SymEngineException("Indeterminate Expression: `1 ** +- " | ||
| "unsigned Infty` encountered"); | ||
| } else if (is_positive_infinity()) { | ||
| if (other.compare(*one) == -1) { |
There was a problem hiding this comment.
This comparison is not mathematical, but structural. check whether other - 1 is positive or zero or negative.
symengine/infinity.cpp
Outdated
| RCP<const Number> Infty::rpow(const Number &other) const | ||
| { | ||
| return zero; | ||
| if (is_a<Complex>(other)) { |
There was a problem hiding this comment.
Check for ComplexDouble and ComplexMPC here as well.
2db9fcd to
6778821
Compare
|
Ping @isuruf. |
Implemented Infty::pow and Infty::rpow functions
As always, please review and suggest changes.