[poincare] Constant: i->ComplexCartesian(0,1) only if the reduction

target is the user
This commit is contained in:
Émilie Feral
2018-12-17 14:54:48 +01:00
committed by Léa Saviot
parent 5463486d59
commit dae5c4d2d4
2 changed files with 4 additions and 4 deletions

View File

@@ -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<ConstantNode *>(Expression::node()); }

View File

@@ -46,15 +46,15 @@ Evaluation<T> 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<ConstantNode>(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;