#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 * subscriptLayout, ExpressionLayout * superscriptLayout, ExpressionLayout * argumentLayout) const { return new SumLayout(subscriptLayout, superscriptLayout, argumentLayout); } template Expression * Sum::templatedApproximateWithNextTerm(Expression * a, Expression * b) const { if (a->type() == Type::Complex && b->type() == Type::Complex) { Complex * c = static_cast *>(a); Complex * d = static_cast *>(b); return new Complex(Addition::compute(*c, *d)); } if (a->type() == Type::Complex) { Complex * c = static_cast *>(a); assert(b->type() == Type::Matrix); Matrix * m = static_cast(b); return Addition::computeOnComplexAndMatrix(c, m); } assert(a->type() == Type::Matrix); assert(b->type() == Type::Matrix); Matrix * m = static_cast(a); Matrix * n = static_cast(b); return Addition::computeOnMatrices(m, n); } }