#include #include #include "layout/product_layout.h" extern "C" { #include #include } #include namespace Poincare { Expression::Type Product::type() const { return Type::Product; } Expression * Product::clone() const { Product * a = new Product(m_operands, true); return a; } const char * Product::name() const { return "product"; } int Product::emptySequenceValue() const { return 1; } ExpressionLayout * Product::createSequenceLayoutWithArgumentLayouts(ExpressionLayout * argumentLayout, ExpressionLayout * subscriptLayout, ExpressionLayout * superscriptLayout) const { return new ProductLayout(argumentLayout, subscriptLayout, superscriptLayout, false); } template Evaluation * Product::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(Multiplication::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(Multiplication::computeOnMatrices(*m, *n)); } }