mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare] CHange name PowerNode::tryComputeRealRootOfRationalPow -->
PowerNode::computeNotPrincipalRealRootOfRationalPow
This commit is contained in:
committed by
LeaNumworks
parent
da6306cb11
commit
d222d13156
@@ -34,7 +34,7 @@ public:
|
||||
int polynomialDegree(Context * context, const char * symbolName) const override;
|
||||
int getPolynomialCoefficients(Context * context, const char * symbolName, Expression coefficients[], ExpressionNode::SymbolicComputation symbolicComputation) const override;
|
||||
|
||||
template<typename T> static Complex<T> tryComputeRealRootOfRationalPow(const std::complex<T> c, T p, T q);
|
||||
template<typename T> static Complex<T> computeNotPrincipalRealRootOfRationalPow(const std::complex<T> c, T p, T q);
|
||||
template<typename T> static Complex<T> compute(const std::complex<T> c, const std::complex<T> d, Preferences::ComplexFormat complexFormat);
|
||||
|
||||
private:
|
||||
|
||||
@@ -48,7 +48,7 @@ Evaluation<T> NthRootNode::templatedApproximate(Context * context, Preferences::
|
||||
* correspond to the principale angle. */
|
||||
if (complexFormat == Preferences::ComplexFormat::Real && indexc.imag() == 0.0 && std::round(indexc.real()) == indexc.real()) {
|
||||
// root(x, q) with q integer and x real
|
||||
Complex<T> result = PowerNode::tryComputeRealRootOfRationalPow(basec, (T)1.0, indexc.real());
|
||||
Complex<T> result = PowerNode::computeNotPrincipalRealRootOfRationalPow(basec, (T)1.0, indexc.real());
|
||||
if (!result.isUndefined()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -128,12 +128,14 @@ bool PowerNode::childAtIndexNeedsUserParentheses(const Expression & child, int c
|
||||
// Private
|
||||
|
||||
template<typename T>
|
||||
Complex<T> PowerNode::tryComputeRealRootOfRationalPow(const std::complex<T> c, T p, T q) {
|
||||
Complex<T> PowerNode::computeNotPrincipalRealRootOfRationalPow(const std::complex<T> c, T p, T q) {
|
||||
// Assert p and q are in fact integers
|
||||
assert(std::round(p) == p);
|
||||
assert(std::round(q) == q);
|
||||
/* Try to find a real root of c^(p/q) with p, q integers. If none is found
|
||||
* easily, return undefined -> this does not mean there is no real root. */
|
||||
/* Try to find a real root of c^(p/q) with p, q integers. We ignore cases
|
||||
* where the principal root is real as these cases are handled generically
|
||||
* later (for instance 1232^(1/8) which has a real principal root is not
|
||||
* handled here). */
|
||||
if (c.imag() == 0 && std::pow((T)-1.0, q) < 0.0) {
|
||||
/* If c real and q odd integer (q odd if (-1)^q = -1), a real root does
|
||||
* exist (which is not necessarily the principal root)!
|
||||
@@ -321,7 +323,7 @@ template<typename T> Evaluation<T> PowerNode::templatedApproximate(Context * con
|
||||
if (std::isnan(p) || std::isnan(q)) {
|
||||
goto defaultApproximation;
|
||||
}
|
||||
Complex<T> result = tryComputeRealRootOfRationalPow(c, p, q);
|
||||
Complex<T> result = computeNotPrincipalRealRootOfRationalPow(c, p, q);
|
||||
if (!result.isUndefined()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user