[poincare] Create templated methods instead of defining UntypedBuilder

on every expression
This commit is contained in:
Émilie Feral
2019-02-19 12:20:07 +01:00
committed by LeaNumworks
parent 7b5f3c570d
commit 359fc3a599
47 changed files with 89 additions and 87 deletions

View File

@@ -50,8 +50,8 @@ friend class AbsoluteValueNode;
public:
AbsoluteValue(const AbsoluteValueNode * n) : Expression(n) {}
static AbsoluteValue Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("abs", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("abs", 1, &UntypedBuilderOneChild<AbsoluteValue>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
private:

View File

@@ -42,8 +42,8 @@ class ArcCosine final : public Expression {
public:
ArcCosine(const ArcCosineNode * n) : Expression(n) {}
static ArcCosine Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("acos", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("acos", 1, &UntypedBuilderOneChild<ArcCosine>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);

View File

@@ -41,8 +41,8 @@ class ArcSine final : public Expression {
public:
ArcSine(const ArcSineNode * n) : Expression(n) {}
static ArcSine Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("asin", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("asin", 1, &UntypedBuilderOneChild<ArcSine>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -45,8 +45,8 @@ class ArcTangent final : public Expression {
public:
ArcTangent(const ArcTangentNode * n) : Expression(n) {}
static ArcTangent Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("atan", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("atan", 1, &UntypedBuilderOneChild<ArcTangent>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -40,8 +40,7 @@ class BinomialCoefficient final : public Expression {
public:
BinomialCoefficient(const BinomialCoefficientNode * n) : Expression(n) {}
static BinomialCoefficient Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("binomial", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("binomial", 2, &UntypedBuilderTwoChildren<BinomialCoefficient>);
// Expression
Expression shallowReduce();

View File

@@ -43,8 +43,8 @@ class Ceiling final : public Expression {
public:
Ceiling(const CeilingNode * n) : Expression(n) {}
static Ceiling Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("ceil", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("ceil", 1, &UntypedBuilderOneChild<Ceiling>);
Expression shallowReduce();
};

View File

@@ -42,8 +42,8 @@ class ComplexArgument final : public Expression {
public:
ComplexArgument(const ComplexArgumentNode * n) : Expression(n) {}
static ComplexArgument Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("arg", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("arg", 1, &UntypedBuilderOneChild<ComplexArgument>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -46,8 +46,7 @@ class ConfidenceInterval : public Expression {
public:
ConfidenceInterval(const ConfidenceIntervalNode * n) : Expression(n) {}
static ConfidenceInterval Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("confidence", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("confidence", 2, &UntypedBuilderTwoChildren<ConfidenceInterval>);
// Expression
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
@@ -59,8 +58,7 @@ class SimplePredictionInterval final : public ConfidenceInterval {
public:
SimplePredictionInterval(const SimplePredictionIntervalNode * n) : ConfidenceInterval(n) {}
static SimplePredictionInterval Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("prediction", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("prediction", 2, &UntypedBuilderTwoChildren<SimplePredictionInterval>);
};
}

View File

@@ -42,8 +42,8 @@ class Conjugate final : public Expression {
public:
Conjugate(const ConjugateNode * n) : Expression(n) {}
static Conjugate Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("conj", 1, &UntypedBuilder);;
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("conj", 1, &UntypedBuilderOneChild<Conjugate>);;
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -47,8 +47,8 @@ class Cosine final : public Expression {
public:
Cosine(const CosineNode * n) : Expression(n) {}
static Cosine Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("cos", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("cos", 1, &UntypedBuilderOneChild<Cosine>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -53,6 +53,7 @@ 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();

View File

@@ -36,8 +36,8 @@ class Determinant final : public Expression {
public:
Determinant(const DeterminantNode * n) : Expression(n) {}
static Determinant Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("det", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("det", 1, &UntypedBuilderOneChild<Determinant>);
Expression shallowReduce(Context & context);
};

View File

@@ -39,8 +39,7 @@ class DivisionQuotient final : public Expression {
public:
DivisionQuotient(const DivisionQuotientNode * n) : Expression(n) {}
static DivisionQuotient Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("quo", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("quo", 2, &UntypedBuilderTwoChildren<DivisionQuotient>);
// Expression
Expression shallowReduce();

View File

@@ -40,8 +40,7 @@ class DivisionRemainder final : public Expression {
public:
DivisionRemainder(const DivisionRemainderNode * n) : Expression(n) {}
static DivisionRemainder Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("rem", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("rem", 2, &UntypedBuilderTwoChildren<DivisionRemainder>);
// Expression
Expression shallowReduce();

View File

@@ -248,6 +248,17 @@ public:
protected:
static bool SimplificationHasBeenInterrupted();
Expression(const ExpressionNode * n) : TreeHandle(n) {}
template<typename U>
static Expression UntypedBuilderOneChild(Expression children) {
assert(children.type() == ExpressionNode::Type::Matrix);
return U::Builder(children.childAtIndex(0));
}
template<typename U>
static Expression UntypedBuilderTwoChildren(Expression children) {
assert(children.type() == ExpressionNode::Type::Matrix);
return U::Builder(children.childAtIndex(0), children.childAtIndex(1));
}
template<class T> T convert() const {
/* This function allows to convert Expression to derived Expressions.

View File

@@ -38,8 +38,8 @@ class Factor final : public Expression {
public:
Factor(const FactorNode * n) : Expression(n) {}
static Factor Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("factor", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("factor", 1, &UntypedBuilderOneChild<Factor>);
Expression shallowBeautify(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit);
Multiplication createMultiplicationOfIntegerPrimeDecomposition(Integer i, Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const;

View File

@@ -45,8 +45,8 @@ class Floor final : public Expression {
public:
Floor(const FloorNode * n) : Expression(n) {}
static Floor Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("floor", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("floor", 1, &UntypedBuilderOneChild<Floor>);
Expression shallowReduce();
};

View File

@@ -45,8 +45,8 @@ class FracPart final : public Expression {
public:
FracPart(const FracPartNode * n) : Expression(n) {}
static FracPart Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("frac", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("frac", 1, &UntypedBuilderOneChild<FracPart>);
Expression shallowReduce();
};

View File

@@ -38,8 +38,7 @@ class GreatCommonDivisor final : public Expression {
public:
GreatCommonDivisor(const GreatCommonDivisorNode * n) : Expression(n) {}
static GreatCommonDivisor Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("gcd", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("gcd", 2, &UntypedBuilderTwoChildren<GreatCommonDivisor>);
// Expression
Expression shallowReduce();

View File

@@ -37,8 +37,8 @@ class HyperbolicArcCosine final : public HyperbolicTrigonometricFunction {
public:
HyperbolicArcCosine(const HyperbolicArcCosineNode * n) : HyperbolicTrigonometricFunction(n) {}
static HyperbolicArcCosine Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("acosh", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("acosh", 1, &UntypedBuilderOneChild<HyperbolicArcCosine>);
};
}

View File

@@ -37,8 +37,8 @@ class HyperbolicArcSine final : public HyperbolicTrigonometricFunction {
public:
HyperbolicArcSine(const HyperbolicArcSineNode * n) : HyperbolicTrigonometricFunction(n) {}
static HyperbolicArcSine Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("asinh", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("asinh", 1, &UntypedBuilderOneChild<HyperbolicArcSine>);
};
}

View File

@@ -37,8 +37,8 @@ class HyperbolicArcTangent final : public HyperbolicTrigonometricFunction {
public:
HyperbolicArcTangent(const HyperbolicArcTangentNode * n) : HyperbolicTrigonometricFunction(n) {}
static HyperbolicArcTangent Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("atanh", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("atanh", 1, &UntypedBuilderOneChild<HyperbolicArcTangent>);
};
}

View File

@@ -37,8 +37,8 @@ class HyperbolicCosine final : public HyperbolicTrigonometricFunction {
public:
HyperbolicCosine(const HyperbolicCosineNode * n) : HyperbolicTrigonometricFunction(n) {}
static HyperbolicCosine Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("cosh", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("cosh", 1, &UntypedBuilderOneChild<HyperbolicCosine>);
};
}

View File

@@ -37,8 +37,8 @@ class HyperbolicSine final : public HyperbolicTrigonometricFunction {
public:
HyperbolicSine(const HyperbolicSineNode * n) : HyperbolicTrigonometricFunction(n) {}
static HyperbolicSine Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sinh", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sinh", 1, &UntypedBuilderOneChild<HyperbolicSine>);
};
}

View File

@@ -37,8 +37,8 @@ class HyperbolicTangent final : public HyperbolicTrigonometricFunction {
public:
HyperbolicTangent(const HyperbolicTangentNode * n) : HyperbolicTrigonometricFunction(n) {}
static HyperbolicTangent Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("tanh", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("tanh", 1, &UntypedBuilderOneChild<HyperbolicTangent>);
};
}

View File

@@ -46,8 +46,8 @@ class ImaginaryPart final : public Expression {
public:
ImaginaryPart(const ImaginaryPartNode * n) : Expression(n) {}
static ImaginaryPart Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("im", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("im", 1, &UntypedBuilderOneChild<ImaginaryPart>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -57,6 +57,7 @@ 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();

View File

@@ -38,8 +38,7 @@ class LeastCommonMultiple final : public Expression {
public:
LeastCommonMultiple(const LeastCommonMultipleNode * n) : Expression(n) {}
static LeastCommonMultiple Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("lcm", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("lcm", 2, &UntypedBuilderTwoChildren<LeastCommonMultiple>);
// Expression
Expression shallowReduce();

View File

@@ -45,8 +45,7 @@ class Logarithm final : public Expression {
public:
Logarithm(const LogarithmNode<2> * n) : Expression(n) {}
static Logarithm Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("log", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("log", 2, &UntypedBuilderTwoChildren<Logarithm>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
Expression shallowBeautify();
@@ -62,8 +61,8 @@ class CommonLogarithm : public Expression {
public:
CommonLogarithm(const LogarithmNode<1> * n) : Expression(n) {}
static CommonLogarithm Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("log", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("log", 1, &UntypedBuilderOneChild<CommonLogarithm>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -36,8 +36,8 @@ class MatrixDimension final : public Expression {
public:
MatrixDimension(const MatrixDimensionNode * n) : Expression(n) {}
static MatrixDimension Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("dim", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("dim", 1, &UntypedBuilderOneChild<MatrixDimension>);
Expression shallowReduce();
};

View File

@@ -35,8 +35,8 @@ class MatrixInverse final : public Expression {
public:
MatrixInverse(const MatrixInverseNode * n) : Expression(n) {}
static MatrixInverse Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("inverse", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("inverse", 1, &UntypedBuilderOneChild<MatrixInverse>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -35,8 +35,8 @@ class MatrixTrace final : public Expression {
public:
MatrixTrace(const MatrixTraceNode * n) : Expression(n) {}
static MatrixTrace Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("trace", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("trace", 1, &UntypedBuilderOneChild<MatrixTrace>);
Expression shallowReduce();
};

View File

@@ -35,8 +35,8 @@ class MatrixTranspose final : public Expression {
public:
MatrixTranspose(const MatrixTransposeNode * n) : Expression(n) {}
static MatrixTranspose Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("transpose", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("transpose", 1, &UntypedBuilderOneChild<MatrixTranspose>);
Expression shallowReduce();
};

View File

@@ -45,8 +45,8 @@ class NaperianLogarithm final : public Expression {
public:
NaperianLogarithm(const NaperianLogarithmNode * n) : Expression(n) {}
static NaperianLogarithm Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("ln", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("ln", 1, &UntypedBuilderOneChild<NaperianLogarithm>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -36,8 +36,7 @@ class NthRoot final : public Expression {
public:
NthRoot(const NthRootNode * n) : Expression(n) {}
static NthRoot Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("root", 2, &UntypedBuilder);
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);
};

View File

@@ -42,8 +42,7 @@ class PermuteCoefficient final : public Expression {
public:
PermuteCoefficient(const PermuteCoefficientNode * n) : Expression(n) {}
static PermuteCoefficient Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("permute", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("permute", 2, &UntypedBuilderTwoChildren<PermuteCoefficient>);
// Expression
Expression shallowReduce();

View File

@@ -38,8 +38,7 @@ class PredictionInterval final : public Expression {
public:
PredictionInterval(const PredictionIntervalNode * n) : Expression(n) {}
static PredictionInterval Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("prediction95", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("prediction95", 2, &UntypedBuilderTwoChildren<PredictionInterval>);
// Expression
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);

View File

@@ -37,6 +37,7 @@ 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();

View File

@@ -42,8 +42,7 @@ friend class RandintNode;
public:
Randint(const RandintNode * n) : Expression(n) {}
static Randint Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("randint", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("randint", 2, &UntypedBuilderTwoChildren<Randint>);
};
}

View File

@@ -44,7 +44,7 @@ friend class RandomNode;
public:
Random(const RandomNode * n) : Expression(n) {}
static Random Builder();
static Expression UntypedBuilder(Expression children) { return Builder(); }
static Expression UntypedBuilder(Expression children) { assert(children.type() == ExpressionNode::Type::Matrix); return Builder(); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("random", 0, &UntypedBuilder);
template<typename T> static T random();

View File

@@ -46,8 +46,8 @@ class RealPart final : public Expression {
public:
RealPart(const RealPartNode * n) : Expression(n) {}
static RealPart Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("re", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("re", 1, &UntypedBuilderOneChild<RealPart>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -39,8 +39,7 @@ class Round final : public Expression {
public:
Round(const RoundNode * n) : Expression(n) {}
static Round Builder(Expression child0, Expression child1);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0), children.childAtIndex(1)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("round", 2, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("round", 2, &UntypedBuilderTwoChildren<Round>);
Expression shallowReduce();
};

View File

@@ -46,8 +46,8 @@ class SignFunction final : public Expression {
public:
SignFunction(const SignFunctionNode * n) : Expression(n) {}
static SignFunction Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sign", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sign", 1, &UntypedBuilderOneChild<SignFunction>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -49,8 +49,8 @@ class Sine final : public Expression {
public:
Sine(const SineNode * n) : Expression(n) {}
static Sine Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sin", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("sin", 1, &UntypedBuilderOneChild<Sine>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};

View File

@@ -42,9 +42,9 @@ class SquareRoot final : public Expression {
public:
SquareRoot(const SquareRootNode * n) : Expression(n) {}
static SquareRoot Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static_assert('\x91' == Ion::Charset::Root, "Charset error");
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("\x91", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("\x91", 1, &UntypedBuilderOneChild<SquareRoot>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
private:

View File

@@ -37,6 +37,7 @@ 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();

View File

@@ -47,8 +47,8 @@ class Tangent final : public Expression {
public:
Tangent(const TangentNode * n) : Expression(n) {}
static Tangent Builder(Expression child);
static Expression UntypedBuilder(Expression children) { return Builder(children.childAtIndex(0)); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("tan", 1, &UntypedBuilder);
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("tan", 1, &UntypedBuilderOneChild<Tangent>);
Expression shallowReduce(Context & context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit, ExpressionNode::ReductionTarget target);
};