[poincare] New static NumberOfChildren() method in Expression subclasses

This commit is contained in:
Ruben Dashyan
2018-10-19 18:06:55 +02:00
committed by Émilie Feral
parent e2e5fd6551
commit cda6f522f0
83 changed files with 165 additions and 40 deletions

View File

@@ -10,7 +10,7 @@ class AbsoluteValueNode final : public ExpressionNode {
public:
// TreeNode
size_t size() const override { return sizeof(AbsoluteValueNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "AbsoluteValue";
@@ -50,6 +50,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "abs"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
private:

View File

@@ -12,7 +12,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(ArcCosineNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "ArcCosine";
@@ -46,6 +46,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "acos"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -12,7 +12,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(ArcSineNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "ArcSine";
@@ -45,6 +45,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "asin"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -12,7 +12,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(ArcTangentNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "ArcTangent";
@@ -45,6 +45,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "atan"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(BinomialCoefficientNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "BinomialCoefficient";
@@ -44,6 +44,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "binomial"; }
static const int NumberOfChildren() { return 2; }
// Expression
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(CeilingNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Ceiling";
@@ -44,6 +44,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "ceil"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(ComplexArgumentNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "ComplexArgument";
@@ -44,6 +44,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "arg"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(ConfidenceIntervalNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "ConfidenceInterval";
@@ -50,6 +50,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "confidence"; }
static const int NumberOfChildren() { return 2; }
// Expression
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
@@ -66,6 +67,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "prediction"; }
static const int NumberOfChildren() { return 2; }
};
}

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(ConjugateNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Conjugate";
@@ -44,11 +44,11 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "conj"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};
}
#endif

View File

@@ -12,7 +12,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(CosineNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Cosine";
@@ -48,6 +48,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "cos"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(DerivativeNode); }
int numberOfChildren() const override { return 3; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Derivative";
@@ -53,6 +53,7 @@ public:
replaceChildAtIndexInPlace(2, child3);
}
static const char * Name() { return "diff"; }
static const int NumberOfChildren() { return 3; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(DeterminantNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Determinant";
@@ -40,6 +40,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "det"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(DivisionQuotientNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "DivisionQuotient";
@@ -40,6 +40,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "quo"; }
static const int NumberOfChildren() { return 2; }
// Expression
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(DivisionRemainderNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "DivisionRemainder";
@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "rem"; }
static const int NumberOfChildren() { return 2; }
// Expression
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);

View File

@@ -24,6 +24,7 @@ class Expression : public TreeHandle {
friend class Arithmetic;
friend class BinomialCoefficient;
friend class Ceiling;
friend class CommonLogarithm;
friend class ComplexArgument;
friend class ConfidenceInterval;
friend class Conjugate;

View File

@@ -12,7 +12,7 @@ class FactorNode /*final*/ : public ExpressionNode {
public:
// TreeNode
size_t size() const override { return sizeof(FactorNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Factor";
@@ -42,6 +42,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "factor"; }
static const int NumberOfChildren() { return 1; }
Expression shallowBeautify(Context & context, Preferences::AngleUnit angleUnit);
Multiplication createMultiplicationOfIntegerPrimeDecomposition(Integer i, Context & context, Preferences::AngleUnit angleUnit) const;

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(FloorNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Floor";
@@ -44,6 +44,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "floor"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(FracPartNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "FracPart";
@@ -44,6 +44,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "frac"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(GreatCommonDivisorNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "GreatCommonDivisor";
@@ -40,6 +40,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "gcd"; }
static const int NumberOfChildren() { return 2; }
// Expression
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);

View File

@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "acosh"; }
static const int NumberOfChildren() { return 1; }
};
}

View File

@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "asinh"; }
static const int NumberOfChildren() { return 1; }
};
}

View File

@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "atanh"; }
static const int NumberOfChildren() { return 1; }
};
}

View File

@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "cosh"; }
static const int NumberOfChildren() { return 1; }
};
}

