#include #include #include "layout/sum_layout.h" extern "C" { #include #include } #include namespace Poincare { Sum::Sum() : Sequence("sum") { } Expression::Type Sum::type() const { return Type::Sum; } Expression * Sum::cloneWithDifferentOperands(Expression** newOperands, int numberOfOperands, bool cloneOperands) const { assert(newOperands != nullptr); Sum * s = new Sum(); s->setArgument(newOperands, numberOfOperands, cloneOperands); return s; } int Sum::emptySequenceValue() const { return 0; } ExpressionLayout * Sum::createSequenceLayoutWithArgumentLayouts(ExpressionLayout * subscriptLayout, ExpressionLayout * superscriptLayout, ExpressionLayout * argumentLayout) const { return new SumLayout(subscriptLayout, superscriptLayout, argumentLayout); } template Evaluation * Sum::templatedEvaluateWithNextTerm(Evaluation * a, Evaluation * b) const { if (a->numberOfOperands() == 1 && b->numberOfOperands() == 1) { return new Complex(Addition::compute(*(a->complexOperand(0)), *(b->complexOperand(0)))); } if (a->numberOfOperands() == 1) { return Addition::computeOnComplexAndMatrix(a->complexOperand(0), b); } return Addition::computeOnMatrices(a, b); } }