#include #include extern "C" { #include #include } #include "layout/horizontal_layout.h" #include "layout/string_layout.h" #include "layout/parenthesis_layout.h" namespace Poincare { Expression::Type Addition::type() const { return Type::Addition; } ExpressionLayout * Addition::privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const { assert(floatDisplayMode != FloatDisplayMode::Default); assert(complexFormat != ComplexFormat::Default); ExpressionLayout** children_layouts = new ExpressionLayout * [3]; children_layouts[0] = m_operands[0]->createLayout(floatDisplayMode, complexFormat); children_layouts[1] = new StringLayout("+", 1); children_layouts[2] = m_operands[1]->type() == Type::Opposite ? new ParenthesisLayout(m_operands[1]->createLayout(floatDisplayMode, complexFormat)) : m_operands[1]->createLayout(floatDisplayMode, complexFormat); ExpressionLayout * layout = new HorizontalLayout(children_layouts, 3); delete[] children_layouts; return layout; } template Complex Addition::compute(const Complex c, const Complex d) { return Complex::Cartesian(c.a()+d.a(), c.b()+d.b()); } template Evaluation * Addition::computeOnMatrices(Evaluation * m, Evaluation * n) { Addition a; return a.computeOnComplexMatrices(m,n); } template Evaluation * Addition::computeOnComplexAndMatrix(const Complex * c, Evaluation * m) { Addition a; return a.computeOnComplexAndComplexMatrix(c,m); } Expression * Addition::cloneWithDifferentOperands(Expression** newOperands, int numberOfOperands, bool cloneOperands) const { return new Addition(newOperands, cloneOperands); } bool Addition::isCommutative() const { return true; } template Poincare::Complex Poincare::Addition::compute(Poincare::Complex, Poincare::Complex); template Poincare::Complex Poincare::Addition::compute(Poincare::Complex, Poincare::Complex); template Poincare::Evaluation* Poincare::Addition::computeOnMatrices(Poincare::Evaluation*, Poincare::Evaluation*); template Poincare::Evaluation* Poincare::Addition::computeOnMatrices(Poincare::Evaluation*, Poincare::Evaluation*); template Poincare::Evaluation* Poincare::Addition::computeOnComplexAndMatrix(Poincare::Complex const*, Poincare::Evaluation*); template Poincare::Evaluation* Poincare::Addition::computeOnComplexAndMatrix(Poincare::Complex const*, Poincare::Evaluation*); }