Numworks Epsilon  1.4.1
Graphing Calculator Operating System
product.cpp
Go to the documentation of this file.
1 #include <poincare/product.h>
4 extern "C" {
5 #include <assert.h>
6 #include <stdlib.h>
7 }
8 #include <cmath>
9 
10 namespace Poincare {
11 
13  return Type::Product;
14 }
15 
17  Product * a = new Product(m_operands, true);
18  return a;
19 }
20 
21 const char * Product::name() const {
22  return "product";
23 }
24 
25 int Product::emptySequenceValue() const {
26  return 1;
27 }
28 
29 ExpressionLayout * Product::createSequenceLayoutWithArgumentLayouts(ExpressionLayout * subscriptLayout, ExpressionLayout * superscriptLayout, ExpressionLayout * argumentLayout) const {
30  return new ProductLayout(subscriptLayout, superscriptLayout, argumentLayout);
31 }
32 
33 template<typename T>
34 Expression * Product::templatedApproximateWithNextTerm(Expression * a, Expression * b) const {
35  if (a->type() == Type::Complex && b->type() == Type::Complex) {
36  Complex<T> * c = static_cast<Complex<T> *>(a);
37  Complex<T> * d = static_cast<Complex<T> *>(b);
38  return new Complex<T>(Multiplication::compute(*c, *d));
39  }
40  if (a->type() == Type::Complex) {
41  Complex<T> * c = static_cast<Complex<T> *>(a);
42  assert(b->type() == Type::Matrix);
43  Matrix * m = static_cast<Matrix *>(b);
45  }
46  assert(a->type() == Type::Matrix);
47  assert(b->type() == Type::Matrix);
48  Matrix * m = static_cast<Matrix *>(a);
49  Matrix * n = static_cast<Matrix *>(b);
50  return Multiplication::computeOnMatrices<T>(m, n);
51 }
52 
53 }
#define assert(e)
Definition: assert.h:9
static Matrix * computeOnComplexAndMatrix(const Complex< T > *c, const Matrix *m)
c(generic_all_nodes)
const Expression * m_operands[T]
static Complex< T > compute(const Complex< T > c, const Complex< T > d)
friend class Matrix
Definition: expression.h:73
Type type() const override
Definition: product.cpp:12
friend class Product
Definition: expression.h:66
Expression * clone() const override
Definition: product.cpp:16