[poincare] Matrix exact reducing when mapping or undefined

This commit is contained in:
Léa Saviot
2019-06-28 17:55:26 +02:00
committed by Émilie Feral
parent d11b8a9614
commit 476d4f0046
7 changed files with 15 additions and 25 deletions

View File

@@ -1,8 +1,6 @@
#ifndef POINCARE_SIMPLIFICATION_HELPER_H
#define POINCARE_SIMPLIFICATION_HELPER_H
#if MATRIX_EXACT_REDUCING
#include <poincare/expression.h>
namespace Poincare {
@@ -14,5 +12,3 @@ namespace SimplificationHelper {
}
#endif
#endif

View File

@@ -41,14 +41,10 @@ Expression AbsoluteValue::shallowReduce(Context & context, Preferences::ComplexF
if (e.isUndefined()) {
return e;
}
#if MATRIX_EXACT_REDUCING
#if 0
if (c->type() == Type::Matrix) {
return SimplificationHelper::Map(this, context, angleUnit);
}
#endif
#endif
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
}
if (c.isReal(context)) {
float app = c.node()->approximate(float(), context, complexFormat, angleUnit).toScalar();
if (!std::isnan(app) &&

View File

@@ -56,11 +56,9 @@ Expression ArcCosine::shallowReduce(Context & context, Preferences::ComplexForma
return e;
}
}
#if MATRIX_EXACT_REDUCING
if (childAtIndex(0).type() == Type::Matrix) {
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
}
#endif
return Trigonometry::shallowReduceInverseFunction(*this, context, complexFormat, angleUnit, target);
}

View File

@@ -56,11 +56,9 @@ Expression ArcSine::shallowReduce(Context & context, Preferences::ComplexFormat
return e;
}
}
#if MATRIX_EXACT_REDUCING
if (childAtIndex(0).type() == Type::Matrix) {
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
}
#endif
return Trigonometry::shallowReduceInverseFunction(*this, context, complexFormat, angleUnit, target);
}

View File

@@ -56,11 +56,9 @@ Expression ArcTangent::shallowReduce(Context & context, Preferences::ComplexForm
return e;
}
}
#if MATRIX_EXACT_REDUCING
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
}
#endif
return Trigonometry::shallowReduceInverseFunction(*this, context, complexFormat, angleUnit, target);
}

View File

@@ -1,10 +1,13 @@
#include <poincare/simplification_helper.h>
#include <poincare/undefined.h>
#if MATRIX_EXACT_REDUCING
namespace Poincare {
// TODO Use clones
Expression SimplificationHelper::Map(const Expression & e, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) {
//TODO: , Preferences::ComplexFormat complexFormat?
Expression SimplificationHelper::Map(const Expression & e, Context & context, Preferences::AngleUnit angleUnit) {
//TODO LEA
#if 0
// TODO Use clones
assert(e->numberOfChildren() == 1 && e->childAtIndex(0)->type() == ExpressionNode::Type::Matrix);
Expression c = e.childAtIndex(0);
Matrix matrix = Matrix::Builder();
@@ -15,7 +18,8 @@ Expression SimplificationHelper::Map(const Expression & e, Context & context, Pr
}
replaceWithInPlace(matrix);
return matrix.shallowReduce(context, complexFormat, angleUnit);
#endif
return Undefined::Builder();
}
}
#endif

View File

@@ -45,12 +45,12 @@ Expression Tangent::shallowReduce(Context & context, Preferences::ComplexFormat
return e;
}
}
#if MATRIX_EXACT_REDUCING
Expression op = childAtIndex(0);
if (op.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
}
#endif
Expression newExpression = Trigonometry::shallowReduceDirectFunction(*this, context, complexFormat, angleUnit, target);
if (newExpression.type() == ExpressionNode::Type::Tangent) {
Sine s = Sine::Builder(newExpression.childAtIndex(0).clone());