#include #include #include "layout/sum_layout.h" extern "C" { #include #include } #include namespace Poincare { Expression::Type Sum::type() const { return Type::Sum; } Expression * Sum::clone() const { Sum * a = new Sum(m_operands, true); return a; } const char * Sum::name() const { return "sum"; } int Sum::emptySequenceValue() const { return 0; } ExpressionLayout * Sum::createSequenceLayoutWithArgumentLayouts(ExpressionLayout * argumentLayout, ExpressionLayout * subscriptLayout, ExpressionLayout * superscriptLayout) const { return new SumLayout(argumentLayout, subscriptLayout, superscriptLayout, false); } template Evaluation * Sum::templatedApproximateWithNextTerm(Evaluation * a, Evaluation * b) const { if (a->type() == Evaluation::Type::Complex && b->type() == Evaluation::Type::Complex) { Complex * c = static_cast *>(a); Complex * d = static_cast *>(b); return new Complex((*c)+(*d)); } if (a->type() == Evaluation::Type::Complex) { Complex * c = static_cast *>(a); assert(b->type() == Evaluation::Type::MatrixComplex); MatrixComplex * m = static_cast *>(b); return new MatrixComplex(Addition::computeOnComplexAndMatrix(*c, *m)); } assert(a->type() == Evaluation::Type::MatrixComplex); assert(b->type() == Evaluation::Type::MatrixComplex); MatrixComplex * m = static_cast *>(a); MatrixComplex * n = static_cast *>(b); return new MatrixComplex(Addition::computeOnMatrices(*m, *n)); } }