mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] Templatize TreeHandle Builders
This commit is contained in:
committed by
LeaNumworks
parent
d29885028b
commit
24c9617a89
@@ -19,7 +19,7 @@ namespace Regression {
|
||||
|
||||
Layout CubicModel::layout() {
|
||||
if (m_layout.isUninitialized()) {
|
||||
const Layout layoutChildren[] = {
|
||||
Layout layoutChildren[] = {
|
||||
CharLayout::Builder('a', KDFont::SmallFont),
|
||||
CharLayout::Builder(Ion::Charset::MiddleDot, KDFont::SmallFont),
|
||||
CharLayout::Builder('X', KDFont::SmallFont),
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Regression {
|
||||
|
||||
Layout ExponentialModel::layout() {
|
||||
if (m_layout.isUninitialized()) {
|
||||
const Layout layoutChildren[] = {
|
||||
Layout layoutChildren[] = {
|
||||
CharLayout::Builder('a', KDFont::SmallFont),
|
||||
CharLayout::Builder(Ion::Charset::MiddleDot, KDFont::SmallFont),
|
||||
CharLayout::Builder('e', KDFont::SmallFont),
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Regression {
|
||||
|
||||
Layout LinearModel::layout() {
|
||||
if (m_layout.isUninitialized()) {
|
||||
const Layout layoutChildren[] = {
|
||||
Layout layoutChildren[] = {
|
||||
CharLayout::Builder('a', KDFont::SmallFont),
|
||||
CharLayout::Builder(Ion::Charset::MiddleDot, KDFont::SmallFont),
|
||||
CharLayout::Builder('X', KDFont::SmallFont),
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Regression {
|
||||
|
||||
Layout LogarithmicModel::layout() {
|
||||
if (m_layout.isUninitialized()) {
|
||||
const Layout layoutChildren[] = {
|
||||
Layout layoutChildren[] = {
|
||||
CharLayout::Builder('a', KDFont::SmallFont),
|
||||
CharLayout::Builder(Ion::Charset::MiddleDot, KDFont::SmallFont),
|
||||
CharLayout::Builder('l', KDFont::SmallFont),
|
||||
|
||||
@@ -12,13 +12,13 @@ namespace Regression {
|
||||
|
||||
Layout LogisticModel::layout() {
|
||||
if (m_layout.isUninitialized()) {
|
||||
const Layout exponentLayoutChildren[] = {
|
||||
Layout exponentLayoutChildren[] = {
|
||||
CharLayout::Builder('-', KDFont::SmallFont),
|
||||
CharLayout::Builder('b', KDFont::SmallFont),
|
||||
CharLayout::Builder(Ion::Charset::MiddleDot, KDFont::SmallFont),
|
||||
CharLayout::Builder('X', KDFont::SmallFont)
|
||||
};
|
||||
const Layout layoutChildren[] = {
|
||||
Layout layoutChildren[] = {
|
||||
CharLayout::Builder('1', KDFont::SmallFont),
|
||||
CharLayout::Builder('+', KDFont::SmallFont),
|
||||
CharLayout::Builder('a', KDFont::SmallFont),
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Regression {
|
||||
|
||||
Layout PowerModel::layout() {
|
||||
if (m_layout.isUninitialized()) {
|
||||
const Layout layoutChildren[] = {
|
||||
Layout layoutChildren[] = {
|
||||
CharLayout::Builder('a', KDFont::SmallFont),
|
||||
CharLayout::Builder(Ion::Charset::MiddleDot, KDFont::SmallFont),
|
||||
CharLayout::Builder('X', KDFont::SmallFont),
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Regression {
|
||||
|
||||
Layout QuadraticModel::layout() {
|
||||
if (m_layout.isUninitialized()) {
|
||||
const Layout layoutChildren[] = {
|
||||
Layout layoutChildren[] = {
|
||||
CharLayout::Builder('a', KDFont::SmallFont),
|
||||
CharLayout::Builder(Ion::Charset::MiddleDot, KDFont::SmallFont),
|
||||
CharLayout::Builder('X', KDFont::SmallFont),
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Regression {
|
||||
|
||||
Layout QuarticModel::layout() {
|
||||
if (m_layout.isUninitialized()) {
|
||||
const Layout layoutChildren[] = {
|
||||
Layout layoutChildren[] = {
|
||||
CharLayout::Builder('a', KDFont::SmallFont),
|
||||
CharLayout::Builder(Ion::Charset::MiddleDot, KDFont::SmallFont),
|
||||
CharLayout::Builder('X', KDFont::SmallFont),
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Regression {
|
||||
|
||||
Layout TrigonometricModel::layout() {
|
||||
if (m_layout.isUninitialized()) {
|
||||
const Layout layoutChildren[] = {
|
||||
Layout layoutChildren[] = {
|
||||
CharLayout::Builder('a', KDFont::SmallFont),
|
||||
CharLayout::Builder(Ion::Charset::MiddleDot, KDFont::SmallFont),
|
||||
CharLayout::Builder('s', KDFont::SmallFont),
|
||||
|
||||
@@ -3,16 +3,13 @@ SFLAGS += -Ipoincare/include
|
||||
#include poincare/src/simplify/Makefile
|
||||
#include poincare/src/simplification/Makefile
|
||||
objs += $(addprefix poincare/src/,\
|
||||
absolute_value_layout.o\
|
||||
binomial_coefficient_layout.o\
|
||||
bracket_layout.o\
|
||||
bracket_pair_layout.o\
|
||||
ceiling_layout.o\
|
||||
char_layout.o\
|
||||
condensed_sum_layout.o\
|
||||
conjugate_layout.o\
|
||||
empty_layout.o\
|
||||
floor_layout.o\
|
||||
fraction_layout.o\
|
||||
grid_layout.o\
|
||||
horizontal_layout.o\
|
||||
|
||||
@@ -49,7 +49,7 @@ class AbsoluteValue final : public Expression {
|
||||
friend class AbsoluteValueNode;
|
||||
public:
|
||||
AbsoluteValue(const AbsoluteValueNode * n) : Expression(n) {}
|
||||
static AbsoluteValue Builder(Expression child);
|
||||
static AbsoluteValue Builder(Expression child) { return TreeHandle::FixedArityBuilder<AbsoluteValue, AbsoluteValueNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("abs", 1, &UntypedBuilderOneChild<AbsoluteValue>);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ private:
|
||||
|
||||
class AbsoluteValueLayout final : public Layout {
|
||||
public:
|
||||
static AbsoluteValueLayout Builder(Layout l);
|
||||
static AbsoluteValueLayout Builder(Layout child) { return TreeHandle::FixedArityBuilder<AbsoluteValueLayout, AbsoluteValueLayoutNode>(&child, 1); }
|
||||
AbsoluteValueLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define POINCARE_ADDITION_H
|
||||
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/array_builder.h>
|
||||
#include <poincare/n_ary_expression_node.h>
|
||||
#include <poincare/rational.h>
|
||||
|
||||
@@ -61,10 +60,10 @@ private:
|
||||
class Addition final : public NAryExpression {
|
||||
public:
|
||||
Addition(const AdditionNode * n) : NAryExpression(n) {}
|
||||
static Addition Builder();
|
||||
static Addition Builder() { return TreeHandle::NAryBuilder<Addition, AdditionNode>(); }
|
||||
static Addition Builder(Expression e1) { return Addition::Builder(&e1, 1); }
|
||||
static Addition Builder(Expression e1, Expression e2) { return Addition::Builder(ArrayBuilder<Expression>(e1, e2).array(), 2); }
|
||||
static Addition Builder(Expression * children, size_t numberOfChildren);
|
||||
static Addition Builder(Expression * children, size_t numberOfChildren) { return TreeHandle::NAryBuilder<Addition, AdditionNode>(children, numberOfChildren); }
|
||||
// Expression
|
||||
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
|
||||
Expression shallowBeautify(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
class ArcCosine final : public Expression {
|
||||
public:
|
||||
ArcCosine(const ArcCosineNode * n) : Expression(n) {}
|
||||
static ArcCosine Builder(Expression child);
|
||||
static ArcCosine Builder(Expression child) { return TreeHandle::FixedArityBuilder<ArcCosine, ArcCosineNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("acos", 1, &UntypedBuilderOneChild<ArcCosine>);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
class ArcSine final : public Expression {
|
||||
public:
|
||||
ArcSine(const ArcSineNode * n) : Expression(n) {}
|
||||
static ArcSine Builder(Expression child);
|
||||
static ArcSine Builder(Expression child) { return TreeHandle::FixedArityBuilder<ArcSine, ArcSineNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("asin", 1, &UntypedBuilderOneChild<ArcSine>);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
class ArcTangent final : public Expression {
|
||||
public:
|
||||
ArcTangent(const ArcTangentNode * n) : Expression(n) {}
|
||||
static ArcTangent Builder(Expression child);
|
||||
static ArcTangent Builder(Expression child) { return TreeHandle::FixedArityBuilder<ArcTangent, ArcTangentNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("atan", 1, &UntypedBuilderOneChild<ArcTangent>);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ private:
|
||||
class BinomialCoefficient final : public Expression {
|
||||
public:
|
||||
BinomialCoefficient(const BinomialCoefficientNode * n) : Expression(n) {}
|
||||
static BinomialCoefficient Builder(Expression child0, Expression child1);
|
||||
static BinomialCoefficient Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<BinomialCoefficient, BinomialCoefficientNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("binomial", 2, &UntypedBuilderTwoChildren<BinomialCoefficient>);
|
||||
|
||||
// Expression
|
||||
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
|
||||
class BinomialCoefficientLayout final : public Layout {
|
||||
public:
|
||||
static BinomialCoefficientLayout Builder(Layout n, Layout k);
|
||||
static BinomialCoefficientLayout Builder(Layout child0, Layout child1) { return TreeHandle::FixedArityBuilder<BinomialCoefficientLayout, BinomialCoefficientLayoutNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
BinomialCoefficientLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
class Ceiling final : public Expression {
|
||||
public:
|
||||
Ceiling(const CeilingNode * n) : Expression(n) {}
|
||||
static Ceiling Builder(Expression child);
|
||||
static Ceiling Builder(Expression child) { return TreeHandle::FixedArityBuilder<Ceiling, CeilingNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("ceil", 1, &UntypedBuilderOneChild<Ceiling>);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ protected:
|
||||
|
||||
class CeilingLayout final : public Layout {
|
||||
public:
|
||||
static CeilingLayout Builder(Layout l);
|
||||
static CeilingLayout Builder(Layout child) { return TreeHandle::FixedArityBuilder<CeilingLayout, CeilingLayoutNode>(&child, 1); }
|
||||
CeilingLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
class ComplexArgument final : public Expression {
|
||||
public:
|
||||
ComplexArgument(const ComplexArgumentNode * n) : Expression(n) {}
|
||||
static ComplexArgument Builder(Expression child);
|
||||
static ComplexArgument Builder(Expression child) { return TreeHandle::FixedArityBuilder<ComplexArgument, ComplexArgumentNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("arg", 1, &UntypedBuilderOneChild<ComplexArgument>);
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ class ComplexCartesian final : public Expression {
|
||||
public:
|
||||
ComplexCartesian() : Expression() {}
|
||||
ComplexCartesian(const ComplexCartesianNode * node) : Expression(node) {}
|
||||
static ComplexCartesian Builder();
|
||||
static ComplexCartesian Builder(Expression child0, Expression child1);
|
||||
static ComplexCartesian Builder() { return TreeHandle::FixedArityBuilder<ComplexCartesian, ComplexCartesianNode>(); }
|
||||
static ComplexCartesian Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<ComplexCartesian, ComplexCartesianNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
|
||||
// Getters
|
||||
Expression real() { return childAtIndex(0); }
|
||||
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
|
||||
class CondensedSumLayout final : public Layout {
|
||||
public:
|
||||
static CondensedSumLayout Builder(Layout base, Layout subscript, Layout superscript);
|
||||
static CondensedSumLayout Builder(Layout base, Layout subscript, Layout superscript) { return TreeHandle::FixedArityBuilder<CondensedSumLayout, CondensedSumLayoutNode>(ArrayBuilder<TreeHandle>(base, subscript, superscript).array(), 3); }
|
||||
CondensedSumLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class ConfidenceInterval : public Expression {
|
||||
friend class SimplePredictionInterval;
|
||||
public:
|
||||
ConfidenceInterval(const ConfidenceIntervalNode * n) : Expression(n) {}
|
||||
static ConfidenceInterval Builder(Expression child0, Expression child1);
|
||||
static ConfidenceInterval Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<ConfidenceInterval, ConfidenceIntervalNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("confidence", 2, &UntypedBuilderTwoChildren<ConfidenceInterval>);
|
||||
|
||||
// Expression
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
class SimplePredictionInterval final : public ConfidenceInterval {
|
||||
public:
|
||||
SimplePredictionInterval(const SimplePredictionIntervalNode * n) : ConfidenceInterval(n) {}
|
||||
static SimplePredictionInterval Builder(Expression child0, Expression child1);
|
||||
static SimplePredictionInterval Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<SimplePredictionInterval, SimplePredictionIntervalNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("prediction", 2, &UntypedBuilderTwoChildren<SimplePredictionInterval>);
|
||||
};
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
class Conjugate final : public Expression {
|
||||
public:
|
||||
Conjugate(const ConjugateNode * n) : Expression(n) {}
|
||||
static Conjugate Builder(Expression child);
|
||||
static Conjugate Builder(Expression child) { return TreeHandle::FixedArityBuilder<Conjugate, ConjugateNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("conj", 1, &UntypedBuilderOneChild<Conjugate>);;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
|
||||
class ConjugateLayout final : public Layout {
|
||||
public:
|
||||
static ConjugateLayout Builder(Layout child);
|
||||
static ConjugateLayout Builder(Layout child) { return TreeHandle::FixedArityBuilder<ConjugateLayout, ConjugateLayoutNode>(&child, 1); }
|
||||
ConjugateLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ private:
|
||||
class Cosine final : public Expression {
|
||||
public:
|
||||
Cosine(const CosineNode * n) : Expression(n) {}
|
||||
static Cosine Builder(Expression child);
|
||||
static Cosine Builder(Expression child) { return TreeHandle::FixedArityBuilder<Cosine, CosineNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("cos", 1, &UntypedBuilderOneChild<Cosine>);
|
||||
|
||||
|
||||
@@ -51,15 +51,8 @@ private:
|
||||
class Derivative final : public Expression {
|
||||
public:
|
||||
Derivative(const DerivativeNode * n) : Expression(n) {}
|
||||
static Derivative Builder(Expression child0, Symbol child1, Expression child2);
|
||||
static Expression UntypedBuilder(Expression children) {
|
||||
assert(children.type() == ExpressionNode::Type::Matrix);
|
||||
if (children.childAtIndex(1).type() != ExpressionNode::Type::Symbol) {
|
||||
// Second parameter must be a Symbol.
|
||||
return Expression();
|
||||
}
|
||||
return Builder(children.childAtIndex(0), children.childAtIndex(1).convert<Symbol>(), children.childAtIndex(2));
|
||||
}
|
||||
static Derivative Builder(Expression child0, Symbol child1, Expression child2) { return TreeHandle::FixedArityBuilder<Derivative, DerivativeNode>(ArrayBuilder<TreeHandle>(child0, child1, child2).array(), 3); }
|
||||
static Expression UntypedBuilder(Expression children);
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("diff", 3, &UntypedBuilder);
|
||||
|
||||
Expression shallowReduce();
|
||||
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
class Determinant final : public Expression {
|
||||
public:
|
||||
Determinant(const DeterminantNode * n) : Expression(n) {}
|
||||
static Determinant Builder(Expression child);
|
||||
static Determinant Builder(Expression child) { return TreeHandle::FixedArityBuilder<Determinant, DeterminantNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("det", 1, &UntypedBuilderOneChild<Determinant>);
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@ private:
|
||||
class Division final : public Expression {
|
||||
public:
|
||||
Division(const DivisionNode * n) : Expression(n) {}
|
||||
static Division Builder();
|
||||
static Division Builder(Expression numerator, Expression denominator);
|
||||
static Division Builder() { return TreeHandle::FixedArityBuilder<Division, DivisionNode>(); }
|
||||
static Division Builder(Expression numerator, Expression denominator) { return TreeHandle::FixedArityBuilder<Division, DivisionNode>(ArrayBuilder<TreeHandle>(numerator, denominator).array(), 2); }
|
||||
|
||||
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
class DivisionQuotient final : public Expression {
|
||||
public:
|
||||
DivisionQuotient(const DivisionQuotientNode * n) : Expression(n) {}
|
||||
static DivisionQuotient Builder(Expression child0, Expression child1);
|
||||
static DivisionQuotient Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<DivisionQuotient, DivisionQuotientNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("quo", 2, &UntypedBuilderTwoChildren<DivisionQuotient>);
|
||||
|
||||
// Expression
|
||||
|
||||
@@ -39,7 +39,7 @@ private:
|
||||
class DivisionRemainder final : public Expression {
|
||||
public:
|
||||
DivisionRemainder(const DivisionRemainderNode * n) : Expression(n) {}
|
||||
static DivisionRemainder Builder(Expression child0, Expression child1);
|
||||
static DivisionRemainder Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<DivisionRemainder, DivisionRemainderNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("rem", 2, &UntypedBuilderTwoChildren<DivisionRemainder>);
|
||||
|
||||
// Expression
|
||||
|
||||
@@ -33,7 +33,7 @@ private:
|
||||
|
||||
class EmptyExpression final : public Expression {
|
||||
public:
|
||||
static EmptyExpression Builder();
|
||||
static EmptyExpression Builder() { return TreeHandle::FixedArityBuilder<EmptyExpression, EmptyExpressionNode>(); }
|
||||
EmptyExpression(const EmptyExpressionNode * n) : Expression(n) {}
|
||||
};
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
class Equal final : public Expression {
|
||||
public:
|
||||
Equal(const EqualNode * n) : Expression(n) {}
|
||||
static Equal Builder(Expression child0, Expression child1);
|
||||
static Equal Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<Equal, EqualNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
|
||||
// For the equation A = B, create the reduced expression A-B
|
||||
Expression standardEquation(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef POINCARE_EXPRESSION_REFERENCE_H
|
||||
#define POINCARE_EXPRESSION_REFERENCE_H
|
||||
|
||||
#include <poincare/array_builder.h>
|
||||
#include <poincare/tree_handle.h>
|
||||
#include <poincare/preferences.h>
|
||||
#include <poincare/print_float.h>
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
class Factor final : public Expression {
|
||||
public:
|
||||
Factor(const FactorNode * n) : Expression(n) {}
|
||||
static Factor Builder(Expression child);
|
||||
static Factor Builder(Expression child) { return TreeHandle::FixedArityBuilder<Factor, FactorNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("factor", 1, &UntypedBuilderOneChild<Factor>);
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ private:
|
||||
class Factorial final : public Expression {
|
||||
public:
|
||||
Factorial(const FactorialNode * n) : Expression(n) {}
|
||||
static Factorial Builder();
|
||||
static Factorial Builder(Expression child);
|
||||
static Factorial Builder(Expression child) { return TreeHandle::FixedArityBuilder<Factorial, FactorialNode>(&child, 1); }
|
||||
|
||||
Expression shallowReduce();
|
||||
Expression shallowBeautify();
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
class Floor final : public Expression {
|
||||
public:
|
||||
Floor(const FloorNode * n) : Expression(n) {}
|
||||
static Floor Builder(Expression child);
|
||||
static Floor Builder(Expression child) { return TreeHandle::FixedArityBuilder<Floor, FloorNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("floor", 1, &UntypedBuilderOneChild<Floor>);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ protected:
|
||||
|
||||
class FloorLayout final : public Layout {
|
||||
public:
|
||||
static FloorLayout Builder(Layout child);
|
||||
static FloorLayout Builder(Layout child) { return TreeHandle::FixedArityBuilder<FloorLayout, FloorLayoutNode>(&child, 1); }
|
||||
FloorLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
class FracPart final : public Expression {
|
||||
public:
|
||||
FracPart(const FracPartNode * n) : Expression(n) {}
|
||||
static FracPart Builder(Expression child);
|
||||
static FracPart Builder(Expression child) { return TreeHandle::FixedArityBuilder<FracPart, FracPartNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("frac", 1, &UntypedBuilderOneChild<FracPart>);
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
|
||||
class FractionLayout final : public Layout {
|
||||
public:
|
||||
static FractionLayout Builder(Layout numerator, Layout denominator);
|
||||
static FractionLayout Builder(Layout child0, Layout child1) { return TreeHandle::FixedArityBuilder<FractionLayout, FractionLayoutNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
FractionLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,12 +12,7 @@ namespace Poincare {
|
||||
|
||||
class Ghost final : public TreeHandle {
|
||||
public:
|
||||
static Ghost Builder() {
|
||||
void * bufferNode = TreePool::sharedPool()->alloc(sizeof(GhostNode));
|
||||
GhostNode * node = new (bufferNode) GhostNode();
|
||||
TreeHandle h = TreeHandle::BuildWithBasicChildren(node);
|
||||
return static_cast<Ghost &>(h);
|
||||
}
|
||||
static Ghost Builder() { return TreeHandle::FixedArityBuilder<Ghost, GhostNode>(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
class GreatCommonDivisor final : public Expression {
|
||||
public:
|
||||
GreatCommonDivisor(const GreatCommonDivisorNode * n) : Expression(n) {}
|
||||
static GreatCommonDivisor Builder(Expression child0, Expression child1);
|
||||
static GreatCommonDivisor Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<GreatCommonDivisor, GreatCommonDivisorNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("gcd", 2, &UntypedBuilderTwoChildren<GreatCommonDivisor>);
|
||||
|
||||
// Expression
|
||||
|
||||
@@ -89,7 +89,8 @@ private:
|
||||
class GridLayout : public Layout {
|
||||
public:
|
||||
GridLayout(const GridLayoutNode * n) : Layout(n) {}
|
||||
static GridLayout Builder();
|
||||
static GridLayout Builder() { return TreeHandle::NAryBuilder<GridLayout,GridLayoutNode>(); }
|
||||
|
||||
void setDimensions(int rows, int columns);
|
||||
void addChildAtIndex(Layout l, int index, int currentNumberOfChildren, LayoutCursor * cursor) {
|
||||
Layout::addChildAtIndex(l, index, currentNumberOfChildren, cursor);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef POINCARE_HORIZONTAL_LAYOUT_NODE_H
|
||||
#define POINCARE_HORIZONTAL_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/array_builder.h>
|
||||
#include <poincare/layout.h>
|
||||
#include <poincare/layout_cursor.h>
|
||||
|
||||
@@ -68,18 +67,12 @@ class HorizontalLayout final : public Layout {
|
||||
public:
|
||||
// Constructors
|
||||
HorizontalLayout(HorizontalLayoutNode * n) : Layout(n) {}
|
||||
static HorizontalLayout Builder();
|
||||
static HorizontalLayout Builder() { return TreeHandle::NAryBuilder<HorizontalLayout,HorizontalLayoutNode>(); }
|
||||
static HorizontalLayout Builder(Layout l) { return HorizontalLayout::Builder(&l, 1); }
|
||||
static HorizontalLayout Builder(Layout l1, Layout l2) { return HorizontalLayout::Builder(ArrayBuilder<Layout>(l1, l2).array(), 2); }
|
||||
static HorizontalLayout Builder(Layout l1, Layout l2, Layout l3) { return HorizontalLayout::Builder(ArrayBuilder<Layout>(l1, l2, l3).array(), 3); }
|
||||
static HorizontalLayout Builder(Layout l1, Layout l2, Layout l3, Layout l4) { return HorizontalLayout::Builder(ArrayBuilder<Layout>(l1, l2, l3, l4).array(), 4); }
|
||||
static HorizontalLayout Builder(const Layout * children, size_t numberOfChildren) {
|
||||
HorizontalLayout h = HorizontalLayout::Builder();
|
||||
for (size_t i = 0; i < numberOfChildren; i++) {
|
||||
h.addChildAtIndexInPlace(children[i], i, i);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
static HorizontalLayout Builder(Layout * children, size_t numberOfChildren) { return TreeHandle::NAryBuilder<HorizontalLayout,HorizontalLayoutNode>(static_cast<TreeHandle *>(children), numberOfChildren); }
|
||||
|
||||
void addChildAtIndex(Layout l, int index, int currentNumberOfChildren, LayoutCursor * cursor, bool removeEmptyChildren = false);
|
||||
// Remove puts a child at the end of the pool
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
class HyperbolicArcCosine final : public HyperbolicTrigonometricFunction {
|
||||
public:
|
||||
HyperbolicArcCosine(const HyperbolicArcCosineNode * n) : HyperbolicTrigonometricFunction(n) {}
|
||||
static HyperbolicArcCosine Builder(Expression child);
|
||||
static HyperbolicArcCosine Builder(Expression child) { return TreeHandle::FixedArityBuilder<HyperbolicArcCosine, HyperbolicArcCosineNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("acosh", 1, &UntypedBuilderOneChild<HyperbolicArcCosine>);
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
class HyperbolicArcSine final : public HyperbolicTrigonometricFunction {
|
||||
public:
|
||||
HyperbolicArcSine(const HyperbolicArcSineNode * n) : HyperbolicTrigonometricFunction(n) {}
|
||||
static HyperbolicArcSine Builder(Expression child);
|
||||
static HyperbolicArcSine Builder(Expression child) { return TreeHandle::FixedArityBuilder<HyperbolicArcSine, HyperbolicArcSineNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("asinh", 1, &UntypedBuilderOneChild<HyperbolicArcSine>);
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
class HyperbolicArcTangent final : public HyperbolicTrigonometricFunction {
|
||||
public:
|
||||
HyperbolicArcTangent(const HyperbolicArcTangentNode * n) : HyperbolicTrigonometricFunction(n) {}
|
||||
static HyperbolicArcTangent Builder(Expression child);
|
||||
static HyperbolicArcTangent Builder(Expression child) { return TreeHandle::FixedArityBuilder<HyperbolicArcTangent, HyperbolicArcTangentNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("atanh", 1, &UntypedBuilderOneChild<HyperbolicArcTangent>);
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
class HyperbolicCosine final : public HyperbolicTrigonometricFunction {
|
||||
public:
|
||||
HyperbolicCosine(const HyperbolicCosineNode * n) : HyperbolicTrigonometricFunction(n) {}
|
||||
static HyperbolicCosine Builder(Expression child);
|
||||
static HyperbolicCosine Builder(Expression child) { return TreeHandle::FixedArityBuilder<HyperbolicCosine, HyperbolicCosineNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("cosh", 1, &UntypedBuilderOneChild<HyperbolicCosine>);
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
class HyperbolicSine final : public HyperbolicTrigonometricFunction {
|
||||
public:
|
||||
HyperbolicSine(const HyperbolicSineNode * n) : HyperbolicTrigonometricFunction(n) {}
|
||||
static HyperbolicSine Builder(Expression child);
|
||||
static HyperbolicSine Builder(Expression child) { return TreeHandle::FixedArityBuilder<HyperbolicSine, HyperbolicSineNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sinh", 1, &UntypedBuilderOneChild<HyperbolicSine>);
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
class HyperbolicTangent final : public HyperbolicTrigonometricFunction {
|
||||
public:
|
||||
HyperbolicTangent(const HyperbolicTangentNode * n) : HyperbolicTrigonometricFunction(n) {}
|
||||
static HyperbolicTangent Builder(Expression child);
|
||||
static HyperbolicTangent Builder(Expression child) { return TreeHandle::FixedArityBuilder<HyperbolicTangent, HyperbolicTangentNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("tanh", 1, &UntypedBuilderOneChild<HyperbolicTangent>);
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
class ImaginaryPart final : public Expression {
|
||||
public:
|
||||
ImaginaryPart(const ImaginaryPartNode * n) : Expression(n) {}
|
||||
static ImaginaryPart Builder(Expression child);
|
||||
static ImaginaryPart Builder(Expression child) { return TreeHandle::FixedArityBuilder<ImaginaryPart, ImaginaryPartNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("im", 1, &UntypedBuilderOneChild<ImaginaryPart>);
|
||||
|
||||
|
||||
@@ -55,15 +55,9 @@ private:
|
||||
class Integral final : public Expression {
|
||||
public:
|
||||
Integral(const IntegralNode * n) : Expression(n) {}
|
||||
static Integral Builder(Expression child0, Symbol child1, Expression child2, Expression child3);
|
||||
static Expression UntypedBuilder(Expression children) {
|
||||
assert(children.type() == ExpressionNode::Type::Matrix);
|
||||
if (children.childAtIndex(1).type() != ExpressionNode::Type::Symbol) {
|
||||
// Second parameter must be a Symbol.
|
||||
return Expression();
|
||||
}
|
||||
return Builder(children.childAtIndex(0), children.childAtIndex(1).convert<Symbol>(), children.childAtIndex(2), children.childAtIndex(3));
|
||||
}
|
||||
static Integral Builder(Expression child0, Symbol child1, Expression child2, Expression child3) { return TreeHandle::FixedArityBuilder<Integral, IntegralNode>(ArrayBuilder<TreeHandle>(child0, child1, child2, child3).array(), 4); }
|
||||
static Expression UntypedBuilder(Expression children);
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("int", 4, &UntypedBuilder);
|
||||
|
||||
// Expression
|
||||
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
|
||||
class IntegralLayout final : public Layout {
|
||||
public:
|
||||
static IntegralLayout Builder(Layout integrand, Layout differential, Layout lowerBound, Layout upperBound);
|
||||
static IntegralLayout Builder(Layout integrand, Layout differential, Layout lowerBound, Layout upperBound) { return TreeHandle::FixedArityBuilder<IntegralLayout, IntegralLayoutNode>(ArrayBuilder<TreeHandle>(integrand, differential, lowerBound, upperBound).array(), 4); }
|
||||
IntegralLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef POINCARE_LAYOUT_REFERENCE_H
|
||||
#define POINCARE_LAYOUT_REFERENCE_H
|
||||
|
||||
#include <poincare/array_builder.h>
|
||||
#include <poincare/layout_node.h>
|
||||
#include <poincare/tree_handle.h>
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
class LeastCommonMultiple final : public Expression {
|
||||
public:
|
||||
LeastCommonMultiple(const LeastCommonMultipleNode * n) : Expression(n) {}
|
||||
static LeastCommonMultiple Builder(Expression child0, Expression child1);
|
||||
static LeastCommonMultiple Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<LeastCommonMultiple, LeastCommonMultipleNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("lcm", 2, &UntypedBuilderTwoChildren<LeastCommonMultiple>);
|
||||
|
||||
// Expression
|
||||
|
||||
@@ -35,7 +35,7 @@ protected:
|
||||
|
||||
class LeftParenthesisLayout final : public Layout {
|
||||
public:
|
||||
static LeftParenthesisLayout Builder();
|
||||
static LeftParenthesisLayout Builder() { return TreeHandle::FixedArityBuilder<LeftParenthesisLayout, LeftParenthesisLayoutNode>(); }
|
||||
LeftParenthesisLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ protected:
|
||||
|
||||
class LeftSquareBracketLayout final : public Layout {
|
||||
public:
|
||||
static LeftSquareBracketLayout Builder();
|
||||
static LeftSquareBracketLayout Builder() { return TreeHandle::FixedArityBuilder<LeftSquareBracketLayout, LeftSquareBracketLayoutNode>(); }
|
||||
LeftSquareBracketLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
class Logarithm final : public Expression {
|
||||
public:
|
||||
Logarithm(const LogarithmNode<2> * n) : Expression(n) {}
|
||||
static Logarithm Builder(Expression child0, Expression child1);
|
||||
static Logarithm Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<Logarithm, LogarithmNode<2>>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("log", 2, &UntypedBuilderTwoChildren<Logarithm>);
|
||||
|
||||
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
class CommonLogarithm : public Expression {
|
||||
public:
|
||||
CommonLogarithm(const LogarithmNode<1> * n) : Expression(n) {}
|
||||
static CommonLogarithm Builder(Expression child);
|
||||
static CommonLogarithm Builder(Expression child) { return TreeHandle::FixedArityBuilder<CommonLogarithm, LogarithmNode<1>>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("log", 1, &UntypedBuilderOneChild<CommonLogarithm>);
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class Matrix final : public Expression {
|
||||
friend class GlobalContext;
|
||||
public:
|
||||
Matrix(const MatrixNode * node) : Expression(node) {}
|
||||
static Matrix Builder();
|
||||
static Matrix Builder() { return TreeHandle::NAryBuilder<Matrix, MatrixNode>(); }
|
||||
|
||||
void setDimensions(int rows, int columns);
|
||||
int numberOfRows() const { return node()->numberOfRows(); }
|
||||
|
||||
@@ -57,7 +57,7 @@ class MatrixComplex final : public Evaluation<T> {
|
||||
friend class MatrixComplexNode<T>;
|
||||
public:
|
||||
MatrixComplex(MatrixComplexNode<T> * node) : Evaluation<T>(node) {}
|
||||
static MatrixComplex Builder();
|
||||
static MatrixComplex Builder() { return TreeHandle::NAryBuilder<MatrixComplex<T>, MatrixComplexNode<T>>(); }
|
||||
static MatrixComplex Builder(std::complex<T> * operands, int numberOfRows, int numberOfColumns);
|
||||
static MatrixComplex<T> Undefined();
|
||||
static MatrixComplex<T> createIdentity(int dim);
|
||||
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
class MatrixDimension final : public Expression {
|
||||
public:
|
||||
MatrixDimension(const MatrixDimensionNode * n) : Expression(n) {}
|
||||
static MatrixDimension Builder(Expression child);
|
||||
static MatrixDimension Builder(Expression child) { return TreeHandle::FixedArityBuilder<MatrixDimension, MatrixDimensionNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("dim", 1, &UntypedBuilderOneChild<MatrixDimension>);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ private:
|
||||
class MatrixInverse final : public Expression {
|
||||
public:
|
||||
MatrixInverse(const MatrixInverseNode * n) : Expression(n) {}
|
||||
static MatrixInverse Builder(Expression child);
|
||||
static MatrixInverse Builder(Expression child) { return TreeHandle::FixedArityBuilder<MatrixInverse, MatrixInverseNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("inverse", 1, &UntypedBuilderOneChild<MatrixInverse>);
|
||||
|
||||
|
||||
@@ -58,16 +58,8 @@ class MatrixLayout /*final*/ : public GridLayout {
|
||||
friend class MatrixLayoutNode;
|
||||
public:
|
||||
MatrixLayout(const MatrixLayoutNode * n) : GridLayout(n) {}
|
||||
static MatrixLayout Builder();
|
||||
static MatrixLayout Builder(Layout l1, Layout l2, Layout l3, Layout l4) {
|
||||
MatrixLayout m = MatrixLayout::Builder();
|
||||
m.addChildAtIndexInPlace(l1, 0, 0);
|
||||
m.addChildAtIndexInPlace(l2, 1, 1);
|
||||
m.addChildAtIndexInPlace(l3, 2, 2);
|
||||
m.addChildAtIndexInPlace(l4, 3, 3);
|
||||
m.setDimensions(2, 2);
|
||||
return m;
|
||||
}
|
||||
static MatrixLayout Builder() { return TreeHandle::NAryBuilder<MatrixLayout, MatrixLayoutNode>(); }
|
||||
static MatrixLayout Builder(Layout l1, Layout l2, Layout l3, Layout l4);
|
||||
|
||||
bool hasGreySquares() const { return node()->hasGreySquares(); }
|
||||
void addGreySquares() { node()->addGreySquares(); }
|
||||
|
||||
@@ -34,7 +34,7 @@ private:
|
||||
class MatrixTrace final : public Expression {
|
||||
public:
|
||||
MatrixTrace(const MatrixTraceNode * n) : Expression(n) {}
|
||||
static MatrixTrace Builder(Expression child);
|
||||
static MatrixTrace Builder(Expression child) { return TreeHandle::FixedArityBuilder<MatrixTrace, MatrixTraceNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("trace", 1, &UntypedBuilderOneChild<MatrixTrace>);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ private:
|
||||
class MatrixTranspose final : public Expression {
|
||||
public:
|
||||
MatrixTranspose(const MatrixTransposeNode * n) : Expression(n) {}
|
||||
static MatrixTranspose Builder(Expression child);
|
||||
static MatrixTranspose Builder(Expression child) { return TreeHandle::FixedArityBuilder<MatrixTranspose, MatrixTransposeNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("transpose", 1, &UntypedBuilderOneChild<MatrixTranspose>);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define POINCARE_MULTIPLICATION_H
|
||||
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/array_builder.h>
|
||||
#include <poincare/n_ary_expression_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -67,7 +66,7 @@ class Multiplication final : public NAryExpression {
|
||||
friend class Power;
|
||||
public:
|
||||
Multiplication(const MultiplicationNode * n) : NAryExpression(n) {}
|
||||
static Multiplication Builder();
|
||||
static Multiplication Builder() { return TreeHandle::NAryBuilder<Multiplication, MultiplicationNode>(); }
|
||||
static Multiplication Builder(Expression e1) { return Multiplication::Builder(&e1, 1); }
|
||||
static Multiplication Builder(Expression e1, Expression e2) { return Multiplication::Builder(ArrayBuilder<Expression>(e1, e2).array(), 2); }
|
||||
static Multiplication Builder(Expression e1, Expression e2, Expression e3) { return Multiplication::Builder(ArrayBuilder<Expression>(e1, e2, e3).array(), 3); }
|
||||
@@ -81,7 +80,7 @@ public:
|
||||
Expression denominator(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const;
|
||||
private:
|
||||
// Constructors
|
||||
static Multiplication Builder(Expression * children, size_t numberOfChildren);
|
||||
static Multiplication Builder(Expression * children, size_t numberOfChildren) { return TreeHandle::NAryBuilder<Multiplication, MultiplicationNode>(children, numberOfChildren); }
|
||||
|
||||
// Simplification
|
||||
Expression privateShallowReduce(Context& context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target, bool expand, bool canBeInterrupted);
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
class NaperianLogarithm final : public Expression {
|
||||
public:
|
||||
NaperianLogarithm(const NaperianLogarithmNode * n) : Expression(n) {}
|
||||
static NaperianLogarithm Builder(Expression child);
|
||||
static NaperianLogarithm Builder(Expression child) { return TreeHandle::FixedArityBuilder<NaperianLogarithm, NaperianLogarithmNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("ln", 1, &UntypedBuilderOneChild<NaperianLogarithm>);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
class NthRoot final : public Expression {
|
||||
public:
|
||||
NthRoot(const NthRootNode * n) : Expression(n) {}
|
||||
static NthRoot Builder(Expression child0, Expression child1);
|
||||
static NthRoot Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<NthRoot, NthRootNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("root", 2, &UntypedBuilderTwoChildren<NthRoot>);
|
||||
|
||||
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
|
||||
|
||||
@@ -47,8 +47,8 @@ public:
|
||||
class Opposite final : public Expression {
|
||||
public:
|
||||
Opposite(const OppositeNode * n) : Expression(n) {}
|
||||
static Opposite Builder();
|
||||
static Opposite Builder(Expression child);
|
||||
static Opposite Builder() { return TreeHandle::FixedArityBuilder<Opposite, OppositeNode>(); }
|
||||
static Opposite Builder(Expression child) { return TreeHandle::FixedArityBuilder<Opposite, OppositeNode>(&child, 1); }
|
||||
|
||||
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
class Parenthesis final : public Expression {
|
||||
public:
|
||||
Parenthesis(const ParenthesisNode * n) : Expression(n) {}
|
||||
static Parenthesis Builder(Expression child);
|
||||
static Parenthesis Builder(Expression child) { return TreeHandle::FixedArityBuilder<Parenthesis, ParenthesisNode>(&child, 1); }
|
||||
// Expression
|
||||
Expression shallowReduce();
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
class PermuteCoefficient final : public Expression {
|
||||
public:
|
||||
PermuteCoefficient(const PermuteCoefficientNode * n) : Expression(n) {}
|
||||
static PermuteCoefficient Builder(Expression child0, Expression child1);
|
||||
static PermuteCoefficient Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<PermuteCoefficient, PermuteCoefficientNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("permute", 2, &UntypedBuilderTwoChildren<PermuteCoefficient>);
|
||||
|
||||
// Expression
|
||||
|
||||
@@ -67,7 +67,7 @@ class Power final : public Expression {
|
||||
friend class Round;
|
||||
public:
|
||||
Power(const PowerNode * n) : Expression(n) {}
|
||||
static Power Builder(Expression base, Expression exponent);
|
||||
static Power Builder(Expression base, Expression exponent) { return TreeHandle::FixedArityBuilder<Power, PowerNode>(ArrayBuilder<TreeHandle>(base, exponent).array(), 2); }
|
||||
|
||||
Expression setSign(ExpressionNode::Sign s, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
|
||||
int getPolynomialCoefficients(Context & context, const char * symbolName, Expression coefficients[]) const;
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
class PredictionInterval final : public Expression {
|
||||
public:
|
||||
PredictionInterval(const PredictionIntervalNode * n) : Expression(n) {}
|
||||
static PredictionInterval Builder(Expression child0, Expression child1);
|
||||
static PredictionInterval Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<PredictionInterval, PredictionIntervalNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("prediction95", 2, &UntypedBuilderTwoChildren<PredictionInterval>);
|
||||
|
||||
// Expression
|
||||
|
||||
@@ -35,15 +35,9 @@ class Product final : public Expression {
|
||||
friend class ProductNode;
|
||||
public:
|
||||
Product(const ProductNode * n) : Expression(n) {}
|
||||
static Product Builder(Expression child0, Symbol child1, Expression child2, Expression child3);
|
||||
static Expression UntypedBuilder(Expression children) {
|
||||
assert(children.type() == ExpressionNode::Type::Matrix);
|
||||
if (children.childAtIndex(1).type() != ExpressionNode::Type::Symbol) {
|
||||
// Second parameter must be a Symbol.
|
||||
return Expression();
|
||||
}
|
||||
return Builder(children.childAtIndex(0), children.childAtIndex(1).convert<Symbol>(), children.childAtIndex(2), children.childAtIndex(3));
|
||||
}
|
||||
static Product Builder(Expression child0, Symbol child1, Expression child2, Expression child3) { return TreeHandle::FixedArityBuilder<Product, ProductNode>(ArrayBuilder<TreeHandle>(child0, child1, child2, child3).array(), 4); }
|
||||
static Expression UntypedBuilder(Expression children);
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("product", 4, &UntypedBuilder);
|
||||
};
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ private:
|
||||
|
||||
class ProductLayout final : public Layout {
|
||||
public:
|
||||
static ProductLayout Builder(Layout argument, Layout variable, Layout lowerB, Layout upperB);
|
||||
static ProductLayout Builder(Layout argument, Layout variable, Layout lowerB, Layout upperB) { return TreeHandle::FixedArityBuilder<ProductLayout,ProductLayoutNode>(ArrayBuilder<TreeHandle>(argument, variable, lowerB, upperB).array(), 4); }
|
||||
ProductLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class Randint final : public Expression {
|
||||
friend class RandintNode;
|
||||
public:
|
||||
Randint(const RandintNode * n) : Expression(n) {}
|
||||
static Randint Builder(Expression child0, Expression child1);
|
||||
static Randint Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<Randint, RandintNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("randint", 2, &UntypedBuilderTwoChildren<Randint>);
|
||||
};
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class Random final : public Expression {
|
||||
friend class RandomNode;
|
||||
public:
|
||||
Random(const RandomNode * n) : Expression(n) {}
|
||||
static Random Builder();
|
||||
static Random Builder() { return TreeHandle::FixedArityBuilder<Random, RandomNode>(); }
|
||||
static Expression UntypedBuilder(Expression children) { assert(children.type() == ExpressionNode::Type::Matrix); return Builder(); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("random", 0, &UntypedBuilder);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
class RealPart final : public Expression {
|
||||
public:
|
||||
RealPart(const RealPartNode * n) : Expression(n) {}
|
||||
static RealPart Builder(Expression child);
|
||||
static RealPart Builder(Expression child) { return TreeHandle::FixedArityBuilder<RealPart, RealPartNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("re", 1, &UntypedBuilderOneChild<RealPart>);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ protected:
|
||||
|
||||
class RightParenthesisLayout final : public Layout {
|
||||
public:
|
||||
static RightParenthesisLayout Builder();
|
||||
static RightParenthesisLayout Builder() { return TreeHandle::FixedArityBuilder<RightParenthesisLayout, RightParenthesisLayoutNode>(); }
|
||||
RightParenthesisLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ protected:
|
||||
|
||||
class RightSquareBracketLayout final : public Layout {
|
||||
public:
|
||||
static RightSquareBracketLayout Builder();
|
||||
static RightSquareBracketLayout Builder() { return TreeHandle::FixedArityBuilder<RightSquareBracketLayout, RightSquareBracketLayoutNode>(); }
|
||||
RightSquareBracketLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
class Round final : public Expression {
|
||||
public:
|
||||
Round(const RoundNode * n) : Expression(n) {}
|
||||
static Round Builder(Expression child0, Expression child1);
|
||||
static Round Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<Round, RoundNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("round", 2, &UntypedBuilderTwoChildren<Round>);
|
||||
|
||||
Expression shallowReduce();
|
||||
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
class SignFunction final : public Expression {
|
||||
public:
|
||||
SignFunction(const SignFunctionNode * n) : Expression(n) {}
|
||||
static SignFunction Builder(Expression child);
|
||||
static SignFunction Builder(Expression child) { return TreeHandle::FixedArityBuilder<SignFunction, SignFunctionNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sign", 1, &UntypedBuilderOneChild<SignFunction>);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
class Sine final : public Expression {
|
||||
public:
|
||||
Sine(const SineNode * n) : Expression(n) {}
|
||||
static Sine Builder(Expression child);
|
||||
static Sine Builder(Expression child) { return TreeHandle::FixedArityBuilder<Sine, SineNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sin", 1, &UntypedBuilderOneChild<Sine>);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
class SquareRoot final : public Expression {
|
||||
public:
|
||||
SquareRoot(const SquareRootNode * n) : Expression(n) {}
|
||||
static SquareRoot Builder(Expression child);
|
||||
static SquareRoot Builder(Expression child) { return TreeHandle::FixedArityBuilder<SquareRoot, SquareRootNode>(&child, 1); }
|
||||
|
||||
static_assert('\x91' == Ion::Charset::Root, "Charset error");
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("\x91", 1, &UntypedBuilderOneChild<SquareRoot>);
|
||||
|
||||
@@ -40,7 +40,7 @@ class Store final : public Expression {
|
||||
friend class StoreNode;
|
||||
public:
|
||||
Store(const StoreNode * n) : Expression(n) {}
|
||||
static Store Builder(Expression value, SymbolAbstract symbol);
|
||||
static Store Builder(Expression value, SymbolAbstract symbol) { return TreeHandle::FixedArityBuilder<Store, StoreNode>(ArrayBuilder<TreeHandle>(value, symbol).array(), 2); }
|
||||
|
||||
// Store
|
||||
const SymbolAbstract symbol() const {
|
||||
|
||||
@@ -55,8 +55,8 @@ private:
|
||||
class Subtraction final : public Expression {
|
||||
public:
|
||||
Subtraction(const SubtractionNode * n) : Expression(n) {}
|
||||
static Subtraction Builder();
|
||||
static Subtraction Builder(Expression child0, Expression child1);
|
||||
static Subtraction Builder() { return TreeHandle::FixedArityBuilder<Subtraction, SubtractionNode>(); }
|
||||
static Subtraction Builder(Expression child0, Expression child1) { return TreeHandle::FixedArityBuilder<Subtraction, SubtractionNode>(ArrayBuilder<TreeHandle>(child0, child1).array(), 2); }
|
||||
|
||||
// Expression
|
||||
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
|
||||
|
||||
@@ -35,15 +35,9 @@ class Sum final : public Expression {
|
||||
friend class SumNode;
|
||||
public:
|
||||
Sum(const SumNode * n) : Expression(n) {}
|
||||
static Sum Builder(Expression child0, Symbol child1, Expression child2, Expression child3);
|
||||
static Expression UntypedBuilder(Expression children) {
|
||||
assert(children.type() == ExpressionNode::Type::Matrix);
|
||||
if (children.childAtIndex(1).type() != ExpressionNode::Type::Symbol) {
|
||||
// Second parameter must be a Symbol.
|
||||
return Expression();
|
||||
}
|
||||
return Builder(children.childAtIndex(0), children.childAtIndex(1).convert<Symbol>(), children.childAtIndex(2), children.childAtIndex(3));
|
||||
}
|
||||
static Sum Builder(Expression child0, Symbol child1, Expression child2, Expression child3) { return TreeHandle::FixedArityBuilder<Sum, SumNode>(ArrayBuilder<TreeHandle>(child0, child1, child2, child3).array(), 4); }
|
||||
static Expression UntypedBuilder(Expression children);
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sum", 4, &UntypedBuilder);
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ private:
|
||||
|
||||
class SumLayout final : public Layout {
|
||||
public:
|
||||
static SumLayout Builder(Layout argument, Layout variable, Layout lowerB, Layout upperB);
|
||||
static SumLayout Builder(Layout argument, Layout variable, Layout lowerB, Layout upperB) { return TreeHandle::FixedArityBuilder<SumLayout,SumLayoutNode>(ArrayBuilder<TreeHandle>(argument, variable, lowerB, upperB).array(), 4); }
|
||||
SumLayout() = delete;
|
||||
};
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ private:
|
||||
class Tangent final : public Expression {
|
||||
public:
|
||||
Tangent(const TangentNode * n) : Expression(n) {}
|
||||
static Tangent Builder(Expression child);
|
||||
static Tangent Builder(Expression child) { return TreeHandle::FixedArityBuilder<Tangent, TangentNode>(&child, 1); }
|
||||
|
||||
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("tan", 1, &UntypedBuilderOneChild<Tangent>);
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Poincare {
|
||||
* equivalent to Logarithm l = Logarithm(clone())). */
|
||||
|
||||
class TreeHandle {
|
||||
template<class T>
|
||||
friend class ArrayBuilder;
|
||||
friend class TreeNode;
|
||||
friend class TreePool;
|
||||
public:
|
||||
@@ -108,8 +110,14 @@ protected:
|
||||
node()->retain();
|
||||
}
|
||||
}
|
||||
|
||||
// WARNING: if the children table is the result of a cast, the object downcasted has to be the same size as a TreeHandle.
|
||||
static TreeHandle BuildWithBasicChildren(TreeNode * node, TreeHandle * children = nullptr, int numberOfChildren = 0);
|
||||
template <class T, class U>
|
||||
static T NAryBuilder(TreeHandle * children = nullptr, size_t numberOfChildren = 0);
|
||||
template <class T, class U>
|
||||
static T FixedArityBuilder(TreeHandle * children = nullptr, size_t numberOfChildren = 0);
|
||||
|
||||
static TreeHandle BuildWithGhostChildren(TreeNode * node);
|
||||
|
||||
void setIdentifierAndRetain(int newId);
|
||||
void setTo(const TreeHandle & tr);
|
||||
@@ -127,6 +135,9 @@ protected:
|
||||
int m_identifier;
|
||||
|
||||
private:
|
||||
template <class U>
|
||||
static TreeHandle Builder();
|
||||
|
||||
void detachFromParent();
|
||||
// Add ghost children on layout construction
|
||||
void buildGhostChildren();
|
||||
|
||||
@@ -42,7 +42,7 @@ protected:
|
||||
class Undefined final : public Number {
|
||||
public:
|
||||
Undefined(const UndefinedNode * n) : Number(n) {}
|
||||
static Undefined Builder();
|
||||
static Undefined Builder() { return TreeHandle::FixedArityBuilder<Undefined, UndefinedNode>(); }
|
||||
static const char * Name() {
|
||||
return "undef";
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ private:
|
||||
|
||||
class Unreal final : public Number {
|
||||
public:
|
||||
static Unreal Builder();
|
||||
static Unreal Builder() { return TreeHandle::FixedArityBuilder<Unreal, UnrealNode>(); }
|
||||
Unreal() = delete;
|
||||
static const char * Name() {
|
||||
return "unreal";
|
||||
|
||||
@@ -31,12 +31,6 @@ Expression AbsoluteValueNode::shallowReduce(Context & context, Preferences::Comp
|
||||
return AbsoluteValue(this).shallowReduce(context, complexFormat, angleUnit, target);
|
||||
}
|
||||
|
||||
AbsoluteValue AbsoluteValue::Builder(Expression child) {
|
||||
void * bufferNode = TreePool::sharedPool()->alloc(sizeof(AbsoluteValueNode));
|
||||
AbsoluteValueNode * node = new (bufferNode) AbsoluteValueNode();
|
||||
TreeHandle h = TreeHandle::BuildWithBasicChildren(node, &child, 1);
|
||||
return static_cast<AbsoluteValue &>(h);
|
||||
}
|
||||
|
||||
Expression AbsoluteValue::setSign(ExpressionNode::Sign s, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) {
|
||||
assert(s == ExpressionNode::Sign::Positive);
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#include <poincare/absolute_value_layout.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
AbsoluteValueLayout AbsoluteValueLayout::Builder(Layout child) {
|
||||
void * bufferNode = TreePool::sharedPool()->alloc(sizeof(AbsoluteValueLayoutNode));
|
||||
AbsoluteValueLayoutNode * node = new (bufferNode) AbsoluteValueLayoutNode();
|
||||
TreeHandle h = TreeHandle::BuildWithBasicChildren(node, &child, 1);
|
||||
return static_cast<AbsoluteValueLayout &>(h);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,21 +87,6 @@ int Addition::getPolynomialCoefficients(Context & context, const char * symbolNa
|
||||
return deg;
|
||||
}
|
||||
|
||||
Addition Addition::Builder() {
|
||||
void * bufferNode = TreePool::sharedPool()->alloc(sizeof(AdditionNode));
|
||||
AdditionNode * node = new (bufferNode) AdditionNode();
|
||||
TreeHandle h = TreeHandle::BuildWithBasicChildren(node);
|
||||
return static_cast<Addition &>(h);
|
||||
}
|
||||
|
||||
Addition Addition::Builder(Expression * children, size_t numberOfChildren) {
|
||||
Addition a = Addition::Builder();
|
||||
for (size_t i = 0; i < numberOfChildren; i++) {
|
||||
a.addChildAtIndexInPlace(children[i], i, i);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
Expression Addition::shallowBeautify(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
|
||||
/* Beautifying AdditionNode essentially consists in adding Subtractions if
|
||||
* needed.
|
||||
|
||||
@@ -48,12 +48,6 @@ Complex<T> ArcCosineNode::computeOnComplex(const std::complex<T> c, Preferences:
|
||||
return Complex<T>::Builder(Trigonometry::ConvertRadianToAngleUnit(result, angleUnit));
|
||||
}
|
||||
|
||||
ArcCosine ArcCosine::Builder(Expression child) {
|
||||
void * bufferNode = TreePool::sharedPool()->alloc(sizeof(ArcCosineNode));
|
||||
ArcCosineNode * node = new (bufferNode) ArcCosineNode();
|
||||
TreeHandle h = TreeHandle::BuildWithBasicChildren(node, &child, 1);
|
||||
return static_cast<ArcCosine &>(h);
|
||||
}
|
||||
|
||||
Expression ArcCosine::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
|
||||
{
|
||||
|
||||
@@ -48,12 +48,6 @@ Complex<T> ArcSineNode::computeOnComplex(const std::complex<T> c, Preferences::C
|
||||
return Complex<T>::Builder(Trigonometry::ConvertRadianToAngleUnit(result, angleUnit));
|
||||
}
|
||||
|
||||
ArcSine ArcSine::Builder(Expression child) {
|
||||
void * bufferNode = TreePool::sharedPool()->alloc(sizeof(ArcSineNode));
|
||||
ArcSineNode * node = new (bufferNode) ArcSineNode();
|
||||
TreeHandle h = TreeHandle::BuildWithBasicChildren(node, &child, 1);
|
||||
return static_cast<ArcSine &>(h);
|
||||
}
|
||||
|
||||
Expression ArcSine::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
|
||||
{
|
||||
|
||||
@@ -48,12 +48,6 @@ Expression ArcTangentNode::shallowReduce(Context & context, Preferences::Complex
|
||||
return ArcTangent(this).shallowReduce(context, complexFormat, angleUnit, target);
|
||||
}
|
||||
|
||||
ArcTangent ArcTangent::Builder(Expression child) {
|
||||
void * bufferNode = TreePool::sharedPool()->alloc(sizeof(ArcTangentNode));
|
||||
ArcTangentNode * node = new (bufferNode) ArcTangentNode();
|
||||
TreeHandle h = TreeHandle::BuildWithBasicChildren(node, &child, 1);
|
||||
return static_cast<ArcTangent &>(h);
|
||||
}
|
||||
|
||||
Expression ArcTangent::shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target) {
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <poincare/binomial_coefficient.h>
|
||||
#include <poincare/array_builder.h>
|
||||
#include <poincare/binomial_coefficient_layout.h>
|
||||
#include <poincare/rational.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
@@ -54,12 +53,6 @@ T BinomialCoefficientNode::compute(T k, T n) {
|
||||
return std::round(result);
|
||||
}
|
||||
|
||||
BinomialCoefficient BinomialCoefficient::Builder(Expression child0, Expression child1) {
|
||||
void * bufferNode = TreePool::sharedPool()->alloc(sizeof(BinomialCoefficientNode));
|
||||
BinomialCoefficientNode * node = new (bufferNode) BinomialCoefficientNode();
|
||||
TreeHandle h = TreeHandle::BuildWithBasicChildren(node, ArrayBuilder<Expression>(child0, child1).array(), 2);
|
||||
return static_cast<BinomialCoefficient &>(h);
|
||||
}
|
||||
|
||||
Expression BinomialCoefficient::shallowReduce() {
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user