From dae5c4d2d43375cdc17568c85251b5a09df1df96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 17 Dec 2018 14:54:48 +0100 Subject: [PATCH] [poincare] Constant: i->ComplexCartesian(0,1) only if the reduction target is the user --- poincare/include/poincare/constant.h | 2 +- poincare/src/constant.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/poincare/include/poincare/constant.h b/poincare/include/poincare/constant.h index ef3a385c7..acf8be0a4 100644 --- a/poincare/include/poincare/constant.h +++ b/poincare/include/poincare/constant.h @@ -58,7 +58,7 @@ public: bool isIComplex() const { return node()->isIComplex(); } // Simplification - Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit); + Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target); private: ConstantNode * node() const { return static_cast(Expression::node()); } diff --git a/poincare/src/constant.cpp b/poincare/src/constant.cpp index 3eb6f53be..12fc9fae4 100644 --- a/poincare/src/constant.cpp +++ b/poincare/src/constant.cpp @@ -46,15 +46,15 @@ Evaluation ConstantNode::templatedApproximate(Context& context, Preferences:: } Expression ConstantNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit, ReductionTarget target) { - return Constant(this).shallowReduce(context, angleUnit); + return Constant(this).shallowReduce(context, angleUnit, target); } Constant::Constant(char name) : SymbolAbstract(TreePool::sharedPool()->createTreeNode(SymbolAbstract::AlignedNodeSize(1, sizeof(ConstantNode)))) { node()->setName(&name, 1); } -Expression Constant::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { - if (isIComplex()) { +Expression Constant::shallowReduce(Context & context, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) { + if (target == ExpressionNode::ReductionTarget::User && isIComplex()) { ComplexCartesian c = ComplexCartesian::Builder(Rational(0), Rational(1)); replaceWithInPlace(c); return c;