View File

@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "sinh"; }
static const int NumberOfChildren() { return 1; }
};
}

View File

@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "tanh"; }
static const int NumberOfChildren() { return 1; }
};
}

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(ImaginaryPartNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "ImaginaryPart";
@@ -46,6 +46,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "im"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(IntegralNode); }
int numberOfChildren() const override { return 4; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Integral";
@@ -57,6 +57,7 @@ public:
replaceChildAtIndexInPlace(3, child4);
}
static const char * Name() { return "int"; }
static const int NumberOfChildren() { return 4; }
// Expression
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(LeastCommonMultipleNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "LeastCommonMultiple";
@@ -39,6 +39,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "lcm"; }
static const int NumberOfChildren() { return 2; }
// Expression
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);

View File

@@ -13,7 +13,7 @@ class LogarithmNode final : public ExpressionNode {
public:
// TreeNode
size_t size() const override { return sizeof(LogarithmNode); }
int numberOfChildren() const override { assert(T == 1 || T == 2); return T; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Logarithm";
@@ -49,6 +49,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "log"; }
static const int NumberOfChildren() { return 2; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
Expression shallowBeautify(Context & context, Preferences::AngleUnit angleUnit);
@@ -67,6 +68,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "log"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(MatrixDimensionNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "MatrixDimension";
@@ -39,6 +39,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "dim"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(MatrixInverseNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "MatrixInverse";
@@ -39,6 +39,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "inverse"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(MatrixTraceNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "MatrixTrace";
@@ -39,6 +39,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "trace"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(MatrixTransposeNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "MatrixTranspose";
@@ -39,6 +39,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "transpose"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -10,7 +10,7 @@ class NaperianLogarithmNode final : public ExpressionNode {
public:
// TreeNode
size_t size() const override { return sizeof(NaperianLogarithmNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "NaperianLogarithm";
@@ -49,6 +49,8 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "ln"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -12,7 +12,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(NthRootNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "NthRoot";
@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "root"; }
static const int NumberOfChildren() { return 2; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(PermuteCoefficientNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "PermuteCoefficient";
@@ -43,6 +43,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "permute"; }
static const int NumberOfChildren() { return 2; }
// Expression
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(PredictionIntervalNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "PredictionInterval";
@@ -43,6 +43,7 @@ public:
replaceChildAtIndexInPlace(1, child2);
}
static const char * Name() { return "prediction95"; }
static const int NumberOfChildren() { return 2; }
// Expression
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);

View File

@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(3, operand3);
}
static const char * Name() { return "product"; }
static const int NumberOfChildren() { return 3; }
};
}

View File

@@ -10,7 +10,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(RandintNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Randint";
@@ -39,6 +39,7 @@ public:
Randint();
Randint(const RandintNode * n) : Expression(n) {}
static const char * Name() { return "randint"; }
static const int NumberOfChildren() { return 2; }
};
}

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(RandomNode); }
int numberOfChildren() const override { return 0; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Random";
@@ -42,6 +42,7 @@ public:
Random();
Random(const RandomNode * n) : Expression(n) {}
static const char * Name() { return "random"; }
static const int NumberOfChildren() { return 0; }
template<typename T> static T random();
private:

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(RealPartNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "RealPart";
@@ -46,6 +46,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "re"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(RoundNode); }
int numberOfChildren() const override { return 2; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Round";
@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(1, operand1);
}
static const char * Name() { return "round"; }
static const int NumberOfChildren() { return 2; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -12,7 +12,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(SineNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Sine";
@@ -50,6 +50,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "sin"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -14,7 +14,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(SquareRootNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "SquareRoot";
@@ -49,6 +49,7 @@ public:
constexpr static char k_name[2] = {Ion::Charset::Root, 0};
return k_name;
}
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -41,6 +41,7 @@ public:
replaceChildAtIndexInPlace(3, operand3);
}
static const char * Name() { return "sum"; }
static const int NumberOfChildren() { return 3; }
};
}

View File

@@ -11,7 +11,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(TangentNode); }
int numberOfChildren() const override { return 1; }
int numberOfChildren() const override;
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "Tangent";
@@ -48,6 +48,7 @@ public:
replaceChildAtIndexInPlace(0, operand);
}
static const char * Name() { return "tan"; }
static const int NumberOfChildren() { return 1; }
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
};

View File

@@ -8,6 +8,8 @@
namespace Poincare {
int AbsoluteValueNode::numberOfChildren() const { return AbsoluteValue::NumberOfChildren(); }
Expression AbsoluteValueNode::setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) {
return AbsoluteValue(this).setSign(s, context, angleUnit);
}

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int ArcCosineNode::numberOfChildren() const { return ArcCosine::NumberOfChildren(); }
Layout ArcCosineNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(ArcCosine(this), floatDisplayMode, numberOfSignificantDigits, ArcCosine::Name());
}

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int ArcSineNode::numberOfChildren() const { return ArcSine::NumberOfChildren(); }
Layout ArcSineNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(ArcSine(this), floatDisplayMode, numberOfSignificantDigits, ArcSine::Name());
}

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int ArcTangentNode::numberOfChildren() const { return ArcTangent::NumberOfChildren(); }
Layout ArcTangentNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(ArcTangent(this), floatDisplayMode, numberOfSignificantDigits, ArcTangent::Name());
}

