From c6cf0eb000e02cb3c985772b0756dffab0ff0ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 8 Jan 2019 10:21:52 +0100 Subject: [PATCH] [poincare] Discard BottomUpComputation of ReductionTarget because it is never used --- poincare/include/poincare/expression_node.h | 3 +-- poincare/src/logarithm.cpp | 2 +- poincare/src/multiplication.cpp | 2 +- poincare/src/power.cpp | 10 +++------- poincare/src/trigonometry.cpp | 2 +- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/poincare/include/poincare/expression_node.h b/poincare/include/poincare/expression_node.h index cc546edd4..227dad7ca 100644 --- a/poincare/include/poincare/expression_node.h +++ b/poincare/include/poincare/expression_node.h @@ -104,8 +104,7 @@ public: /* Properties */ enum class ReductionTarget { - BottomUpComputation = 0, - TopDownComputation = 1, + TopDownComputation = 0, User }; enum class Sign { diff --git a/poincare/src/logarithm.cpp b/poincare/src/logarithm.cpp index 3b00882d2..6b7e79818 100644 --- a/poincare/src/logarithm.cpp +++ b/poincare/src/logarithm.cpp @@ -134,7 +134,7 @@ Expression Logarithm::shallowReduce(Context & context, Preferences::ComplexForma * - the reduction is being BottomUp. In this case, we do not yet have any * information on the parent which could later be a power of b. */ - bool letLogAtRoot = target == ExpressionNode::ReductionTarget::BottomUpComputation || parentIsAPowerOfSameBase(); + bool letLogAtRoot = parentIsAPowerOfSameBase(); // log(x^y, b)->y*log(x, b) if x>0 if (!letLogAtRoot && c.type() == ExpressionNode::Type::Power && c.childAtIndex(0).sign(&context) == ExpressionNode::Sign::Positive) { Power p = static_cast(c); diff --git a/poincare/src/multiplication.cpp b/poincare/src/multiplication.cpp index 8314071ec..860a6e5d3 100644 --- a/poincare/src/multiplication.cpp +++ b/poincare/src/multiplication.cpp @@ -453,7 +453,7 @@ Expression Multiplication::privateShallowReduce(Context & context, Preferences:: * Note: This step must be done after Step 4, otherwise we wouldn't be able to * reduce expressions such as (x+y)^(-1)*(x+y)(a+b). */ Expression p = parent(); - if (target != ExpressionNode::ReductionTarget::BottomUpComputation && shouldExpand && (p.isUninitialized() || p.type() != ExpressionNode::Type::Multiplication)) { + if (shouldExpand && (p.isUninitialized() || p.type() != ExpressionNode::Type::Multiplication)) { for (int i = 0; i < numberOfChildren(); i++) { if (childAtIndex(i).type() == ExpressionNode::Type::Addition) { return distributeOnOperandAtIndex(i, context, complexFormat, angleUnit, target); diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index 803f4889d..95b52f1bd 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -394,14 +394,10 @@ Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat co } } - /* We do not apply some rules to a^b if: - * - the parent node is a logarithm of same base a. In this case there is a - * simplication of form ln(e^(3^(1/2))->3^(1/2). - * - the reduction is being BottomUpComputation. In this case, we do not yet have any - * information on the parent which could later be a logarithm of the same - * base. + /* We do not apply some rules to a^b if the parent node is a logarithm of same + * base a. In this case there is a simplication of form ln(e^(3^(1/2))->3^(1/2). */ - bool letPowerAtRoot = target == ExpressionNode::ReductionTarget::BottomUpComputation || parentIsALogarithmOfSameBase(); + bool letPowerAtRoot = parentIsALogarithmOfSameBase(); /* Step 2: we now bubble up ComplexCartesian, we handle different cases: * At least, one child is a ComplexCartesian and the other is either a diff --git a/poincare/src/trigonometry.cpp b/poincare/src/trigonometry.cpp index 7f9e3b0f9..786f79872 100644 --- a/poincare/src/trigonometry.cpp +++ b/poincare/src/trigonometry.cpp @@ -303,7 +303,7 @@ Expression Trigonometry::shallowReduceInverseFunction(Expression & e, Context& c * information on the parent which could later be a cosine, a sine or a tangent. */ Expression p = e.parent(); - bool letArcFunctionAtRoot = target == ExpressionNode::ReductionTarget::BottomUpComputation || (!p.isUninitialized() && isDirectTrigonometryFunction(p)); + bool letArcFunctionAtRoot = !p.isUninitialized() && isDirectTrigonometryFunction(p); /* Step 5. Handle opposite argument: arccos(-x) = Pi-arcos(x), * arcsin(-x) = -arcsin(x), arctan(-x)= -arctan(x) * */