[poincare] SerializationHelper::Map -> Expression::mapOnMatrixChild

This commit is contained in:
Léa Saviot
2019-07-01 11:56:28 +02:00
committed by Émilie Feral
parent 51ee5d8e21
commit de2d9f7c57
55 changed files with 169 additions and 197 deletions

View File

@@ -113,7 +113,6 @@ src += $(addprefix poincare/src/,\
sequence.cpp \
serialization_helper.cpp \
sign_function.cpp \
simplification_helper.cpp \
sine.cpp \
square_root.cpp \
store.cpp \

View File

@@ -53,7 +53,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("abs", 1, &UntypedBuilderOneChild<AbsoluteValue>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
private:
Expression setSign(ExpressionNode::Sign s, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit);
};

View File

@@ -45,7 +45,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("acos", 1, &UntypedBuilderOneChild<ArcCosine>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};

View File

@@ -44,7 +44,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("asin", 1, &UntypedBuilderOneChild<ArcSine>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -48,7 +48,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("atan", 1, &UntypedBuilderOneChild<ArcTangent>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -46,7 +46,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("ceil", 1, &UntypedBuilderOneChild<Ceiling>);
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -45,7 +45,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("arg", 1, &UntypedBuilderOneChild<ComplexArgument>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -52,12 +52,12 @@ public:
// Common operations (done in-place)
Expression squareNorm(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression norm(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression argument(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression argument(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
ComplexCartesian inverse(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
ComplexCartesian squareRoot(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
ComplexCartesian powerInteger(int n, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
ComplexCartesian powerInteger(int n, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
ComplexCartesian multiply(ComplexCartesian & other, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
ComplexCartesian power(ComplexCartesian & other, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
ComplexCartesian power(ComplexCartesian & other, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
private:
static constexpr int k_maxNumberOfNodesBeforeInterrupting = 50;
void factorAndArgumentOfFunction(Expression e, ExpressionNode::Type searchedType, Expression * factor, Expression * argument, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);

View File

@@ -45,7 +45,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("conj", 1, &UntypedBuilderOneChild<Conjugate>);;
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -50,7 +50,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("cos", 1, &UntypedBuilderOneChild<Cosine>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -213,6 +213,7 @@ public:
void simplifyAndApproximate(Expression * simplifiedExpression, Expression * approximateExpression, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, bool symbolicComputation = true);
Expression reduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit);
Expression mapOnMatrixChild(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
static Expression ExpressionWithoutSymbols(Expression expressionWithSymbols, Context & context);
Expression radianToDegree();
Expression degreeToRadian();

View File

@@ -54,7 +54,7 @@ public:
Factorial(const FactorialNode * n) : Expression(n) {}
static Factorial Builder(Expression child) { return TreeHandle::FixedArityBuilder<Factorial, FactorialNode>(&child, 1); }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
Expression shallowBeautify();
private:
constexpr static int k_maxOperandValue = 100;

View File

@@ -48,7 +48,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("floor", 1, &UntypedBuilderOneChild<Floor>);
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -48,7 +48,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("frac", 1, &UntypedBuilderOneChild<FracPart>);
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -18,7 +18,7 @@ private:
class HyperbolicTrigonometricFunction : public Expression {
public:
HyperbolicTrigonometricFunction(const HyperbolicTrigonometricFunctionNode * n) : Expression(n) {}
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -49,7 +49,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("im", 1, &UntypedBuilderOneChild<ImaginaryPart>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -47,7 +47,7 @@ public:
static Logarithm Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<Logarithm, LogarithmNode<2>>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("log", 2, &UntypedBuilderTwoChildren<Logarithm>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
Expression shallowBeautify();
private:
@@ -64,7 +64,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("log", 1, &UntypedBuilderOneChild<CommonLogarithm>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -48,7 +48,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("ln", 1, &UntypedBuilderOneChild<NaperianLogarithm>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -38,7 +38,7 @@ public:
static NthRoot Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<NthRoot, NthRootNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("root", 2, &UntypedBuilderTwoChildren<NthRoot>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -71,7 +71,7 @@ public:
Expression setSign(ExpressionNode::Sign s, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
int getPolynomialCoefficients(Context & context, const char * symbolName, Expression coefficients[]) const;
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
Expression shallowBeautify(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
private:
@@ -81,12 +81,12 @@ private:
// Simplification
Expression denominator(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const;
Expression simplifyPowerPower(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression simplifyPowerMultiplication(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression simplifyPowerPower(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
Expression simplifyPowerMultiplication(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
Expression simplifyRationalRationalPower(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
static Expression CreateSimplifiedIntegerRationalPower(Integer i, Rational r, bool isDenominator, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression removeSquareRootsFromDenominator(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit);
Expression removeSquareRootsFromDenominator(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, bool symbolicComputation);
bool parentIsALogarithmOfSameBase() const;
bool isNthRootOfUnity() const;
Expression equivalentExpressionUsingStandardExpression() const;

View File

@@ -49,7 +49,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("re", 1, &UntypedBuilderOneChild<RealPart>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -49,7 +49,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sign", 1, &UntypedBuilderOneChild<SignFunction>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -1,14 +0,0 @@
#ifndef POINCARE_SIMPLIFICATION_HELPER_H
#define POINCARE_SIMPLIFICATION_HELPER_H
#include <poincare/expression.h>
namespace Poincare {
namespace SimplificationHelper {
Expression Map(const Expression & e, Context & context, Preferences::AngleUnit angleUnit);
};
}
#endif

View File

@@ -52,7 +52,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sin", 1, &UntypedBuilderOneChild<Sine>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -42,7 +42,7 @@ public:
SquareRoot(const SquareRootNode * n) : Expression(n) {}
static SquareRoot Builder(Expression child) { return TreeHandle::FixedArityBuilder<SquareRoot, SquareRootNode>(&child, 1); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("", 1, &UntypedBuilderOneChild<SquareRoot>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -50,7 +50,7 @@ public:
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("tan", 1, &UntypedBuilderOneChild<Tangent>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation);
};
}

View File

@@ -1,7 +1,6 @@
#include <poincare/absolute_value.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/absolute_value_layout.h>
#include <poincare/complex_cartesian.h>
#include <poincare/multiplication.h>
@@ -28,7 +27,7 @@ int AbsoluteValueNode::serialize(char * buffer, int bufferSize, Preferences::Pri
}
Expression AbsoluteValueNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return AbsoluteValue(this).shallowReduce(context, complexFormat, angleUnit, target);
return AbsoluteValue(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression AbsoluteValue::setSign(ExpressionNode::Sign s, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) {
@@ -36,14 +35,14 @@ Expression AbsoluteValue::setSign(ExpressionNode::Sign s, Context * context, Pre
return *this;
}
Expression AbsoluteValue::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression AbsoluteValue::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
return e;
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
if (c.isReal(context)) {
float app = c.node()->approximate(float(), context, complexFormat, angleUnit).toScalar();

View File

@@ -2,7 +2,7 @@
#include <poincare/complex.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <cmath>
namespace Poincare {
@@ -20,7 +20,7 @@ int ArcCosineNode::serialize(char * buffer, int bufferSize, Preferences::PrintFl
}
Expression ArcCosineNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return ArcCosine(this).shallowReduce(context, complexFormat, angleUnit, target);
return ArcCosine(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
template<typename T>
@@ -49,7 +49,7 @@ Complex<T> ArcCosineNode::computeOnComplex(const std::complex<T> c, Preferences:
}
Expression ArcCosine::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression ArcCosine::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -57,7 +57,7 @@ Expression ArcCosine::shallowReduce(Context & context, Preferences::ComplexForma
}
}
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
return Trigonometry::shallowReduceInverseFunction(*this, context, complexFormat, angleUnit, target);
}

View File

@@ -2,7 +2,7 @@
#include <poincare/complex.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <cmath>
namespace Poincare {
@@ -20,7 +20,7 @@ int ArcSineNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloa
}
Expression ArcSineNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return ArcSine(this).shallowReduce(context, complexFormat, angleUnit, target);
return ArcSine(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
template<typename T>
@@ -49,7 +49,7 @@ Complex<T> ArcSineNode::computeOnComplex(const std::complex<T> c, Preferences::C
}
Expression ArcSine::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression ArcSine::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -57,7 +57,7 @@ Expression ArcSine::shallowReduce(Context & context, Preferences::ComplexFormat
}
}
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
return Trigonometry::shallowReduceInverseFunction(*this, context, complexFormat, angleUnit, target);
}

View File

@@ -2,7 +2,7 @@
#include <poincare/complex.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <cmath>
namespace Poincare {
@@ -45,11 +45,10 @@ Complex<T> ArcTangentNode::computeOnComplex(const std::complex<T> c, Preferences
}
Expression ArcTangentNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return ArcTangent(this).shallowReduce(context, complexFormat, angleUnit, target);
return ArcTangent(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression ArcTangent::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression ArcTangent::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -57,7 +56,7 @@ Expression ArcTangent::shallowReduce(Context & context, Preferences::ComplexForm
}
}
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
return Trigonometry::shallowReduceInverseFunction(*this, context, complexFormat, angleUnit, target);
}

View File

@@ -2,7 +2,7 @@
#include <poincare/constant.h>
#include <poincare/ceiling_layout.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/symbol.h>
#include <poincare/rational.h>
#include <cmath>
@@ -32,11 +32,11 @@ Complex<T> CeilingNode::computeOnComplex(const std::complex<T> c, Preferences::C
}
Expression CeilingNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return Ceiling(this).shallowReduce(context, angleUnit);
return Ceiling(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression Ceiling::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) {
Expression Ceiling::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -45,7 +45,7 @@ Expression Ceiling::shallowReduce(Context & context, Preferences::AngleUnit angl
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
if (c.type() == ExpressionNode::Type::Constant) {
Constant s = static_cast<Constant&>(c);

View File

@@ -2,7 +2,7 @@
#include <poincare/complex_cartesian.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/rational.h>
#include <poincare/constant.h>
extern "C" {
@@ -25,7 +25,7 @@ int ComplexArgumentNode::serialize(char * buffer, int bufferSize, Preferences::P
}
Expression ComplexArgumentNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return ComplexArgument(this).shallowReduce(context, complexFormat, angleUnit, target);
return ComplexArgument(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
template<typename T>
@@ -34,7 +34,7 @@ Complex<T> ComplexArgumentNode::computeOnComplex(const std::complex<T> c, Prefer
}
Expression ComplexArgument::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression ComplexArgument::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -43,7 +43,7 @@ Expression ComplexArgument::shallowReduce(Context & context, Preferences::Comple
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
bool real = c.isReal(context);
if (real) {
@@ -62,7 +62,7 @@ Expression ComplexArgument::shallowReduce(Context & context, Preferences::Comple
}
if (real || c.type() == ExpressionNode::Type::ComplexCartesian) {
ComplexCartesian complexChild = real ? ComplexCartesian::Builder(c, Rational::Builder(0)) : static_cast<ComplexCartesian &>(c);
Expression childArg = complexChild.argument(context, complexFormat, angleUnit, target);
Expression childArg = complexChild.argument(context, complexFormat, angleUnit, target, symbolicComputation);
replaceWithInPlace(childArg);
return childArg.shallowReduce(context, complexFormat, angleUnit, target);
}

View File

@@ -136,7 +136,7 @@ Expression ComplexCartesian::norm(Context & context, Preferences::ComplexFormat
return n;
}
Expression ComplexCartesian::argument(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression ComplexCartesian::argument(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
Expression a = real();
Expression b = imag();
if (!b.isRationalZero()) {
@@ -160,7 +160,7 @@ Expression ComplexCartesian::argument(Context & context, Preferences::ComplexFor
return sub;
} else {
// if b == 0, argument = (1-sign(a))*π/2
Expression signa = SignFunction::Builder(a).shallowReduce(context, complexFormat, angleUnit, target);
Expression signa = SignFunction::Builder(a).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
Subtraction sub = Subtraction::Builder(Rational::Builder(1), signa);
signa.shallowReduce(context, complexFormat, angleUnit, target);
Multiplication mul = Multiplication::Builder(Rational::Builder(1,2), Constant::Builder(UCodePointGreekSmallLetterPi), sub);
@@ -228,7 +228,7 @@ ComplexCartesian ComplexCartesian::squareRoot(Context & context, Preferences::Co
}
ComplexCartesian ComplexCartesian::powerInteger(int n, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
ComplexCartesian ComplexCartesian::powerInteger(int n, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
Expression a = real();
Expression b = imag();
assert(n > 0);
@@ -266,8 +266,8 @@ ComplexCartesian ComplexCartesian::powerInteger(int n, Context & context, Prefer
Power bpow = Power::Builder(bclone, Rational::Builder(i));
Multiplication m = Multiplication::Builder(binom, apow, bpow);
binom.shallowReduce(context);
apow.shallowReduce(context, complexFormat, angleUnit, target);
bpow.shallowReduce(context, complexFormat, angleUnit, target);
apow.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
bpow.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
if (i/2%2 == 1) {
m.addChildAtIndexInPlace(Rational::Builder(-1), 0, m.numberOfChildren());
}
@@ -318,10 +318,10 @@ Expression ComplexCartesian::powerHelper(Expression norm, Expression trigo, Cont
return m;
}
ComplexCartesian ComplexCartesian::power(ComplexCartesian & other, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
ComplexCartesian ComplexCartesian::power(ComplexCartesian & other, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
Expression r = clone().convert<ComplexCartesian>().norm(context, complexFormat, angleUnit, target);
Expression rclone = r.clone();
Expression th = argument(context, complexFormat, angleUnit, target);
Expression th = argument(context, complexFormat, angleUnit, target, symbolicComputation);
Expression thclone = th.clone();
Expression c = other.real();
Expression d = other.imag();

View File

@@ -4,7 +4,7 @@
#include <poincare/multiplication.h>
#include <poincare/rational.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/opposite.h>
#include <assert.h>
#include <cmath>
@@ -24,7 +24,7 @@ int ConjugateNode::serialize(char * buffer, int bufferSize, Preferences::PrintFl
}
Expression ConjugateNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return Conjugate(this).shallowReduce(context, complexFormat, angleUnit, target);
return Conjugate(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
template<typename T>
@@ -32,7 +32,7 @@ Complex<T> ConjugateNode::computeOnComplex(const std::complex<T> c, Preferences:
return Complex<T>::Builder(std::conj(c));
}
Expression Conjugate::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression Conjugate::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -41,7 +41,7 @@ Expression Conjugate::shallowReduce(Context & context, Preferences::ComplexForma
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
if (c.isReal(context)) {
replaceWithInPlace(c);

View File

@@ -2,7 +2,7 @@
#include <poincare/complex.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <cmath>
namespace Poincare {
@@ -31,10 +31,10 @@ int CosineNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloat
}
Expression CosineNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return Cosine(this).shallowReduce(context, complexFormat, angleUnit, target);
return Cosine(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression Cosine::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression Cosine::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -43,7 +43,7 @@ Expression Cosine::shallowReduce(Context & context, Preferences::ComplexFormat c
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
return Trigonometry::shallowReduceDirectFunction(*this, context, complexFormat, angleUnit, target);
}

View File

@@ -1,7 +1,7 @@
#include <poincare/derivative.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/symbol.h>
#include <poincare/undefined.h>
#include <cmath>

View File

@@ -477,7 +477,7 @@ void Expression::simplifyAndApproximate(Expression * simplifiedExpression, Expre
ecomplex.clone().convert<ComplexCartesian>().norm(context, complexFormat, angleUnit, ExpressionNode::ReductionTarget::User).shallowReduce(context, complexFormat, angleUnit, ExpressionNode::ReductionTarget::User, symbolicComputation) :
ecomplex.real();
Expression tb = complexFormat == Preferences::ComplexFormat::Polar ?
ecomplex.argument(context, complexFormat, angleUnit, ExpressionNode::ReductionTarget::User).shallowReduce(context, complexFormat, angleUnit, ExpressionNode::ReductionTarget::User, symbolicComputation) :
ecomplex.argument(context, complexFormat, angleUnit, ExpressionNode::ReductionTarget::User, symbolicComputation).shallowReduce(context, complexFormat, angleUnit, ExpressionNode::ReductionTarget::User, symbolicComputation) :
ecomplex.imag();
ra = ra.deepBeautify(context, complexFormat, angleUnit, ExpressionNode::ReductionTarget::User);
tb = tb.deepBeautify(context, complexFormat, angleUnit, ExpressionNode::ReductionTarget::User);
@@ -527,6 +527,21 @@ Expression Expression::ExpressionWithoutSymbols(Expression e, Context & context)
return e;
}
Expression Expression::mapOnMatrixChild(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
assert(numberOfChildren() == 1 && childAtIndex(0).type() == ExpressionNode::Type::Matrix);
Expression c = childAtIndex(0);
Matrix matrix = Matrix::Builder();
for (int i = 0; i < c.numberOfChildren(); i++) {
Expression f = clone(); // TODO Avoid cloning because 'this' might be very big TODO LEA: emptyBuilder?
f.replaceChildAtIndexInPlace(0, c.childAtIndex(i));
matrix.addChildAtIndexInPlace(f, i, i);
f.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
matrix.setDimensions(c.convert<Matrix>().numberOfRows(), c.convert<Matrix>().numberOfColumns());
replaceWithInPlace(matrix);
return matrix.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression Expression::radianToDegree() {
// e*180/Pi
return Multiplication::Builder(*this, Rational::Builder(180), Power::Builder(Constant::Builder(UCodePointGreekSmallLetterPi), Rational::Builder(-1)));

View File

@@ -5,7 +5,7 @@
#include <poincare/parenthesis.h>
#include <poincare/rational.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/symbol.h>
#include <poincare/undefined.h>
#include <cmath>
@@ -35,7 +35,7 @@ bool FactorialNode::childNeedsParenthesis(const TreeNode * child) const {
// Simplification
Expression FactorialNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return Factorial(this).shallowReduce(context, angleUnit);
return Factorial(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression FactorialNode::shallowBeautify(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target) {
@@ -77,7 +77,7 @@ int FactorialNode::serialize(char * buffer, int bufferSize, Preferences::PrintFl
}
Expression Factorial::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) {
Expression Factorial::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -86,7 +86,7 @@ Expression Factorial::shallowReduce(Context & context, Preferences::AngleUnit an
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
if (c.type() == ExpressionNode::Type::Rational) {
Rational r = c.convert<Rational>();

View File

@@ -3,7 +3,7 @@
#include <poincare/floor_layout.h>
#include <poincare/rational.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/symbol.h>
#include <ion.h>
#include <assert.h>
@@ -32,10 +32,10 @@ Complex<T> FloorNode::computeOnComplex(const std::complex<T> c, Preferences::Com
}
Expression FloorNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return Floor(this).shallowReduce(context, angleUnit);
return Floor(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression Floor::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) {
Expression Floor::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -44,7 +44,7 @@ Expression Floor::shallowReduce(Context & context, Preferences::AngleUnit angleU
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
if (c.type() == ExpressionNode::Type::Constant) {
Constant s = static_cast<Constant &>(c);

View File

@@ -1,7 +1,7 @@
#include <poincare/frac_part.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/rational.h>
#include <cmath>
@@ -20,7 +20,7 @@ int FracPartNode::serialize(char * buffer, int bufferSize, Preferences::PrintFlo
}
Expression FracPartNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return FracPart(this).shallowReduce(context, angleUnit);
return FracPart(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
template<typename T>
@@ -32,7 +32,7 @@ Complex<T> FracPartNode::computeOnComplex(const std::complex<T> c, Preferences::
}
Expression FracPart::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) {
Expression FracPart::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -41,7 +41,7 @@ Expression FracPart::shallowReduce(Context & context, Preferences::AngleUnit ang
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
if (c.type() != ExpressionNode::Type::Rational) {
return *this;

View File

@@ -3,7 +3,7 @@
#include <poincare/parenthesis.h>
#include <poincare/rational.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/symbol.h>
#include <poincare/undefined.h>
#include <cmath>

View File

@@ -1,13 +1,13 @@
#include <poincare/hyperbolic_trigonometric_function.h>
#include <poincare/simplification_helper.h>
namespace Poincare {
Expression HyperbolicTrigonometricFunctionNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return HyperbolicTrigonometricFunction(this).shallowReduce(context, angleUnit);
return HyperbolicTrigonometricFunction(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression HyperbolicTrigonometricFunction::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) {
Expression HyperbolicTrigonometricFunction::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -16,7 +16,7 @@ Expression HyperbolicTrigonometricFunction::shallowReduce(Context & context, Pre
}
Expression c = childAtIndex(0);
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
return *this;
}

View File

@@ -1,7 +1,7 @@
#include <poincare/imaginary_part.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/complex_cartesian.h>
#include <poincare/rational.h>
#include <cmath>
@@ -21,10 +21,10 @@ int ImaginaryPartNode::serialize(char * buffer, int bufferSize, Preferences::Pri
}
Expression ImaginaryPartNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return ImaginaryPart(this).shallowReduce(context, complexFormat, angleUnit, target);
return ImaginaryPart(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression ImaginaryPart::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression ImaginaryPart::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -33,7 +33,7 @@ Expression ImaginaryPart::shallowReduce(Context & context, Preferences::ComplexF
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
if (c.isReal(context)) {
Expression result = Rational::Builder(0);

View File

@@ -11,7 +11,7 @@
#include <poincare/rational.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/constant.h>
#include <poincare/undefined.h>
#include <cmath>
@@ -50,12 +50,12 @@ int LogarithmNode<T>::serialize(char * buffer, int bufferSize, Preferences::Prin
template<>
Expression LogarithmNode<1>::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
return CommonLogarithm(this).shallowReduce(context, complexFormat, angleUnit, target);
return CommonLogarithm(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
template<>
Expression LogarithmNode<2>::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
return Logarithm(this).shallowReduce(context, complexFormat, angleUnit, target);
return Logarithm(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
template<>
@@ -86,7 +86,7 @@ template<typename U> Evaluation<U> LogarithmNode<2>::templatedApproximate(Contex
return Complex<U>::Builder(result);
}
Expression CommonLogarithm::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target){
Expression CommonLogarithm::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -95,14 +95,14 @@ Expression CommonLogarithm::shallowReduce(Context & context, Preferences::Comple
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
Logarithm log = Logarithm::Builder(childAtIndex(0), Rational::Builder(10));
replaceWithInPlace(log);
return log.shallowReduce(context, complexFormat, angleUnit, target);
return log.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression Logarithm::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target){
Expression Logarithm::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -161,7 +161,7 @@ Expression Logarithm::shallowReduce(Context & context, Preferences::ComplexForma
Multiplication mult = Multiplication::Builder(y);
replaceWithInPlace(mult);
mult.addChildAtIndexInPlace(*this, 1, 1); // --> y*log(x,b)
shallowReduce(context, complexFormat, angleUnit, target); // reduce log (ie log(e, e) = 1)
shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation); // reduce log (ie log(e, e) = 1)
return mult.shallowReduce(context, complexFormat, angleUnit, target);
}
// log(x*y, b)->log(x,b)+log(y, b) if x,y>0
@@ -174,12 +174,12 @@ Expression Logarithm::shallowReduce(Context & context, Preferences::ComplexForma
static_cast<Multiplication &>(c).removeChildInPlace(factor, factor.numberOfChildren());
newLog.replaceChildAtIndexInPlace(0, factor);
a.addChildAtIndexInPlace(newLog, a.numberOfChildren(), a.numberOfChildren());
newLog.shallowReduce(context, complexFormat, angleUnit, target);
newLog.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
}
if (a.numberOfChildren() > 0) {
c.shallowReduce(context, complexFormat, angleUnit, target);
Expression reducedLastLog = shallowReduce(context, complexFormat, angleUnit, target);
Expression reducedLastLog = shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
reducedLastLog.replaceWithInPlace(a);
a.addChildAtIndexInPlace(reducedLastLog, a.numberOfChildren(), a.numberOfChildren());
return a.shallowReduce(context, complexFormat, angleUnit, target);
@@ -205,7 +205,7 @@ Expression Logarithm::shallowReduce(Context & context, Preferences::ComplexForma
// log(m) with m Matrix
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
return *this;

View File

@@ -99,7 +99,7 @@ bool NAryExpression::SortedIsMatrix(Expression e, Context & context) {
assert(IsNAry(e, context));
int childrenCount = e.numberOfChildren();
if (childrenCount > 0) {
return SortedIsMatrix(e.childAtIndex(childrenCount - 1), context);
return Expression::SortedIsMatrix(e.childAtIndex(childrenCount - 1), context);
}
return false;
}

View File

@@ -3,7 +3,7 @@
#include <poincare/logarithm.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
namespace Poincare {
@@ -19,11 +19,11 @@ int NaperianLogarithmNode::serialize(char * buffer, int bufferSize, Preferences:
}
Expression NaperianLogarithmNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return NaperianLogarithm(this).shallowReduce(context, complexFormat, angleUnit, target);
return NaperianLogarithm(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression NaperianLogarithm::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression NaperianLogarithm::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -32,11 +32,11 @@ Expression NaperianLogarithm::shallowReduce(Context & context, Preferences::Comp
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
Logarithm l = Logarithm::Builder(c, Constant::Builder(UCodePointScriptSmallE));
replaceWithInPlace(l);
return l.shallowReduce(context, complexFormat, angleUnit, target);
return l.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
}

View File

@@ -29,7 +29,7 @@ int NthRootNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloa
}
Expression NthRootNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return NthRoot(this).shallowReduce(context, complexFormat, angleUnit, target);
return NthRoot(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
template<typename T>
@@ -64,7 +64,7 @@ Evaluation<T> NthRootNode::templatedApproximate(Context& context, Preferences::C
}
Expression NthRoot::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression NthRoot::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -80,7 +80,7 @@ Expression NthRoot::shallowReduce(Context & context, Preferences::ComplexFormat
Power p = Power::Builder(childAtIndex(0), invIndex);
invIndex.shallowReduce(context, complexFormat, angleUnit, target);
replaceWithInPlace(p);
return p.shallowReduce(context, complexFormat, angleUnit, target);
return p.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
}

View File

@@ -7,7 +7,7 @@
#include <poincare/multiplication.h>
#include <poincare/rational.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
extern "C" {
#include <cmath>
#include <assert.h>

View File

@@ -165,7 +165,7 @@ int PowerNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatM
// Simplify
Expression PowerNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return Power(this).shallowReduce(context, complexFormat, angleUnit, target);
return Power(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression PowerNode::shallowBeautify(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
@@ -275,7 +275,7 @@ int Power::getPolynomialCoefficients(Context & context, const char * symbolName,
return -1;
}
Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
@@ -424,11 +424,11 @@ Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat co
} else if (r.integerDenominator().isOne() && r.unsignedIntegerNumerator().isLowerThan(ten)) {
if (r.sign() == ExpressionNode::Sign::Positive) {
// (x+iy)^n, n integer positive n < 10
result = complexBase.powerInteger(r.unsignedIntegerNumerator().extractedInt(), context, complexFormat, angleUnit, target);
result = complexBase.powerInteger(r.unsignedIntegerNumerator().extractedInt(), context, complexFormat, angleUnit, target, symbolicComputation);
} else {
// (x+iy)^(-n), n integer positive n < 10
assert(r.sign() == ExpressionNode::Sign::Negative);
result = complexBase.powerInteger(r.unsignedIntegerNumerator().extractedInt(), context, complexFormat, angleUnit, target).inverse(context, complexFormat, angleUnit, target);
result = complexBase.powerInteger(r.unsignedIntegerNumerator().extractedInt(), context, complexFormat, angleUnit, target, symbolicComputation).inverse(context, complexFormat, angleUnit, target);
}
}
if (!result.isUninitialized()) {
@@ -443,7 +443,7 @@ Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat co
(!letPowerAtRoot && base.type() == ExpressionNode::Type::ComplexCartesian && index.type() == ExpressionNode::Type::ComplexCartesian)) {
complexBase = base.type() == ExpressionNode::Type::ComplexCartesian ? static_cast<ComplexCartesian &>(base) : ComplexCartesian::Builder(base, Rational::Builder(0));
complexIndex = index.type() == ExpressionNode::Type::ComplexCartesian ? static_cast<ComplexCartesian &>(index) : ComplexCartesian::Builder(index, Rational::Builder(0));
result = complexBase.power(complexIndex, context, complexFormat, angleUnit, target);
result = complexBase.power(complexIndex, context, complexFormat, angleUnit, target, symbolicComputation);
replaceWithInPlace(result);
return result.shallowReduce();
}
@@ -451,7 +451,7 @@ Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat co
/* Step 3: We look for square root and sum of square roots (two terms maximum
* so far) at the denominator and move them to the numerator. */
if (target == ExpressionNode::ReductionTarget::User) {
Expression r = removeSquareRootsFromDenominator(context, complexFormat, angleUnit);
Expression r = removeSquareRootsFromDenominator(context, complexFormat, angleUnit, symbolicComputation);
if (!r.isUninitialized()) {
return r;
}
@@ -482,7 +482,7 @@ Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat co
// (-inf)^x --> (-1)^x*inf
Power p = Power::Builder(Rational::Builder(-1), childAtIndex(1));
result = Multiplication::Builder(p, result);
p.shallowReduce(context, complexFormat, angleUnit, target);
p.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
}
if (!result.isUninitialized()) {
@@ -525,7 +525,7 @@ Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat co
m1.addChildAtIndexInPlace(i, 0, 0);
i.shallowReduce(context, complexFormat, angleUnit, target);
m1.addChildAtIndexInPlace(*this, 1, 1);
shallowReduce(context, complexFormat, angleUnit, target);
shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
return m1.shallowReduce(context, complexFormat, angleUnit, target);
}
}
@@ -606,7 +606,7 @@ Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat co
return approximation;
}
}
return simplifyPowerPower(context, complexFormat, angleUnit, target);
return simplifyPowerPower(context, complexFormat, angleUnit, target, symbolicComputation);
}
}
// Step 11: (a*b*c*...)^r ?
@@ -614,7 +614,7 @@ Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat co
Multiplication m = childAtIndex(0).convert<Multiplication>();
// Case 1: (a*b*c*...)^n = a^n*b^n*c^n*... if n integer
if (childAtIndex(1).type() == ExpressionNode::Type::Rational && childAtIndex(1).convert<Rational>().integerDenominator().isOne()) {
return simplifyPowerMultiplication(context, complexFormat, angleUnit, target);
return simplifyPowerMultiplication(context, complexFormat, angleUnit, target, symbolicComputation);
}
// Case 2: (a*b*...)^r -> |a|^r*(sign(a)*b*...)^r if a not -1
for (int i = 0; i < m.numberOfChildren(); i++) {
@@ -644,8 +644,8 @@ Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat co
Multiplication root = Multiplication::Builder(p);
replaceWithInPlace(root);
root.addChildAtIndexInPlace(thisRef, 1, 1);
p.shallowReduce(context, complexFormat, angleUnit, target);
thisRef.shallowReduce(context, complexFormat, angleUnit, target);
p.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
thisRef.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
return root.shallowReduce(context, complexFormat, angleUnit, target);
}
}
@@ -747,7 +747,7 @@ Expression Power::shallowReduce(Context & context, Preferences::ComplexFormat co
}
if (nr.sign() == ExpressionNode::Sign::Negative) {
nr.replaceWithInPlace(Rational::Builder(-1));
return shallowReduce(context, complexFormat, angleUnit, target);
return shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
} else {
replaceWithInPlace(result);
return result;
@@ -858,24 +858,24 @@ Expression Power::denominator(Context & context, Preferences::ComplexFormat comp
return Expression();
}
Expression Power::simplifyPowerPower(Context& context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression Power::simplifyPowerPower(Context& context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
// this is p^e = (a^b)^e, we want a^(b*e)
Expression p = childAtIndex(0);
Multiplication m = Multiplication::Builder(p.childAtIndex(1), childAtIndex(1));
replaceChildAtIndexInPlace(0, p.childAtIndex(0));
replaceChildAtIndexInPlace(1, m);
m.shallowReduce(context, complexFormat, angleUnit, target);
return shallowReduce(context, complexFormat, angleUnit, target);
return shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression Power::simplifyPowerMultiplication(Context& context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression Power::simplifyPowerMultiplication(Context& context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
// this is m^r= (a*b*c*...)^r, we want a^r * b^r *c^r * ...
Expression m = childAtIndex(0);
Expression r = childAtIndex(1);
for (int index = 0; index < m.numberOfChildren(); index++) {
Power p = Power::Builder(m.childAtIndex(index).clone(), r.clone()); // We copy r and factor to avoid inheritance issues
m.replaceChildAtIndexInPlace(index, p);
p.shallowReduce(context, complexFormat, angleUnit, target);
p.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
replaceWithInPlace(m);
return m.shallowReduce(context, complexFormat, angleUnit, target);
@@ -974,7 +974,7 @@ Expression Power::CreateSimplifiedIntegerRationalPower(Integer i, Rational r, bo
return m.shallowReduce(context, complexFormat, angleUnit, target);
}
Expression Power::removeSquareRootsFromDenominator(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) {
Expression Power::removeSquareRootsFromDenominator(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, bool symbolicComputation) {
Expression result;
if (childAtIndex(0).type() == ExpressionNode::Type::Rational
&& childAtIndex(1).type() == ExpressionNode::Type::Rational
@@ -1001,7 +1001,7 @@ Expression Power::removeSquareRootsFromDenominator(Context & context, Preference
} else {
result = Multiplication::Builder(Rational::Builder(one, p), sqrt); // We use here the assertion that p != 0
}
sqrt.shallowReduce(context, complexFormat, angleUnit, ExpressionNode::ReductionTarget::User);
sqrt.shallowReduce(context, complexFormat, angleUnit, ExpressionNode::ReductionTarget::User, symbolicComputation);
}
} else if (childAtIndex(1).type() == ExpressionNode::Type::Rational
&& childAtIndex(1).convert<Rational>().isMinusOne()

View File

@@ -2,7 +2,7 @@
#include <poincare/complex_cartesian.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <assert.h>
#include <cmath>
@@ -21,11 +21,10 @@ int RealPartNode::serialize(char * buffer, int bufferSize, Preferences::PrintFlo
}
Expression RealPartNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return RealPart(this).shallowReduce(context, complexFormat, angleUnit, target);
return RealPart(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression RealPart::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression RealPart::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -34,7 +33,7 @@ Expression RealPart::shallowReduce(Context & context, Preferences::ComplexFormat
}
Expression c = childAtIndex(0);
if (c.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
if (c.isReal(context)) {
replaceWithInPlace(c);

View File

@@ -3,7 +3,7 @@
#include <poincare/rational.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <ion.h>
#include <assert.h>
#include <math.h>
@@ -35,7 +35,7 @@ int SignFunctionNode::serialize(char * buffer, int bufferSize, Preferences::Prin
}
Expression SignFunctionNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return SignFunction(this).shallowReduce(context, complexFormat, angleUnit, target);
return SignFunction(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
template<typename T>
@@ -53,7 +53,7 @@ Complex<T> SignFunctionNode::computeOnComplex(const std::complex<T> c, Preferenc
}
Expression SignFunction::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression SignFunction::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -62,7 +62,7 @@ Expression SignFunction::shallowReduce(Context & context, Preferences::ComplexFo
}
Expression child = childAtIndex(0);
if (child.type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
Rational resultSign = Rational::Builder(1);
ExpressionNode::Sign s = child.sign(&context);

View File

@@ -1,25 +0,0 @@
#include <poincare/simplification_helper.h>
#include <poincare/undefined.h>
namespace Poincare {
//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();
for (int i = 0; i < c->numberOfChildren(); i++) {
Expression f = e.replaceChildAtIndexInPlace(0, e.childAtIndex(0).childAtIndex(i));
matrix.addChildAtIndexInPlace(f, i, i);
f.shallowReduce(context, complexFormat, angleUnit);
}
replaceWithInPlace(matrix);
return matrix.shallowReduce(context, complexFormat, angleUnit);
#endif
return Undefined::Builder();
}
}

View File

@@ -2,7 +2,7 @@
#include <poincare/complex.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <cmath>
namespace Poincare {
@@ -31,11 +31,11 @@ int SineNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMo
}
Expression SineNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return Sine(this).shallowReduce(context, complexFormat, angleUnit, target);
return Sine(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression Sine::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression Sine::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -43,7 +43,7 @@ Expression Sine::shallowReduce(Context & context, Preferences::ComplexFormat com
}
}
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
return Trigonometry::shallowReduceDirectFunction(*this, context, complexFormat, angleUnit, target);
}

View File

@@ -4,7 +4,7 @@
#include <poincare/subtraction.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/nth_root_layout.h>
#include <poincare/division.h>
#include <poincare/sign_function.h>
@@ -39,11 +39,10 @@ Complex<T> SquareRootNode::computeOnComplex(const std::complex<T> c, Preferences
}
Expression SquareRootNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return SquareRoot(this).shallowReduce(context, complexFormat, angleUnit, target);
return SquareRoot(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression SquareRoot::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression SquareRoot::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -57,7 +56,7 @@ Expression SquareRoot::shallowReduce(Context & context, Preferences::ComplexForm
#endif
Power p = Power::Builder(childAtIndex(0), Rational::Builder(1, 2));
replaceWithInPlace(p);
return p.shallowReduce(context, complexFormat, angleUnit, target);
return p.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
}

View File

@@ -3,7 +3,7 @@
#include <poincare/division.h>
#include <poincare/layout_helper.h>
#include <poincare/serialization_helper.h>
#include <poincare/simplification_helper.h>
#include <poincare/sine.h>
#include <poincare/trigonometry.h>
#include <cmath>
@@ -34,11 +34,11 @@ Complex<T> TangentNode::computeOnComplex(const std::complex<T> c, Preferences::C
}
Expression TangentNode::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ReductionTarget target, bool symbolicComputation) {
return Tangent(this).shallowReduce(context, complexFormat, angleUnit, target);
return Tangent(this).shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression Tangent::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
Expression Tangent::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool symbolicComputation) {
{
Expression e = Expression::defaultShallowReduce();
if (e.isUndefined()) {
@@ -47,7 +47,7 @@ Expression Tangent::shallowReduce(Context & context, Preferences::ComplexFormat
}
if (childAtIndex(0).type() == ExpressionNode::Type::Matrix) {
return SimplificationHelper::Map(*this, context, angleUnit);
return mapOnMatrixChild(context, complexFormat, angleUnit, target, symbolicComputation);
}
Expression newExpression = Trigonometry::shallowReduceDirectFunction(*this, context, complexFormat, angleUnit, target);
@@ -55,8 +55,8 @@ Expression Tangent::shallowReduce(Context & context, Preferences::ComplexFormat
Sine s = Sine::Builder(newExpression.childAtIndex(0).clone());
Cosine c = Cosine::Builder(newExpression.childAtIndex(0));
Division d = Division::Builder(s, c);
s.shallowReduce(context, complexFormat, angleUnit, target);
c.shallowReduce(context, complexFormat, angleUnit, target);
s.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
c.shallowReduce(context, complexFormat, angleUnit, target, symbolicComputation);
newExpression.replaceWithInPlace(d);
return d.shallowReduce(context, complexFormat, angleUnit, target);
}