View File

@@ -10,6 +10,8 @@
namespace Poincare {
int BinomialCoefficientNode::numberOfChildren() const { return BinomialCoefficient::NumberOfChildren(); }
Expression BinomialCoefficientNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols) {
return BinomialCoefficient(this).shallowReduce(context, angleUnit, replaceSymbols);
}

View File

@@ -11,6 +11,8 @@
namespace Poincare {
int CeilingNode::numberOfChildren() const { return Ceiling::NumberOfChildren(); }
Layout CeilingNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return CeilingLayout(childAtIndex(0)->createLayout(floatDisplayMode, numberOfSignificantDigits));
}

View File

@@ -9,6 +9,8 @@ extern "C" {
namespace Poincare {
int ComplexArgumentNode::numberOfChildren() const { return ComplexArgument::NumberOfChildren(); }
Layout ComplexArgumentNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(ComplexArgument(this), floatDisplayMode, numberOfSignificantDigits, ComplexArgument::Name());
}
@@ -44,7 +46,5 @@ Expression ComplexArgument::shallowReduce(Context & context, Preferences::AngleU
return *this;
}
}

View File

@@ -11,6 +11,8 @@
namespace Poincare {
int ConfidenceIntervalNode::numberOfChildren() const { return ConfidenceInterval::NumberOfChildren(); }
Layout ConfidenceIntervalNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(ConfidenceInterval(this), floatDisplayMode, numberOfSignificantDigits, ConfidenceInterval::Name());
}

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int ConjugateNode::numberOfChildren() const { return Conjugate::NumberOfChildren(); }
Layout ConjugateNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return ConjugateLayout(childAtIndex(0)->createLayout(floatDisplayMode, numberOfSignificantDigits));
}

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int CosineNode::numberOfChildren() const { return Cosine::NumberOfChildren(); }
float CosineNode::characteristicXRange(Context & context, Preferences::AngleUnit angleUnit) const {
return Trigonometry::characteristicXRange(Cosine(this), context, angleUnit);
}

View File

