mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] Engine-->Helper and break LayoutHelper into LayoutHelper and
SerializationHelper
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "integral_graph_controller.h"
|
||||
#include "../../shared/text_field_delegate.h"
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include "../app.h"
|
||||
|
||||
#include <assert.h>
|
||||
@@ -39,7 +39,7 @@ double IntegralGraphController::cursorNextStep(double x, int direction) {
|
||||
ExpressionLayout * IntegralGraphController::createFunctionLayout(const char * functionName) {
|
||||
char buffer[7] = "0(x)dx";
|
||||
buffer[0] = functionName[0];
|
||||
return LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
return LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "../../../poincare/src/layout/char_layout.h"
|
||||
#include "../../../poincare/src/layout/horizontal_layout.h"
|
||||
#include "../../../poincare/src/layout/vertical_offset_layout.h"
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <assert.h>
|
||||
|
||||
using namespace Poincare;
|
||||
@@ -93,18 +93,18 @@ void SequenceToolbox::buildExtraCellsLayouts(const char * sequenceName, int recu
|
||||
const char * indice = j == 0 ? "n" : "n+1";
|
||||
m_addedCellLayout[j] = new HorizontalLayout(
|
||||
new CharLayout(sequenceName[0], KDText::FontSize::Large),
|
||||
new VerticalOffsetLayout(LayoutEngine::createStringLayout(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
new VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
false);
|
||||
m_addedCellLayout[j+recurrenceDepth] = new HorizontalLayout(
|
||||
new CharLayout(otherSequenceName[0], KDText::FontSize::Large),
|
||||
new VerticalOffsetLayout(LayoutEngine::createStringLayout(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
new VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
false);
|
||||
}
|
||||
if (recurrenceDepth < 2) {
|
||||
const char * indice = recurrenceDepth == 0 ? "n" : (recurrenceDepth == 1 ? "n+1" : "n+2");
|
||||
m_addedCellLayout[2*recurrenceDepth] = new HorizontalLayout(
|
||||
new CharLayout(otherSequenceName[0], KDText::FontSize::Large),
|
||||
new VerticalOffsetLayout(LayoutEngine::createStringLayout(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
new VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "list_controller.h"
|
||||
#include "../app.h"
|
||||
#include <assert.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include "../../../poincare/src/layout/char_layout.h"
|
||||
#include "../../../poincare/src/layout/horizontal_layout.h"
|
||||
#include "../../../poincare/src/layout/vertical_offset_layout.h"
|
||||
@@ -131,7 +131,7 @@ void TypeParameterController::willDisplayCellAtLocation(HighlightCell * cell, in
|
||||
}
|
||||
m_expressionLayouts[j] = new HorizontalLayout(
|
||||
new CharLayout(nextName[0], size),
|
||||
new VerticalOffsetLayout(LayoutEngine::createStringLayout(subscripts[j], strlen(subscripts[j]), size), VerticalOffsetLayout::Type::Subscript, false),
|
||||
new VerticalOffsetLayout(LayoutHelper::String(subscripts[j], strlen(subscripts[j]), size), VerticalOffsetLayout::Type::Subscript, false),
|
||||
false);
|
||||
ExpressionTableCellWithPointer * myCell = (ExpressionTableCellWithPointer *)cell;
|
||||
myCell->setExpressionLayout(m_expressionLayouts[j]);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "sequence.h"
|
||||
#include "sequence_store.h"
|
||||
#include "cache_context.h"
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include "../../poincare/src/layout/char_layout.h"
|
||||
#include "../../poincare/src/layout/horizontal_layout.h"
|
||||
#include "../../poincare/src/layout/vertical_offset_layout.h"
|
||||
@@ -233,19 +233,19 @@ Poincare::ExpressionLayout * Sequence::definitionName() {
|
||||
if (m_type == Type::Explicit) {
|
||||
m_definitionName = new HorizontalLayout(
|
||||
new CharLayout(name()[0], KDText::FontSize::Large),
|
||||
new VerticalOffsetLayout(LayoutEngine::createStringLayout("n", 1, KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
new VerticalOffsetLayout(LayoutHelper::String("n", 1, KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
false);
|
||||
}
|
||||
if (m_type == Type::SingleRecurrence) {
|
||||
m_definitionName = new HorizontalLayout(
|
||||
new CharLayout(name()[0], KDText::FontSize::Large),
|
||||
new VerticalOffsetLayout(LayoutEngine::createStringLayout("n+1", 3, KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
new VerticalOffsetLayout(LayoutHelper::String("n+1", 3, KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
false);
|
||||
}
|
||||
if (m_type == Type::DoubleRecurrence) {
|
||||
m_definitionName = new HorizontalLayout(
|
||||
new CharLayout(name()[0], KDText::FontSize::Large),
|
||||
new VerticalOffsetLayout(LayoutEngine::createStringLayout("n+2", 3, KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
new VerticalOffsetLayout(LayoutHelper::String("n+2", 3, KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false),
|
||||
false);
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ Poincare::ExpressionLayout * Sequence::firstInitialConditionName() {
|
||||
&& (m_type == Type::SingleRecurrence
|
||||
|| m_type == Type::DoubleRecurrence))
|
||||
{
|
||||
ExpressionLayout * indexLayout = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Large);
|
||||
ExpressionLayout * indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large);
|
||||
m_firstInitialConditionName = new HorizontalLayout(
|
||||
new CharLayout(name()[0], KDText::FontSize::Large),
|
||||
new VerticalOffsetLayout(indexLayout, VerticalOffsetLayout::Type::Subscript, false),
|
||||
@@ -273,7 +273,7 @@ Poincare::ExpressionLayout * Sequence::secondInitialConditionName() {
|
||||
Integer(m_initialRank+1).writeTextInBuffer(buffer, k_initialRankNumberOfDigits+1);
|
||||
if (m_secondInitialConditionName == nullptr) {
|
||||
if (m_type == Type::DoubleRecurrence) {
|
||||
ExpressionLayout * indexLayout = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Large);
|
||||
ExpressionLayout * indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large);
|
||||
m_secondInitialConditionName = new HorizontalLayout(
|
||||
new CharLayout(name()[0], KDText::FontSize::Large),
|
||||
new VerticalOffsetLayout(indexLayout, VerticalOffsetLayout::Type::Subscript, false),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "helpers.h"
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <ion/charset.h>
|
||||
#include "../../poincare/src/layout/horizontal_layout.h"
|
||||
#include "../../poincare/src/layout/vertical_offset_layout.h"
|
||||
@@ -11,15 +11,15 @@ namespace Helpers {
|
||||
|
||||
ExpressionLayout * CartesianComplexFormat(KDText::FontSize fontSize) {
|
||||
const char text[] = {'a','+', Ion::Charset::IComplex, 'b', ' '};
|
||||
return LayoutEngine::createStringLayout(text, sizeof(text), fontSize);
|
||||
return LayoutHelper::String(text, sizeof(text), fontSize);
|
||||
}
|
||||
|
||||
ExpressionLayout * PolarComplexFormat(KDText::FontSize fontSize) {
|
||||
const char base[] = {'r', Ion::Charset::Exponential};
|
||||
const char superscript[] = {Ion::Charset::IComplex, Ion::Charset::SmallTheta, ' '};
|
||||
return new HorizontalLayout(
|
||||
LayoutEngine::createStringLayout(base, sizeof(base), fontSize),
|
||||
new VerticalOffsetLayout(LayoutEngine::createStringLayout(superscript, sizeof(superscript), fontSize), VerticalOffsetLayout::Type::Superscript, false),
|
||||
LayoutHelper::String(base, sizeof(base), fontSize),
|
||||
new VerticalOffsetLayout(LayoutHelper::String(superscript, sizeof(superscript), fontSize), VerticalOffsetLayout::Type::Superscript, false),
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "sum_graph_controller.h"
|
||||
#include "../apps_container.h"
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include "poincare_helpers.h"
|
||||
|
||||
#include <assert.h>
|
||||
@@ -233,32 +233,32 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl
|
||||
assert(step == Step::Result || functionLayout == nullptr);
|
||||
const char sigma[] = {' ', m_sumSymbol};
|
||||
if (step == Step::FirstParameter) {
|
||||
m_sumLayoutRef = LayoutEngine::createStringLayout(sigma, sizeof(sigma));
|
||||
m_sumLayoutRef = LayoutHelper::String(sigma, sizeof(sigma));
|
||||
} else if (step == Step::SecondParameter) {
|
||||
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits)];
|
||||
PrintFloat::convertFloatToText<double>(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
|
||||
m_sumLayoutRef = LayoutEngine::createStringLayout(sigma, sizeof(sigma));/* TODO new CondensedSumLayout(
|
||||
LayoutEngine::createStringLayout(sigma, sizeof(sigma)),
|
||||
LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small),
|
||||
m_sumLayoutRef = LayoutHelper::String(sigma, sizeof(sigma));/* TODO new CondensedSumLayout(
|
||||
LayoutHelper::String(sigma, sizeof(sigma)),
|
||||
LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small),
|
||||
new EmptyLayout(EmptyLayout::Color::Yellow, false, KDText::FontSize::Small, false),
|
||||
false); */
|
||||
} else {
|
||||
m_sumLayoutRef = LayoutEngine::createStringLayout(sigma, sizeof(sigma));
|
||||
m_sumLayoutRef = LayoutHelper::String(sigma, sizeof(sigma));
|
||||
/* TODO
|
||||
char buffer[2+PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
|
||||
PrintFloat::convertFloatToText<double>(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
|
||||
ExpressionLayout * start = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
ExpressionLayout * start = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
PrintFloat::convertFloatToText<double>(end, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
|
||||
ExpressionLayout * end = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
ExpressionLayout * end = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
m_sumLayoutRef = new CondensedSumLayout(
|
||||
LayoutEngine::createStringLayout(sigma, sizeof(sigma)),
|
||||
LayoutHelper::String(sigma, sizeof(sigma)),
|
||||
start,
|
||||
end,
|
||||
false);
|
||||
ExpressionLayout * childrenLayouts[3];
|
||||
strlcpy(buffer, "= ", 3);
|
||||
PoincareHelpers::ConvertFloatToText<double>(result, buffer+2, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
childrenLayouts[2] = LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
childrenLayouts[2] = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small);
|
||||
childrenLayouts[1] = functionLayout;
|
||||
childrenLayouts[0] = m_sumLayoutRef;
|
||||
m_sumLayoutRef = new HorizontalLayout(childrenLayouts, 3, false);*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "list_controller.h"
|
||||
#include "../constant.h"
|
||||
#include <assert.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include "../i18n.h"
|
||||
|
||||
using namespace Poincare;
|
||||
|
||||
@@ -66,9 +66,9 @@ SolutionsController::SolutionsController(Responder * parentResponder, EquationSt
|
||||
m_delta2Layout(nullptr),
|
||||
m_contentView(this)
|
||||
{
|
||||
m_delta2Layout = new HorizontalLayout(new VerticalOffsetLayout(new CharLayout('2', KDText::FontSize::Small), VerticalOffsetLayout::Type::Superscript, false), LayoutEngine::createStringLayout("-4ac", 4, KDText::FontSize::Small), false);
|
||||
m_delta2Layout = new HorizontalLayout(new VerticalOffsetLayout(new CharLayout('2', KDText::FontSize::Small), VerticalOffsetLayout::Type::Superscript, false), LayoutHelper::String("-4ac", 4, KDText::FontSize::Small), false);
|
||||
char deltaB[] = {Ion::Charset::CapitalDelta, '=', 'b'};
|
||||
static_cast<HorizontalLayout *>(m_delta2Layout)->addOrMergeChildAtIndex(LayoutEngine::createStringLayout(deltaB, 3, KDText::FontSize::Small), 0, false);
|
||||
static_cast<HorizontalLayout *>(m_delta2Layout)->addOrMergeChildAtIndex(LayoutHelper::String(deltaB, 3, KDText::FontSize::Small), 0, false);
|
||||
for (int i = 0; i < EquationStore::k_maxNumberOfExactSolutions; i++) {
|
||||
m_exactValueCells[i].setParentResponder(m_contentView.selectableTableView());
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ objs += $(addprefix poincare/src/,\
|
||||
objs += $(addprefix poincare/src/,\
|
||||
absolute_value.o\
|
||||
addition.o\
|
||||
approximation_engine.o\
|
||||
approximation_helper.o\
|
||||
arc_cosine.o\
|
||||
arc_sine.o\
|
||||
arc_tangent.o\
|
||||
@@ -79,7 +79,7 @@ objs += $(addprefix poincare/src/,\
|
||||
imaginary_part.o\
|
||||
integer.o\
|
||||
integral.o\
|
||||
layout_engine.o\
|
||||
layout_helper.o\
|
||||
list_data.o\
|
||||
least_common_multiple.o\
|
||||
logarithm.o\
|
||||
@@ -106,7 +106,7 @@ objs += $(addprefix poincare/src/,\
|
||||
real_part.o\
|
||||
round.o\
|
||||
sequence.o\
|
||||
simplification_engine.o\
|
||||
simplification_helper.o\
|
||||
sine.o\
|
||||
square_root.o\
|
||||
static_hierarchy.o\
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#define POINCARE_ABSOLUTE_VALUE_H
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -17,17 +17,17 @@ private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "abs");
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "abs");
|
||||
}
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit, computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit, computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class AbsoluteValueLayoutNode : public BracketPairLayoutNode {
|
||||
public:
|
||||
using BracketPairLayoutNode::BracketPairLayoutNode;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixSerializableRefTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "abs");
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "abs");
|
||||
}
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(AbsoluteValueLayoutNode); }
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include <poincare/dynamic_hierarchy.h>
|
||||
#include <poincare/rational.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -23,19 +23,19 @@ public:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> compute(const std::complex<T> c, const std::complex<T> d);
|
||||
template<typename T> static MatrixComplex<T> computeOnMatrices(const MatrixComplex<T> m, const MatrixComplex<T> n) {
|
||||
return ApproximationEngine::elementWiseOnComplexMatrices(m, n, compute<T>);
|
||||
return ApproximationHelper::ElementWiseOnComplexMatrices(m, n, compute<T>);
|
||||
}
|
||||
template<typename T> static MatrixComplex<T> computeOnComplexAndMatrix(const std::complex<T> c, const MatrixComplex<T> m) {
|
||||
return ApproximationEngine::elementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
return ApproximationHelper::ElementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
}
|
||||
private:
|
||||
/* Layout */
|
||||
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createInfixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Infix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
static const char * name() { return "+"; }
|
||||
|
||||
@@ -48,13 +48,13 @@ private:
|
||||
static bool TermsHaveIdenticalNonRationalFactors(const Expression * e1, const Expression * e2);
|
||||
/* Evaluation */
|
||||
template<typename T> static MatrixComplex<T> computeOnMatrixAndComplex(const MatrixComplex<T> m, const std::complex<T> c) {
|
||||
return ApproximationEngine::elementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
return ApproximationHelper::ElementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
}
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::mapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
|
||||
return ApproximationHelper::MapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::mapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
|
||||
return ApproximationHelper::MapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef POINCARE_APPROXIMATION_ENGINE_H
|
||||
#define POINCARE_APPROXIMATION_ENGINE_H
|
||||
#ifndef POINCARE_APPROXIMATION_HELPER_H
|
||||
#define POINCARE_APPROXIMATION_HELPER_H
|
||||
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/matrix_complex.h>
|
||||
@@ -8,22 +8,20 @@
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class ApproximationEngine {
|
||||
public:
|
||||
template <typename T> static std::complex<T> truncateRealOrImaginaryPartAccordingToArgument(std::complex<T> c);
|
||||
namespace ApproximationHelper {
|
||||
template <typename T> static std::complex<T> TruncateRealOrImaginaryPartAccordingToArgument(std::complex<T> c);
|
||||
|
||||
template <typename T> using ComplexCompute = Complex<T>(*)(const std::complex<T>, Preferences::AngleUnit angleUnit);
|
||||
template<typename T> static Evaluation<T> map(const ExpressionNode * expression, Context& context, Preferences::AngleUnit angleUnit, ComplexCompute<T> compute);
|
||||
template<typename T> static Evaluation<T> Map(const ExpressionNode * expression, Context& context, Preferences::AngleUnit angleUnit, ComplexCompute<T> compute);
|
||||
|
||||
template <typename T> using ComplexAndComplexReduction = Complex<T>(*)(const std::complex<T>, const std::complex<T>);
|
||||
template <typename T> using ComplexAndMatrixReduction = MatrixComplex<T>(*)(const std::complex<T> c, const MatrixComplex<T> m);
|
||||
template <typename T> using MatrixAndComplexReduction = MatrixComplex<T>(*)(const MatrixComplex<T> m, const std::complex<T> c);
|
||||
template <typename T> using MatrixAndMatrixReduction = MatrixComplex<T>(*)(const MatrixComplex<T> m, const MatrixComplex<T> n);
|
||||
template<typename T> static Evaluation<T> mapReduce(const ExpressionNode * expression, Context& context, Preferences::AngleUnit angleUnit, ComplexAndComplexReduction<T> computeOnComplexes, ComplexAndMatrixReduction<T> computeOnComplexAndMatrix, MatrixAndComplexReduction<T> computeOnMatrixAndComplex, MatrixAndMatrixReduction<T> computeOnMatrices);
|
||||
|
||||
template<typename T> static MatrixComplex<T> elementWiseOnMatrixComplexAndComplex(const MatrixComplex<T> n, std::complex<T> c, ComplexAndComplexReduction<T> computeOnComplexes);
|
||||
template<typename T> static MatrixComplex<T> elementWiseOnComplexMatrices(const MatrixComplex<T> m, const MatrixComplex<T> n, ComplexAndComplexReduction<T> computeOnComplexes);
|
||||
template<typename T> static Evaluation<T> MapReduce(const ExpressionNode * expression, Context& context, Preferences::AngleUnit angleUnit, ComplexAndComplexReduction<T> computeOnComplexes, ComplexAndMatrixReduction<T> computeOnComplexAndMatrix, MatrixAndComplexReduction<T> computeOnMatrixAndComplex, MatrixAndMatrixReduction<T> computeOnMatrices);
|
||||
|
||||
template<typename T> static MatrixComplex<T> ElementWiseOnMatrixComplexAndComplex(const MatrixComplex<T> n, std::complex<T> c, ComplexAndComplexReduction<T> computeOnComplexes);
|
||||
template<typename T> static MatrixComplex<T> ElementWiseOnComplexMatrices(const MatrixComplex<T> m, const MatrixComplex<T> n, ComplexAndComplexReduction<T> computeOnComplexes);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_ARC_COSINE_H
|
||||
#define POINCARE_ARC_COSINE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -15,10 +15,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const {
|
||||
return "acos";
|
||||
@@ -28,10 +28,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_ARC_SINE_H
|
||||
#define POINCARE_ARC_SINE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -15,10 +15,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "asin"; }
|
||||
/* Simplification */
|
||||
@@ -26,10 +26,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit, computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit, computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_ARC_TANGENT_H
|
||||
#define POINCARE_ARC_TANGENT_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -15,10 +15,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "atan"; }
|
||||
/* Simplification */
|
||||
@@ -26,10 +26,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_BINOMIAL_COEFFICIENT_H
|
||||
|
||||
#include <poincare/evaluation.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -17,7 +17,7 @@ private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "binomial");
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "binomial");
|
||||
}
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_CEILING_H
|
||||
#define POINCARE_CEILING_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,7 +15,7 @@ private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "ceil"; }
|
||||
/* Simplification */
|
||||
@@ -23,10 +23,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit, computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit, computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_CEILING_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/bracket_pair_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -10,7 +10,7 @@ class CeilingLayoutNode : public BracketPairLayoutNode {
|
||||
public:
|
||||
using BracketPairLayoutNode::BracketPairLayoutNode;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixSerializableRefTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "ceil");
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "ceil");
|
||||
}
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(CeilingLayoutNode); }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_COMPLEX_ARGUMENT_H
|
||||
#define POINCARE_COMPLEX_ARGUMENT_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "arg"; }
|
||||
/* Simplification */
|
||||
@@ -25,10 +25,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <poincare/layout_cursor.h>
|
||||
#include <poincare/layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/layout_reference.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override { assert(false); }
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override { assert(false); }
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixSerializableRefTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "sum");
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "sum");
|
||||
}
|
||||
|
||||
LayoutNode * layoutToPointWhenInserting() override {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_CONFIDENCE_INTERVAL_H
|
||||
#define POINCARE_CONFIDENCE_INTERVAL_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
virtual const char * name() const { return "confidence"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#define POINCARE_CONJUGATE_H
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,17 +15,17 @@ private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "conj");
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "conj");
|
||||
}
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_COSINE_H
|
||||
#define POINCARE_COSINE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
#include <poincare/expression.h>
|
||||
|
||||
@@ -19,20 +19,20 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "cos"; }
|
||||
/* Simplication */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
/* Evaluation */
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_DERIVATIVE_H
|
||||
#define POINCARE_DERIVATIVE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/variable_context.h>
|
||||
|
||||
@@ -15,10 +15,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "diff"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_DETERMINANT_H
|
||||
#define POINCARE_DETERMINANT_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -13,10 +13,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "det"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#define POINCARE_DIVISION_H
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -21,21 +21,21 @@ private:
|
||||
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "/");
|
||||
return LayoutHelper::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "/");
|
||||
}
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
/* Evaluation */
|
||||
template<typename T> static MatrixComplex<T> computeOnMatrixAndComplex(const MatrixComplex<T> m, const std::complex<T> c) {
|
||||
return ApproximationEngine::elementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
return ApproximationHelper::ElementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
}
|
||||
template<typename T> static MatrixComplex<T> computeOnComplexAndMatrix(const std::complex<T> c, const MatrixComplex<T> n);
|
||||
template<typename T> static MatrixComplex<T> computeOnMatrices(const MatrixComplex<T> m, const MatrixComplex<T> n);
|
||||
virtual Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::mapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
|
||||
return ApproximationHelper::MapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
|
||||
}
|
||||
virtual Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::mapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
|
||||
return ApproximationHelper::MapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_DIVISION_QUOTIENT_H
|
||||
#define POINCARE_DIVISION_QUOTIENT_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/evaluation.h>
|
||||
#include <poincare/char_layout_node.h>
|
||||
@@ -15,10 +15,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "quo"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_DIVISION_REMAINDER_H
|
||||
#define POINCARE_DIVISION_REMAINDER_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/evaluation.h>
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "rem"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -20,7 +20,7 @@ private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "=");
|
||||
return LayoutHelper::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "=");
|
||||
}
|
||||
/* Evalutation */
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
}
|
||||
bool isEqualToItsApproximationLayout(Expression approximation, int bufferSize, Preferences::AngleUnit angleUnit, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits, Context & context);
|
||||
|
||||
/* Layout Engine */
|
||||
/* Layout Helper */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return this->node()->createLayout(floatDisplayMode, numberOfSignificantDigits); }
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const { return this->node()->writeTextInBuffer(buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits); }
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
static Expression ParseAndSimplify(const char * text, Context & context, Preferences::AngleUnit angleUnit);
|
||||
void simplify(Context & context, Preferences::AngleUnit angleUnit);
|
||||
|
||||
/* Approximation Engine */
|
||||
/* Approximation Helper */
|
||||
template<typename U> Expression approximate(Context& context, Preferences::AngleUnit angleUnit, Preferences::Preferences::ComplexFormat complexFormat) const;
|
||||
template<typename U> U approximateToScalar(Context& context, Preferences::AngleUnit angleUnit) const;
|
||||
template<typename U> static U approximateToScalar(const char * text, Context& context, Preferences::AngleUnit angleUnit);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Poincare {
|
||||
* Expression. */
|
||||
|
||||
class ExpressionNode : public SerializableNode {
|
||||
friend class ApproximationEngine;
|
||||
friend class ApproximationHelper;
|
||||
friend class SymbolNode;
|
||||
friend class NAryExpressionNode;
|
||||
public:
|
||||
@@ -138,10 +138,10 @@ public:
|
||||
//TODO: What should be the implementation for complex?
|
||||
virtual int simplificationOrderSameType(const ExpressionNode * e, bool canBeInterrupted) const { return 0; }
|
||||
|
||||
/* Layout Engine */
|
||||
/* Layout Helper */
|
||||
virtual LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const = 0;
|
||||
|
||||
/* Evaluation Engine */
|
||||
/* Evaluation Helper */
|
||||
typedef float SinglePrecision;
|
||||
typedef double DoublePrecision;
|
||||
constexpr static int k_maxNumberOfSteps = 10000;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_FACTOR_H
|
||||
#define POINCARE_FACTOR_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/multiplication.h>
|
||||
#include <poincare/rational.h>
|
||||
@@ -16,10 +16,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "factor"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_FACTORIAL_H
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -22,10 +22,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_FLOOR_H
|
||||
#define POINCARE_FLOOR_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,7 +15,7 @@ private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "floor"; }
|
||||
/* Simplification */
|
||||
@@ -23,10 +23,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit, computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit, computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_FLOOR_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/bracket_pair_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -10,7 +10,7 @@ class FloorLayoutNode : public BracketPairLayoutNode {
|
||||
public:
|
||||
using BracketPairLayoutNode::BracketPairLayoutNode;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixSerializableRefTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "floor");
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "floor");
|
||||
}
|
||||
|
||||
// TreeNode
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_FRAC_PART_H
|
||||
#define POINCARE_FRAC_PART_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "frac"; }
|
||||
/* Simplification */
|
||||
@@ -25,10 +25,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit, computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit, computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_GREAT_COMMON_DIVISOR_H
|
||||
#define POINCARE_GREAT_COMMON_DIVISOR_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/evaluation.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "gcd"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_HYPERBOLIC_ARC_COSINE_H
|
||||
#define POINCARE_HYPERBOLIC_ARC_COSINE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "acosh"; }
|
||||
/* Simplification */
|
||||
@@ -25,10 +25,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_HYPERBOLIC_ARC_SINE_H
|
||||
#define POINCARE_HYPERBOLIC_ARC_SINE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "asinh"; }
|
||||
/* Simplification */
|
||||
@@ -25,10 +25,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_HYPERBOLIC_ARC_TANGENT_H
|
||||
#define POINCARE_HYPERBOLIC_ARC_TANGENT_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "atanh"; }
|
||||
/* Simplification */
|
||||
@@ -25,10 +25,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_HYPERBOLIC_COSINE_H
|
||||
#define POINCARE_HYPERBOLIC_COSINE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,20 +15,20 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "cosh"; }
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
/* Evaluation */
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_HYPERBOLIC_SINE_H
|
||||
#define POINCARE_HYPERBOLIC_SINE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,20 +15,20 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "sinh"; }
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
/* Evaluation */
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_HYPERBOLIC_TANGENT_H
|
||||
#define POINCARE_HYPERBOLIC_TANGENT_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,20 +15,20 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "tanh"; }
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
/* Evaluation */
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_IMAGINARY_PART_H
|
||||
#define POINCARE_IMAGINARY_PART_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "im"; }
|
||||
/* Simplification */
|
||||
@@ -25,10 +25,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Poincare {
|
||||
class ExpressionLayout;
|
||||
class LayoutReference;
|
||||
class LayoutNode;
|
||||
class IntegerReference;
|
||||
struct IntegerDivisionReference;
|
||||
class Integer;
|
||||
struct IntegerDivision;
|
||||
|
||||
typedef uint16_t half_native_uint_t;
|
||||
typedef int32_t native_int_t;
|
||||
@@ -24,8 +24,8 @@ typedef uint64_t double_native_uint_t;
|
||||
* Modern Computer Arithmetic, Richard P. Brent and Paul Zimmermann */
|
||||
|
||||
class NaturalIntegerAbstract {
|
||||
friend class IntegerReference;
|
||||
friend class RationalReference;
|
||||
friend class Integer;
|
||||
friend class Rational;
|
||||
public:
|
||||
// Getters
|
||||
uint32_t digit(int i) const { assert(i < m_numberOfDigits); return digits()[i]; }
|
||||
@@ -43,18 +43,18 @@ public:
|
||||
virtual bool isOne() const { return (m_numberOfDigits == 1 && digit(0) == 1); };
|
||||
virtual bool isTwo() const { return (m_numberOfDigits == 1 && digit(0) == 2); };
|
||||
virtual bool isTen() const { return (m_numberOfDigits == 1 && digit(0) == 10); };
|
||||
bool isZero() const { return (m_numberOfDigits == 0); };
|
||||
virtual bool isZero() const { return (m_numberOfDigits == 0); };
|
||||
bool isInfinity() const { return m_numberOfDigits > k_maxNumberOfDigits; }
|
||||
bool isEven() const { return (m_numberOfDigits == 0 || ((digit(0) & 1) == 0)); }
|
||||
bool isEven() const { return (isZero() || ((digit(0) & 1) == 0)); }
|
||||
|
||||
// Arithmetic
|
||||
/* buffer has to be k_maxNumberOfDigits+1 to allow ...*/
|
||||
static int8_t ucmp(const NaturalIntegerAbstract * a, const NaturalIntegerAbstract * b); // -1, 0, or 1
|
||||
static IntegerReference usum(const NaturalIntegerAbstract * a, const NaturalIntegerAbstract * b, bool subtract);
|
||||
static IntegerReference umult(const NaturalIntegerAbstract * a, const NaturalIntegerAbstract * b);
|
||||
static IntegerDivisionReference udiv(const NaturalIntegerAbstract * a, const NaturalIntegerAbstract * b);
|
||||
static IntegerReference upow(const NaturalIntegerAbstract * a, const NaturalIntegerAbstract * b);
|
||||
static IntegerReference ufact(const NaturalIntegerAbstract * a);
|
||||
static Integer usum(const NaturalIntegerAbstract * a, const NaturalIntegerAbstract * b, bool subtract);
|
||||
static Integer umult(const NaturalIntegerAbstract * a, const NaturalIntegerAbstract * b);
|
||||
static IntegerDivision udiv(const NaturalIntegerAbstract * a, const NaturalIntegerAbstract * b);
|
||||
static Integer upow(const NaturalIntegerAbstract * a, const NaturalIntegerAbstract * b);
|
||||
static Integer ufact(const NaturalIntegerAbstract * a);
|
||||
|
||||
constexpr static int k_maxNumberOfDigits = 32;
|
||||
protected:
|
||||
@@ -68,7 +68,7 @@ protected:
|
||||
|
||||
size_t m_numberOfDigits; // In base native_uint_max
|
||||
private:
|
||||
static IntegerReference IntegerWithHalfDigitAtIndex(half_native_uint_t halfDigit, int index);
|
||||
static Integer IntegerWithHalfDigitAtIndex(half_native_uint_t halfDigit, int index);
|
||||
|
||||
uint16_t numberOfHalfDigits() const {
|
||||
native_uint_t d = digit(m_numberOfDigits-1);
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
Type type() const override { return Type::Integer; }
|
||||
|
||||
// Simplification
|
||||
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit) override;
|
||||
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit) override { return Integer(this).shallowReduce(context, angleUnit); }
|
||||
|
||||
// Approximation
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override { return Complex<float>(templatedApproximate<float>()); }
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
|
||||
// ExpressionNode
|
||||
Sign sign() const override { return m_negative ? Sign::Negative : Sign::Positive; }
|
||||
Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) override;
|
||||
Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) override { Integer(this).setSign(s, context, angleUnit); }
|
||||
|
||||
void setNegative(bool negative);
|
||||
|
||||
@@ -152,58 +152,81 @@ private:
|
||||
native_uint_t m_digits[0];
|
||||
};
|
||||
|
||||
class AllocationFailureIntegerNode : public IntegerNode, public AllocationFailedExpressionNode {
|
||||
public
|
||||
// ExpressionNode
|
||||
using AllocationFailedExpressionNode::type;
|
||||
using AllocationFailedExpressionNode::approximate;
|
||||
using AllocationFailedExpressionNode::writeTextInBuffer;
|
||||
using AllocationFailedExpressionNode::createLayout;
|
||||
using AllocationFailedExpressionNode::numberOfChildren;
|
||||
using AllocationFailedExpressionNode::isAllocationFailure;
|
||||
size_t size() const override { return sizeof(AllocationFailureIntegerNode); }
|
||||
#if TREE_LOG
|
||||
const char * description() const override { return "AllocationFailureIntegerNode"; }
|
||||
#endif
|
||||
|
||||
class IntegerReference : public NumberReference {
|
||||
// IntegerNode
|
||||
bool isZero() const override { return false; }
|
||||
void setDigits(native_int_t i) override {}
|
||||
void setDigits(double_native_int_t i);
|
||||
void setDigits(const native_uint_t * digits, size_t size, bool negative);
|
||||
};
|
||||
|
||||
class Integer : public Number {
|
||||
friend class NaturalIntegerAbstract;
|
||||
friend class NaturalIntegerPointer;
|
||||
friend class IntegerNode;
|
||||
friend class RationalReference;
|
||||
friend class DecimalReference;
|
||||
friend class Rational;
|
||||
friend class Decimal;
|
||||
public:
|
||||
IntegerReference(TreeNode * n) : NumberReference(n) {}
|
||||
IntegerReference(const char * digits, size_t length, bool negative);
|
||||
IntegerReference(const NaturalIntegerAbstract * naturalInteger);
|
||||
IntegerReference(native_int_t i);
|
||||
IntegerReference(double_native_int_t i);
|
||||
static IntegerReference Overflow() { return IntegerReference((native_uint_t *)nullptr, IntegerNode::k_maxNumberOfDigits+1, false); }
|
||||
Integer(TreeNode * n) : Number(n) {}
|
||||
Integer(const char * digits, size_t length, bool negative);
|
||||
Integer(const NaturalIntegerAbstract * naturalInteger);
|
||||
Integer(native_int_t i);
|
||||
Integer(double_native_int_t i);
|
||||
static Integer Overflow() { return Integer((native_uint_t *)nullptr, IntegerNode::k_maxNumberOfDigits+1, false); }
|
||||
|
||||
constexpr static int k_maxExtractableInteger = 0x7FFFFFFF;
|
||||
int extractedInt() const;
|
||||
|
||||
// Comparison
|
||||
static int NaturalOrder(const IntegerReference i, const IntegerReference j);
|
||||
static int NaturalOrder(const Integer i, const Integer j);
|
||||
|
||||
// Properties
|
||||
bool isZero() const;
|
||||
virtual bool isZero() const;
|
||||
bool isOne() const;
|
||||
bool isInfinity() const;
|
||||
bool isEven() const;
|
||||
bool isNegative() const { return node()->sign() == ExpressionNode::Sign::Negative; }
|
||||
void setNegative(bool negative);
|
||||
static int NumberOfBase10Digits(const IntegerReference i);
|
||||
static int NumberOfBase10Digits(const Integer i);
|
||||
|
||||
// Arithmetic
|
||||
static IntegerReference Addition(const IntegerReference i, const IntegerReference j);
|
||||
static IntegerReference Subtraction(const IntegerReference i, const IntegerReference j);
|
||||
static IntegerReference Multiplication(const IntegerReference i, const IntegerReference j);
|
||||
static IntegerDivisionReference Division(const IntegerReference numerator, const IntegerReference denominator);
|
||||
static IntegerReference Power(const IntegerReference i, const IntegerReference j);
|
||||
static IntegerReference Factorial(const IntegerReference i);
|
||||
static Integer Addition(const Integer i, const Integer j);
|
||||
static Integer Subtraction(const Integer i, const Integer j);
|
||||
static Integer Multiplication(const Integer i, const Integer j);
|
||||
static IntegerDivision Division(const Integer numerator, const Integer denominator);
|
||||
static Integer Power(const Integer i, const Integer j);
|
||||
static Integer Factorial(const Integer i);
|
||||
private:
|
||||
// TreeNode
|
||||
IntegerNode * typedNode() const { assert(node()->type() == ExpressionNode::Type::Integer); return static_cast<IntegerNode *>(node()); }
|
||||
|
||||
IntegerReference(const native_uint_t * digits, size_t numberOfDigits, bool negative);
|
||||
IntegerReference(size_t size) : NumberReference(TreePool::sharedPool()->createTreeNode<IntegerNode>(size)) {
|
||||
Integer(const native_uint_t * digits, size_t numberOfDigits, bool negative);
|
||||
Integer(size_t size) : Number(TreePool::sharedPool()->createTreeNode<IntegerNode>(size)) {
|
||||
}
|
||||
static IntegerReference addition(const IntegerReference a, const IntegerReference b, bool inverseBNegative);
|
||||
static Integer addition(const Integer a, const Integer b, bool inverseBNegative);
|
||||
size_t numberOfDigits() const { return typedNode()->numberOfDigits(); }
|
||||
uint32_t digit(int i) const { return typedNode()->digit(i); }
|
||||
|
||||
// Simplification
|
||||
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit);
|
||||
};
|
||||
|
||||
struct IntegerDivisionReference {
|
||||
IntegerReference quotient;
|
||||
IntegerReference remainder;
|
||||
struct IntegerDivision {
|
||||
Integer quotient;
|
||||
Integer remainder;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/variable_context.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -16,7 +16,7 @@ private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "int");
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "int");
|
||||
}
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef POINCARE_LAYOUT_ENGINE_H
|
||||
#define POINCARE_LAYOUT_ENGINE_H
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/layout_reference.h>
|
||||
#include <poincare/horizontal_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class LayoutEngine {
|
||||
|
||||
public:
|
||||
/* Expression to Layout */
|
||||
static LayoutRef createInfixLayout(const Expression expression, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits, const char * operatorName);
|
||||
static LayoutRef createPrefixLayout(const Expression expression, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits, const char * operatorName);
|
||||
|
||||
/* Create special layouts */
|
||||
static LayoutRef createParenthesedLayout(LayoutRef layout, bool cloneLayout);
|
||||
static HorizontalLayoutRef createStringLayout(const char * buffer, int bufferSize, KDText::FontSize fontSize = KDText::FontSize::Large);
|
||||
static LayoutRef createLogLayout(LayoutRef argument, LayoutRef index);
|
||||
|
||||
/* SerializableReference to Text */
|
||||
static int writeInfixSerializableRefTextInBuffer(
|
||||
const SerializableReference serializableRef,
|
||||
char * buffer,
|
||||
int bufferSize,
|
||||
Preferences::PrintFloatMode floatDisplayMode,
|
||||
int numberOfDigits,
|
||||
const char * operatorName,
|
||||
int firstChildIndex = 0,
|
||||
int lastChildIndex = -1);
|
||||
|
||||
static int writePrefixSerializableRefTextInBuffer(
|
||||
const SerializableReference serializableRef,
|
||||
char * buffer,
|
||||
int bufferSize,
|
||||
Preferences::PrintFloatMode floatDisplayMode,
|
||||
int numberOfDigits,
|
||||
const char * operatorName,
|
||||
bool writeFirstChild = true);
|
||||
|
||||
/* Write one char in buffer */
|
||||
static int writeOneCharInBuffer(char * buffer, int bufferSize, char charToWrite);
|
||||
|
||||
private:
|
||||
static void writeChildTreeInBuffer(SerializableReference childRef, SerializableReference parentRef, char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfDigits, int * numberOfChar);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
23
poincare/include/poincare/layout_helper.h
Normal file
23
poincare/include/poincare/layout_helper.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef POINCARE_LAYOUT_HELPER_H
|
||||
#define POINCARE_LAYOUT_HELPER_H
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/layout_reference.h>
|
||||
#include <poincare/horizontal_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
namespace LayoutHelper {
|
||||
/* Expression to Layout */
|
||||
static LayoutRef Infix(const Expression expression, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits, const char * operatorName);
|
||||
static LayoutRef Prefix(const Expression expression, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits, const char * operatorName);
|
||||
|
||||
/* Create special layouts */
|
||||
static LayoutRef Parentheses(LayoutRef layout, bool cloneLayout);
|
||||
static HorizontalLayoutRef String(const char * buffer, int bufferSize, KDText::FontSize fontSize = KDText::FontSize::Large);
|
||||
static LayoutRef Logarithm(LayoutRef argument, LayoutRef index);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_LEAST_COMMON_MULTIPLE_H
|
||||
#define POINCARE_LEAST_COMMON_MULTIPLE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/evaluation.h>
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "lcm"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_LEFT_PARENTHESIS_LAYOUT_NODE_H
|
||||
#define POINCARE_LEFT_PARENTHESIS_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/parenthesis_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
// Serializable Node
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, '(');
|
||||
return SerializationHelper::Char(buffer, bufferSize, '(');
|
||||
}
|
||||
|
||||
// TreeNode
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_LEFT_SQUARE_BRACKET_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/square_bracket_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -10,7 +10,7 @@ class LeftSquareBracketLayoutNode : public SquareBracketLayoutNode {
|
||||
public:
|
||||
using SquareBracketLayoutNode::SquareBracketLayoutNode;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, '[');
|
||||
return SerializationHelper::Char(buffer, bufferSize, '[');
|
||||
}
|
||||
bool isLeftBracket() const override { return true; }
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_LOGARITHM_H
|
||||
#define POINCARE_LOGARITHM_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/bounded_static_hierarchy.h>
|
||||
#include <poincare/integer.h>
|
||||
|
||||
@@ -16,7 +16,7 @@ private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "log");
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "log");
|
||||
}
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit) override;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_MATRIX_DIMENSION_H
|
||||
#define POINCARE_MATRIX_DIMENSION_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -13,10 +13,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "dim"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_MATRIX_INVERSE_H
|
||||
#define POINCARE_MATRIX_INVERSE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -13,10 +13,10 @@ public:
|
||||
private:
|
||||
/* Evaluation */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "inverse"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_MATRIX_TRACE_H
|
||||
#define POINCARE_MATRIX_TRACE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/evaluation.h>
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "trace"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_MATRIX_TRANSPOSE_H
|
||||
#define POINCARE_MATRIX_TRANSPOSE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -13,10 +13,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "transpose"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#define POINCARE_MULTIPLICATION_H
|
||||
|
||||
#include <poincare/dynamic_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> compute(const std::complex<T> c, const std::complex<T> d);
|
||||
template<typename T> static MatrixComplex<T> computeOnComplexAndMatrix(const std::complex<T> c, const MatrixComplex<T> m) {
|
||||
return ApproximationEngine::elementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
return ApproximationHelper::ElementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
}
|
||||
template<typename T> static void computeOnArrays(T * m, T * n, T * result, int mNumberOfColumns, int mNumberOfRows, int nNumberOfColumns);
|
||||
template<typename T> static MatrixComplex<T> computeOnMatrices(const MatrixComplex<T> m, const MatrixComplex<T> n);
|
||||
@@ -59,13 +59,13 @@ private:
|
||||
/* Evaluation */
|
||||
|
||||
template<typename T> static MatrixComplex<T> computeOnMatrixAndComplex(const MatrixComplex<T> m, const std::complex<T> c) {
|
||||
return ApproximationEngine::elementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
return ApproximationHelper::ElementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
}
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::mapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
|
||||
return ApproximationHelper::MapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::mapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
|
||||
return ApproximationHelper::MapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_NAPERIAN_LOGARITHM_H
|
||||
#define POINCARE_NAPERIAN_LOGARITHM_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "ln"; }
|
||||
/* Simplification */
|
||||
@@ -25,10 +25,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_NTH_ROOT_H
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,7 +14,7 @@ private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "root");
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "root");
|
||||
}
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_OPPOSITE_H
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -26,10 +26,10 @@ public:
|
||||
|
||||
// Approximation
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit, compute<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit, compute<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, compute<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, compute<double>);
|
||||
}
|
||||
|
||||
// Layout
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_PARENTHESIS_H
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -23,9 +23,7 @@ public:
|
||||
|
||||
// Layout
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixSerializableRefTextInBuffer(Expression(this), buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "");
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
// Simplification
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_PERMUTE_COEFFICIENT_H
|
||||
#define POINCARE_PERMUTE_COEFFICIENT_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/evaluation.h>
|
||||
|
||||
@@ -15,10 +15,10 @@ private:
|
||||
constexpr static int k_maxNValue = 100;
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "permute"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_POWER_H
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/rational.h>
|
||||
#include <poincare/multiplication.h>
|
||||
#include <poincare/char_layout_node.h>
|
||||
@@ -33,7 +33,7 @@ private:
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
static const char * name() { return "^"; }
|
||||
/* Simplify */
|
||||
@@ -60,10 +60,10 @@ private:
|
||||
template<typename T> static MatrixComplex<T> computeOnMatrixAndComplex(const MatrixComplex<T> m, const std::complex<T> d);
|
||||
template<typename T> static MatrixComplex<T> computeOnMatrices(const MatrixComplex<T> m, const MatrixComplex<T> n);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::mapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
|
||||
return ApproximationHelper::MapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::mapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
|
||||
return ApproximationHelper::MapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_PREDICTION_INTERVAL_H
|
||||
#define POINCARE_PREDICTION_INTERVAL_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "prediction95"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_PRODUCT_LAYOUT_NODE_H
|
||||
#define POINCARE_PRODUCT_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/sequence_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_RANDINT_H
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -13,10 +13,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "randint"; }
|
||||
/* Evaluation */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/evaluation.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -17,10 +17,10 @@ private:
|
||||
Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) override;
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "random"; }
|
||||
/* Evaluation */
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_REEL_PART_H
|
||||
#define POINCARE_REEL_PART_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "re"; }
|
||||
/* Simplification */
|
||||
@@ -25,10 +25,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_RIGHT_PARENTHESIS_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/parenthesis_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
// SerializableNode
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, ')');
|
||||
return SerializationHelper::Char(buffer, bufferSize, ')');
|
||||
}
|
||||
|
||||
// TreeNode
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define POINCARE_RIGHT_SQUARE_BRACKET_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/square_bracket_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -10,7 +10,7 @@ class RightSquareBracketLayoutNode : public SquareBracketLayoutNode {
|
||||
public:
|
||||
using SquareBracketLayoutNode::SquareBracketLayoutNode;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, ']');
|
||||
return SerializationHelper::Char(buffer, bufferSize, ']');
|
||||
}
|
||||
bool isRightBracket() const override { return true; }
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_ROUND_H
|
||||
#define POINCARE_ROUND_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/evaluation.h>
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "round"; }
|
||||
/* Simplification */
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_SEQUENCE_H
|
||||
#define POINCARE_SEQUENCE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -12,7 +12,7 @@ class Sequence : public StaticHierarchy<3> {
|
||||
private:
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
virtual LayoutRef createSequenceLayout(LayoutRef subscriptLayout, LayoutRef superscriptLayout, LayoutRef argumentLayout) const = 0;
|
||||
virtual const char * name() const = 0;
|
||||
|
||||
36
poincare/include/poincare/serialization_helper.h
Normal file
36
poincare/include/poincare/serialization_helper.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef POINCARE_SERIALIZATION_HELPER_H
|
||||
#define POINCARE_SERIALIZATION_HELPER_H
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/horizontal_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
namespace SerializationHelper {
|
||||
/* SerializableReference to Text */
|
||||
static int Infix(
|
||||
const SerializableReference serializableRef,
|
||||
char * buffer,
|
||||
int bufferSize,
|
||||
Preferences::PrintFloatMode floatDisplayMode,
|
||||
int numberOfDigits,
|
||||
const char * operatorName,
|
||||
int firstChildIndex = 0,
|
||||
int lastChildIndex = -1);
|
||||
|
||||
static int Prefix(
|
||||
const SerializableReference serializableRef,
|
||||
char * buffer,
|
||||
int bufferSize,
|
||||
Preferences::PrintFloatMode floatDisplayMode,
|
||||
int numberOfDigits,
|
||||
const char * operatorName,
|
||||
bool writeFirstChild = true);
|
||||
|
||||
/* Write one char in buffer */
|
||||
static int Char(char * buffer, int bufferSize, char charToWrite);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef POINCARE_SIMPLIFICATION_ENGINE_H
|
||||
#define POINCARE_SIMPLIFICATION_ENGINE_H
|
||||
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
|
||||
#include <poincare/expression.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class SimplificationEngine {
|
||||
public:
|
||||
static Expression * map(Expression * e, Context & context, Preferences::AngleUnit angleUnit);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
18
poincare/include/poincare/simplification_helper.h
Normal file
18
poincare/include/poincare/simplification_helper.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef POINCARE_SIMPLIFICATION_HELPER_H
|
||||
#define POINCARE_SIMPLIFICATION_HELPER_H
|
||||
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
|
||||
#include <poincare/expression.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
namespace SimplificationHelper {
|
||||
static Expression * Map(Expression * e, Context & context, Preferences::AngleUnit angleUnit);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_SINE_H
|
||||
#define POINCARE_SINE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -18,20 +18,20 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "sin"; }
|
||||
/* Simplication */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
/* Evaluation */
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_SQUARE_ROOT_H
|
||||
#define POINCARE_SQUARE_ROOT_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -20,10 +20,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/symbol.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/evaluation.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#define POINCARE_SUBSTRACTION_H
|
||||
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -17,28 +17,28 @@ private:
|
||||
/* Layout */
|
||||
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createInfixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Infix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
static const char * name() { return "-"; }
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
|
||||
/* Evaluation */
|
||||
template<typename T> static MatrixComplex<T> computeOnMatrixAndComplex(const MatrixComplex<T> m, const std::complex<T> c) {
|
||||
return ApproximationEngine::elementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
return ApproximationHelper::ElementWiseOnMatrixComplexAndComplex(m, c, compute<T>);
|
||||
}
|
||||
template<typename T> static MatrixComplex<T> computeOnComplexAndMatrix(const std::complex<T> c, const MatrixComplex<T> n);
|
||||
template<typename T> static MatrixComplex<T> computeOnMatrices(const MatrixComplex<T> m, const MatrixComplex<T> n) {
|
||||
return ApproximationEngine::elementWiseOnComplexMatrices(m, n, compute<T>);
|
||||
return ApproximationHelper::ElementWiseOnComplexMatrices(m, n, compute<T>);
|
||||
}
|
||||
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::mapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
|
||||
return ApproximationHelper::MapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::mapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
|
||||
return ApproximationHelper::MapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POINCARE_SUM_LAYOUT_NODE_H
|
||||
#define POINCARE_SUM_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/sequence_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef POINCARE_TANGENT_H
|
||||
#define POINCARE_TANGENT_H
|
||||
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/static_hierarchy.h>
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -16,10 +16,10 @@ public:
|
||||
private:
|
||||
/* Layout */
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
const char * name() const { return "tan"; }
|
||||
/* Simplication */
|
||||
@@ -27,10 +27,10 @@ private:
|
||||
/* Evaluation */
|
||||
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, Preferences::AngleUnit angleUnit = Preferences::AngleUnit::Radian);
|
||||
Evaluation<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
return ApproximationHelper::Map<float>(this, context, angleUnit,computeOnComplex<float>);
|
||||
}
|
||||
Evaluation<double> approximate(DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override {
|
||||
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
return ApproximationHelper::Map<double>(this, context, angleUnit, computeOnComplex<double>);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <poincare/absolute_value.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include <poincare/simplification_helper.h>
|
||||
#include <poincare/absolute_value_layout_node.h>
|
||||
|
||||
extern "C" {
|
||||
@@ -35,7 +35,7 @@ Expression AbsoluteValue::shallowReduce(Context& context, Preferences::AngleUnit
|
||||
Expression * op = editableOperand(0);
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
if (op->type() == Type::Matrix) {
|
||||
return SimplificationEngine::map(this, context, angleUnit);
|
||||
return SimplificationHelper::Map(this, context, angleUnit);
|
||||
}
|
||||
#endif
|
||||
if (op->sign() == Sign::Positive) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <poincare/approximation_engine.h>
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/evaluation.h>
|
||||
#include <poincare/matrix.h>
|
||||
#include <cmath>
|
||||
@@ -13,7 +13,7 @@ template <typename T> T absMod(T a, T b) {
|
||||
return result > b/2 ? b-result : result;
|
||||
}
|
||||
|
||||
template <typename T> std::complex<T> ApproximationEngine::truncateRealOrImaginaryPartAccordingToArgument(std::complex<T> c) {
|
||||
template <typename T> std::complex<T> ApproximationHelper::TruncateRealOrImaginaryPartAccordingToArgument(std::complex<T> c) {
|
||||
T arg = std::arg(c);
|
||||
T precision = 10*Expression::epsilon<T>();
|
||||
if (absMod<T>(arg, (T)M_PI) <= precision) {
|
||||
@@ -25,7 +25,7 @@ template <typename T> std::complex<T> ApproximationEngine::truncateRealOrImagina
|
||||
return c;
|
||||
}
|
||||
|
||||
template<typename T> Evaluation<T> ApproximationEngine::map(const ExpressionNode * expression, Context& context, Preferences::AngleUnit angleUnit, ComplexCompute<T> compute) {
|
||||
template<typename T> Evaluation<T> ApproximationHelper::Map(const ExpressionNode * expression, Context& context, Preferences::AngleUnit angleUnit, ComplexCompute<T> compute) {
|
||||
assert(expression->numberOfChildren() == 1);
|
||||
Evaluation<T> input = expression->childAtIndex(0)->approximate(T(), context, angleUnit);
|
||||
if (input.node()->type() == EvaluationNode<T>::Type::AllocationFailure) {
|
||||
@@ -50,7 +50,7 @@ template<typename T> Evaluation<T> ApproximationEngine::map(const ExpressionNode
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> Evaluation<T> ApproximationEngine::mapReduce(const ExpressionNode * expression, Context& context, Preferences::AngleUnit angleUnit, ComplexAndComplexReduction<T> computeOnComplexes, ComplexAndMatrixReduction<T> computeOnComplexAndMatrix, MatrixAndComplexReduction<T> computeOnMatrixAndComplex, MatrixAndMatrixReduction<T> computeOnMatrices) {
|
||||
template<typename T> Evaluation<T> ApproximationHelper::MapReduce(const ExpressionNode * expression, Context& context, Preferences::AngleUnit angleUnit, ComplexAndComplexReduction<T> computeOnComplexes, ComplexAndMatrixReduction<T> computeOnComplexAndMatrix, MatrixAndComplexReduction<T> computeOnMatrixAndComplex, MatrixAndMatrixReduction<T> computeOnMatrices) {
|
||||
Evaluation<T> result = expression->childAtIndex(0)->approximate(T(), context, angleUnit);
|
||||
for (int i = 1; i < expression->numberOfChildren(); i++) {
|
||||
Evaluation<T> intermediateResult(nullptr);
|
||||
@@ -87,7 +87,7 @@ template<typename T> Evaluation<T> ApproximationEngine::mapReduce(const Expressi
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T> MatrixComplex<T> ApproximationEngine::elementWiseOnMatrixComplexAndComplex(const MatrixComplex<T> m, const std::complex<T> c, ComplexAndComplexReduction<T> computeOnComplexes) {
|
||||
template<typename T> MatrixComplex<T> ApproximationHelper::ElementWiseOnMatrixComplexAndComplex(const MatrixComplex<T> m, const std::complex<T> c, ComplexAndComplexReduction<T> computeOnComplexes) {
|
||||
if (m.isAllocationFailure()) {
|
||||
return MatrixComplex<T>(EvaluationNode<T>::FailedAllocationStaticNode());
|
||||
}
|
||||
@@ -104,7 +104,7 @@ template<typename T> MatrixComplex<T> ApproximationEngine::elementWiseOnMatrixCo
|
||||
return matrix;
|
||||
}
|
||||
|
||||
template<typename T> MatrixComplex<T> ApproximationEngine::elementWiseOnComplexMatrices(const MatrixComplex<T> m, const MatrixComplex<T> n, ComplexAndComplexReduction<T> computeOnComplexes) {
|
||||
template<typename T> MatrixComplex<T> ApproximationHelper::ElementWiseOnComplexMatrices(const MatrixComplex<T> m, const MatrixComplex<T> n, ComplexAndComplexReduction<T> computeOnComplexes) {
|
||||
if (m.isAllocationFailure() || n.isAllocationFailure()) {
|
||||
return MatrixComplex<T>(EvaluationNode<T>::FailedAllocationStaticNode());
|
||||
}
|
||||
@@ -125,16 +125,16 @@ template<typename T> MatrixComplex<T> ApproximationEngine::elementWiseOnComplexM
|
||||
return matrix;
|
||||
}
|
||||
|
||||
template std::complex<float> Poincare::ApproximationEngine::truncateRealOrImaginaryPartAccordingToArgument<float>(std::complex<float>);
|
||||
template std::complex<double> Poincare::ApproximationEngine::truncateRealOrImaginaryPartAccordingToArgument<double>(std::complex<double>);
|
||||
template Poincare::Evaluation<float> Poincare::ApproximationEngine::map(const Poincare::ExpressionNode * expression, Poincare::Context& context, Poincare::Preferences::AngleUnit angleUnit, Poincare::ApproximationEngine::ComplexCompute<float> compute);
|
||||
template Poincare::Evaluation<double> Poincare::ApproximationEngine::map(const Poincare::ExpressionNode * expression, Poincare::Context& context, Poincare::Preferences::AngleUnit angleUnit, Poincare::ApproximationEngine::ComplexCompute<double> compute);
|
||||
template Poincare::Evaluation<float> Poincare::ApproximationEngine::mapReduce(const Poincare::ExpressionNode * expression, Poincare::Context& context, Poincare::Preferences::AngleUnit angleUnit, Poincare::ApproximationEngine::ComplexAndComplexReduction<float> computeOnComplexes, Poincare::ApproximationEngine::ComplexAndMatrixReduction<float> computeOnComplexAndMatrix, Poincare::ApproximationEngine::MatrixAndComplexReduction<float> computeOnMatrixAndComplex, Poincare::ApproximationEngine::MatrixAndMatrixReduction<float> computeOnMatrices);
|
||||
template Poincare::Evaluation<double> Poincare::ApproximationEngine::mapReduce(const Poincare::ExpressionNode * expression, Poincare::Context& context, Poincare::Preferences::AngleUnit angleUnit, Poincare::ApproximationEngine::ComplexAndComplexReduction<double> computeOnComplexes, Poincare::ApproximationEngine::ComplexAndMatrixReduction<double> computeOnComplexAndMatrix, Poincare::ApproximationEngine::MatrixAndComplexReduction<double> computeOnMatrixAndComplex, Poincare::ApproximationEngine::MatrixAndMatrixReduction<double> computeOnMatrices);
|
||||
template Poincare::MatrixComplex<float> Poincare::ApproximationEngine::elementWiseOnMatrixComplexAndComplex<float>(const Poincare::MatrixComplex<float>, const std::complex<float>, Poincare::Complex<float> (*)(std::complex<float>, std::complex<float>));
|
||||
template Poincare::MatrixComplex<double> Poincare::ApproximationEngine::elementWiseOnMatrixComplexAndComplex<double>(const Poincare::MatrixComplex<double>, std::complex<double> const, Poincare::Complex<double> (*)(std::complex<double>, std::complex<double>));
|
||||
template Poincare::MatrixComplex<float> Poincare::ApproximationEngine::elementWiseOnComplexMatrices<float>(const Poincare::MatrixComplex<float>, const Poincare::MatrixComplex<float>, Poincare::Complex<float> (*)(std::complex<float>, std::complex<float>));
|
||||
template Poincare::MatrixComplex<double> Poincare::ApproximationEngine::elementWiseOnComplexMatrices<double>(const Poincare::MatrixComplex<double>, const Poincare::MatrixComplex<double>, Poincare::Complex<double> (*)(std::complex<double>, std::complex<double>));
|
||||
template std::complex<float> Poincare::ApproximationHelper::TruncateRealOrImaginaryPartAccordingToArgument<float>(std::complex<float>);
|
||||
template std::complex<double> Poincare::ApproximationHelper::TruncateRealOrImaginaryPartAccordingToArgument<double>(std::complex<double>);
|
||||
template Poincare::Evaluation<float> Poincare::ApproximationHelper::Map(const Poincare::ExpressionNode * expression, Poincare::Context& context, Poincare::Preferences::AngleUnit angleUnit, Poincare::ApproximationHelper::ComplexCompute<float> compute);
|
||||
template Poincare::Evaluation<double> Poincare::ApproximationHelper::Map(const Poincare::ExpressionNode * expression, Poincare::Context& context, Poincare::Preferences::AngleUnit angleUnit, Poincare::ApproximationHelper::ComplexCompute<double> compute);
|
||||
template Poincare::Evaluation<float> Poincare::ApproximationHelper::MapReduce(const Poincare::ExpressionNode * expression, Poincare::Context& context, Poincare::Preferences::AngleUnit angleUnit, Poincare::ApproximationHelper::ComplexAndComplexReduction<float> computeOnComplexes, Poincare::ApproximationHelper::ComplexAndMatrixReduction<float> computeOnComplexAndMatrix, Poincare::ApproximationHelper::MatrixAndComplexReduction<float> computeOnMatrixAndComplex, Poincare::ApproximationHelper::MatrixAndMatrixReduction<float> computeOnMatrices);
|
||||
template Poincare::Evaluation<double> Poincare::ApproximationHelper::MapReduce(const Poincare::ExpressionNode * expression, Poincare::Context& context, Poincare::Preferences::AngleUnit angleUnit, Poincare::ApproximationHelper::ComplexAndComplexReduction<double> computeOnComplexes, Poincare::ApproximationHelper::ComplexAndMatrixReduction<double> computeOnComplexAndMatrix, Poincare::ApproximationHelper::MatrixAndComplexReduction<double> computeOnMatrixAndComplex, Poincare::ApproximationHelper::MatrixAndMatrixReduction<double> computeOnMatrices);
|
||||
template Poincare::MatrixComplex<float> Poincare::ApproximationHelper::ElementWiseOnMatrixComplexAndComplex<float>(const Poincare::MatrixComplex<float>, const std::complex<float>, Poincare::Complex<float> (*)(std::complex<float>, std::complex<float>));
|
||||
template Poincare::MatrixComplex<double> Poincare::ApproximationHelper::ElementWiseOnMatrixComplexAndComplex<double>(const Poincare::MatrixComplex<double>, std::complex<double> const, Poincare::Complex<double> (*)(std::complex<double>, std::complex<double>));
|
||||
template Poincare::MatrixComplex<float> Poincare::ApproximationHelper::ElementWiseOnComplexMatrices<float>(const Poincare::MatrixComplex<float>, const Poincare::MatrixComplex<float>, Poincare::Complex<float> (*)(std::complex<float>, std::complex<float>));
|
||||
template Poincare::MatrixComplex<double> Poincare::ApproximationHelper::ElementWiseOnComplexMatrices<double>(const Poincare::MatrixComplex<double>, const Poincare::MatrixComplex<double>, Poincare::Complex<double> (*)(std::complex<double>, std::complex<double>));
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <poincare/arc_cosine.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include <poincare/simplification_helper.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
@@ -24,7 +24,7 @@ Expression ArcCosine::shallowReduce(Context& context, Preferences::AngleUnit ang
|
||||
}
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
if (operand(0)->type() == Type::Matrix) {
|
||||
return SimplificationEngine::map(this, context, angleUnit);
|
||||
return SimplificationHelper::Map(this, context, angleUnit);
|
||||
}
|
||||
#endif
|
||||
return Trigonometry::shallowReduceInverseFunction(this, context, angleUnit);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <poincare/arc_sine.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include <poincare/simplification_helper.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
@@ -24,7 +24,7 @@ Expression ArcSine::shallowReduce(Context& context, Preferences::AngleUnit angle
|
||||
}
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
if (operand(0)->type() == Type::Matrix) {
|
||||
return SimplificationEngine::map(this, context, angleUnit);
|
||||
return SimplificationHelper::Map(this, context, angleUnit);
|
||||
}
|
||||
#endif
|
||||
return Trigonometry::shallowReduceInverseFunction(this, context, angleUnit);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <poincare/arc_tangent.h>
|
||||
#include <poincare/trigonometry.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include <poincare/simplification_helper.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
@@ -24,7 +24,7 @@ Expression ArcTangent::shallowReduce(Context& context, Preferences::AngleUnit an
|
||||
}
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
if (operand(0)->type() == Type::Matrix) {
|
||||
return SimplificationEngine::map(this, context, angleUnit);
|
||||
return SimplificationHelper::Map(this, context, angleUnit);
|
||||
}
|
||||
#endif
|
||||
return Trigonometry::shallowReduceInverseFunction(this, context, angleUnit);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <poincare/binomial_coefficient_layout_node.h>
|
||||
#include <poincare/left_parenthesis_layout_node.h>
|
||||
#include <poincare/right_parenthesis_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <assert.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -75,7 +75,7 @@ void BinomialCoefficientLayoutNode::moveCursorDown(LayoutCursor * cursor, bool *
|
||||
}
|
||||
|
||||
int BinomialCoefficientLayoutNode::writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return LayoutEngine::writePrefixSerializableRefTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "binomial");
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "binomial");
|
||||
}
|
||||
|
||||
KDSize BinomialCoefficientLayoutNode::computeSize() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <poincare/bracket_pair_layout_node.h>
|
||||
#include <poincare/horizontal_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <cmath>
|
||||
#include <ion.h>
|
||||
#include <poincare/symbol.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include <poincare/simplification_helper.h>
|
||||
#include <poincare/rational.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
@@ -28,7 +28,7 @@ Expression Ceiling::shallowReduce(Context& context, Preferences::AngleUnit angle
|
||||
Expression * op = editableOperand(0);
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
if (op->type() == Type::Matrix) {
|
||||
return SimplificationEngine::map(this, context, angleUnit);
|
||||
return SimplificationHelper::Map(this, context, angleUnit);
|
||||
}
|
||||
#endif
|
||||
if (op->type() == Type::Symbol) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <poincare/char_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <ion/charset.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -28,7 +28,7 @@ void CharLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecompu
|
||||
}
|
||||
|
||||
int CharLayoutNode::writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, m_char);
|
||||
return SerializationHelper::Char(buffer, bufferSize, m_char);
|
||||
}
|
||||
|
||||
bool CharLayoutNode::isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <poincare/complex_argument.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include <poincare/simplification_helper.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
@@ -24,7 +24,7 @@ Expression ComplexArgument::shallowReduce(Context& context, Preferences::AngleUn
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
Expression * op = editableOperand(0);
|
||||
if (op->type() == Type::Matrix) {
|
||||
return SimplificationEngine::map(this, context, angleUnit);
|
||||
return SimplificationHelper::Map(this, context, angleUnit);
|
||||
}
|
||||
#endif
|
||||
return this;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <poincare/conjugate.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include <poincare/simplification_helper.h>
|
||||
#include <poincare/conjugate_layout_node.h>
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
@@ -27,7 +27,7 @@ Expression Conjugate::shallowReduce(Context& context, Preferences::AngleUnit ang
|
||||
Expression * op = editableOperand(0);
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
if (op->type() == Type::Matrix) {
|
||||
return SimplificationEngine::map(this, context, angleUnit);
|
||||
return SimplificationHelper::Map(this, context, angleUnit);
|
||||
}
|
||||
#endif
|
||||
if (op->type() == Type::Rational) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <poincare/conjugate_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <escher/metric.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -54,7 +54,7 @@ void ConjugateLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRe
|
||||
}
|
||||
|
||||
int ConjugateLayoutNode::writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return LayoutEngine::writePrefixSerializableRefTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "conj");
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "conj");
|
||||
}
|
||||
|
||||
KDSize ConjugateLayoutNode::computeSize() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <poincare/symbol.h>
|
||||
#include <poincare/rational.h>
|
||||
#include <poincare/multiplication.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include <poincare/simplification_helper.h>
|
||||
#include <ion.h>
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
@@ -40,7 +40,7 @@ Expression Cosine::shallowReduce(Context& context, Preferences::AngleUnit angleU
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
Expression * op = editableOperand(0);
|
||||
if (op->type() == Type::Matrix) {
|
||||
return SimplificationEngine::map(this, context, angleUnit);
|
||||
return SimplificationHelper::Map(this, context, angleUnit);
|
||||
}
|
||||
#endif
|
||||
return Trigonometry::shallowReduceDirectFunction(this, context, angleUnit);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <poincare/rational.h>
|
||||
#include <poincare/opposite.h>
|
||||
#include <poincare/infinity.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/ieee754.h>
|
||||
#include <assert.h>
|
||||
#include <ion.h>
|
||||
@@ -107,7 +107,7 @@ bool DecimalNode::needsParenthesisWithParent(SerializableNode * parentNode) cons
|
||||
LayoutRef DecimalNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
char buffer[k_maxBufferSize];
|
||||
int numberOfChars = convertToText(buffer, k_maxBufferSize, floatDisplayMode, numberOfSignificantDigits);
|
||||
return LayoutEngine::createStringLayout(buffer, numberOfChars);
|
||||
return LayoutHelper::String(buffer, numberOfChars);
|
||||
}
|
||||
|
||||
int DecimalNode::writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <poincare/derivative.h>
|
||||
#include <poincare/symbol.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include <poincare/simplification_helper.h>
|
||||
#include <poincare/undefined.h>
|
||||
#include <cmath>
|
||||
extern "C" {
|
||||
@@ -85,7 +85,7 @@ template<typename T>
|
||||
T Derivative::riddersApproximation(Context & context, Preferences::AngleUnit angleUnit, T x, T h, T * error) const {
|
||||
/* Ridders' Algorithm
|
||||
* Blibliography:
|
||||
* - Ridders, C.J.F. 1982, Advances in Engineering Software, vol. 4, no. 2,
|
||||
* - Ridders, C.J.F. 1982, Advances in Helperering Software, vol. 4, no. 2,
|
||||
* pp. 75–76. */
|
||||
|
||||
*error = sizeof(T) == sizeof(float) ? FLT_MAX : DBL_MAX;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <poincare/empty_expression.h>
|
||||
#include <poincare/empty_layout_node.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <ion/charset.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -11,7 +11,7 @@ Expression * EmptyExpression::clone() const {
|
||||
}
|
||||
|
||||
int EmptyExpression::writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, Ion::Charset::Empty);
|
||||
return SerializationHelper::Char(buffer, bufferSize, Ion::Charset::Empty);
|
||||
}
|
||||
|
||||
LayoutRef EmptyExpression::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
|
||||
@@ -99,8 +99,8 @@ Expression ExpressionNode::reduce(Context & context, Preferences::AngleUnit angl
|
||||
return Expression(this);
|
||||
}
|
||||
|
||||
Expression ExpressionNode::beautify(Context & context, Preferences::AngleUnit angleUnit) const {
|
||||
return Expression(this);
|
||||
Expression Expression::beautify(Context & context, Preferences::AngleUnit angleUnit) const {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool ExpressionNode::isOfType(Type * types, int length) const {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <poincare/rational.h>
|
||||
#include <poincare/undefined.h>
|
||||
#include <poincare/symbol.h>
|
||||
#include <poincare/simplification_engine.h>
|
||||
#include <poincare/simplification_helper.h>
|
||||
#include <poincare/parenthesis.h>
|
||||
#include <ion.h>
|
||||
extern "C" {
|
||||
@@ -43,7 +43,7 @@ Expression Factorial::shallowReduce(Context& context, Preferences::AngleUnit ang
|
||||
}
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
if (operand(0)->type() == Type::Matrix) {
|
||||
return SimplificationEngine::map(this, context, angleUnit);
|
||||
return SimplificationHelper::Map(this, context, angleUnit);
|
||||
}
|
||||
#endif
|
||||
if (operand(0)->type() == Type::Rational) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user