@@ -10,6 +10,8 @@
namespace Poincare {
int DerivativeNode::numberOfChildren() const { return Derivative::NumberOfChildren(); }
int DerivativeNode::polynomialDegree(Context & context, const char * symbolName) const {
if (childAtIndex(0)->polynomialDegree(context, symbolName) == 0
&& childAtIndex(1)->polynomialDegree(context, symbolName) == 0

View File

@@ -9,6 +9,8 @@ extern "C" {
namespace Poincare {
int DeterminantNode::numberOfChildren() const { return Determinant::NumberOfChildren(); }
Layout DeterminantNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(Determinant(this), floatDisplayMode, numberOfSignificantDigits, Determinant::Name());
}

View File

@@ -8,6 +8,8 @@
namespace Poincare {
int DivisionQuotientNode::numberOfChildren() const { return DivisionQuotient::NumberOfChildren(); }
Expression DivisionQuotientNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols) {
return DivisionQuotient(this).shallowReduce(context, angleUnit, replaceSymbols);
}

View File

@@ -8,6 +8,8 @@
namespace Poincare {
int DivisionRemainderNode::numberOfChildren() const { return DivisionRemainder::NumberOfChildren(); }
Layout DivisionRemainderNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(DivisionRemainder(this), floatDisplayMode, numberOfSignificantDigits, DivisionRemainder::Name());
}

View File

@@ -14,6 +14,8 @@ extern "C" {
namespace Poincare {
int FactorNode::numberOfChildren() const { return Factor::NumberOfChildren(); }
Layout FactorNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(Factor(this), floatDisplayMode, numberOfSignificantDigits, Factor::Name());
}

View File

@@ -11,6 +11,8 @@
namespace Poincare {
int FloorNode::numberOfChildren() const { return Floor::NumberOfChildren(); }
Layout FloorNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return FloorLayout(childAtIndex(0)->createLayout(floatDisplayMode, numberOfSignificantDigits));
}

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int FracPartNode::numberOfChildren() const { return FracPart::NumberOfChildren(); }
Layout FracPartNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(FracPart(this), floatDisplayMode, numberOfSignificantDigits, FracPart::Name());
}

View File

@@ -8,6 +8,8 @@
namespace Poincare {
int GreatCommonDivisorNode::numberOfChildren() const { return GreatCommonDivisor::NumberOfChildren(); }
Layout GreatCommonDivisorNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(GreatCommonDivisor(this), floatDisplayMode, numberOfSignificantDigits, GreatCommonDivisor::Name());
}

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int ImaginaryPartNode::numberOfChildren() const { return ImaginaryPart::NumberOfChildren(); }
Layout ImaginaryPartNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(ImaginaryPart(this), floatDisplayMode, numberOfSignificantDigits, ImaginaryPart::Name());
}

View File

@@ -10,6 +10,8 @@
namespace Poincare {
int IntegralNode::numberOfChildren() const { return Integral::NumberOfChildren(); }
int IntegralNode::polynomialDegree(Context & context, const char * symbolName) const {
if (childAtIndex(0)->polynomialDegree(context, symbolName) == 0
&& childAtIndex(1)->polynomialDegree(context, symbolName) == 0

View File

@@ -9,6 +9,8 @@
namespace Poincare {
int LeastCommonMultipleNode::numberOfChildren() const { return LeastCommonMultiple::NumberOfChildren(); }
Layout LeastCommonMultipleNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(LeastCommonMultiple(this), floatDisplayMode, numberOfSignificantDigits, LeastCommonMultiple::Name());
}

View File

@@ -20,6 +20,12 @@
namespace Poincare {
template<>
int LogarithmNode<1>::numberOfChildren() const { return CommonLogarithm::NumberOfChildren(); }
template<>
int LogarithmNode<2>::numberOfChildren() const { return Logarithm::NumberOfChildren(); }
template<>
Layout LogarithmNode<1>::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, CommonLogarithm::Name());

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int MatrixDimensionNode::numberOfChildren() const { return MatrixDimension::NumberOfChildren(); }
Expression MatrixDimensionNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols) {
return MatrixDimension(this).shallowReduce(context, angleUnit, replaceSymbols);
}

View File

@@ -10,6 +10,8 @@
namespace Poincare {
int MatrixInverseNode::numberOfChildren() const { return MatrixInverse::NumberOfChildren(); }
Expression MatrixInverseNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols) {
return MatrixInverse(this).shallowReduce(context, angleUnit, replaceSymbols);
}

View File

@@ -9,6 +9,8 @@
namespace Poincare {
int MatrixTraceNode::numberOfChildren() const { return MatrixTrace::NumberOfChildren(); }
Expression MatrixTraceNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols) {
return MatrixTrace(this).shallowReduce(context, angleUnit, replaceSymbols);
}

View File

@@ -7,6 +7,9 @@
#include <cmath>
namespace Poincare {
int MatrixTransposeNode::numberOfChildren() const { return MatrixTranspose::NumberOfChildren(); }
Expression MatrixTransposeNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols) {
return MatrixTranspose(this).shallowReduce(context, angleUnit, replaceSymbols);
}

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int NaperianLogarithmNode::numberOfChildren() const { return NaperianLogarithm::NumberOfChildren(); }
Layout NaperianLogarithmNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, NaperianLogarithm::Name());
}

View File

@@ -10,6 +10,8 @@
namespace Poincare {
int NthRootNode::numberOfChildren() const { return NthRoot::NumberOfChildren(); }
Layout NthRootNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return NthRootLayout(
childAtIndex(0)->createLayout(floatDisplayMode, numberOfSignificantDigits),

View File

@@ -11,6 +11,8 @@ extern "C" {
namespace Poincare {
int PermuteCoefficientNode::numberOfChildren() const { return PermuteCoefficient::NumberOfChildren(); }
Layout PermuteCoefficientNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(PermuteCoefficient(this), floatDisplayMode, numberOfSignificantDigits, PermuteCoefficient::Name());
}

View File

@@ -14,6 +14,8 @@ extern "C" {
namespace Poincare {
int PredictionIntervalNode::numberOfChildren() const { return PredictionInterval::NumberOfChildren(); }
Layout PredictionIntervalNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(PredictionInterval(this), floatDisplayMode, numberOfSignificantDigits, PredictionInterval::Name());
}

View File

@@ -12,6 +12,8 @@ extern "C" {
namespace Poincare {
int RandintNode::numberOfChildren() const { return Randint::NumberOfChildren(); }
Layout RandintNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(Randint(this), floatDisplayMode, numberOfSignificantDigits, Randint::Name());
}

View File

@@ -8,6 +8,8 @@
namespace Poincare {
int RandomNode::numberOfChildren() const { return Random::NumberOfChildren(); }
Expression RandomNode::setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) {
return Random(this).setSign(s, context, angleUnit);
}

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int RealPartNode::numberOfChildren() const { return RealPart::NumberOfChildren(); }
Layout RealPartNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(RealPart(this), floatDisplayMode, numberOfSignificantDigits, RealPart::Name());
}

View File

@@ -9,6 +9,8 @@
namespace Poincare {
int RoundNode::numberOfChildren() const { return Round::NumberOfChildren(); }
Layout RoundNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return LayoutHelper::Prefix(Round(this), floatDisplayMode, numberOfSignificantDigits, Round::Name());
}

View File

@@ -7,6 +7,8 @@
namespace Poincare {
int SineNode::numberOfChildren() const { return Sine::NumberOfChildren(); }
float SineNode::characteristicXRange(Context & context, Preferences::AngleUnit angleUnit) const {
return Trigonometry::characteristicXRange(Sine(this), context, angleUnit);
}

View File

@@ -10,6 +10,8 @@
namespace Poincare {
int SquareRootNode::numberOfChildren() const { return SquareRoot::NumberOfChildren(); }
Layout SquareRootNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
return NthRootLayout(childAtIndex(0)->createLayout(floatDisplayMode, numberOfSignificantDigits));
}

View File

@@ -10,6 +10,8 @@
namespace Poincare {
int TangentNode::numberOfChildren() const { return Tangent::NumberOfChildren(); }
float TangentNode::characteristicXRange(Context & context, Preferences::AngleUnit angleUnit) const {
return Trigonometry::characteristicXRange(Tangent(this), context, angleUnit);
}