Numworks Epsilon  1.4.1
Graphing Calculator Operating System
subtraction.h
Go to the documentation of this file.
1 #ifndef POINCARE_SUBSTRACTION_H
2 #define POINCARE_SUBSTRACTION_H
3 
7 
8 namespace Poincare {
9 
10 class Subtraction : public StaticHierarchy<2> {
12 public:
13  Type type() const override;
14  Expression * clone() const override;
15  template<typename T> static Complex<T> compute(const Complex<T> c, const Complex<T> d);
16  int polynomialDegree(char symbolName) const override;
17 private:
18  /* Layout */
19  bool needParenthesisWithParent(const Expression * e) const override;
20  ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
21  return LayoutEngine::createInfixLayout(this, floatDisplayMode, complexFormat, name());
22  }
23  int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
24  return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
25  }
26  static const char * name() { return "-"; }
27  /* Simplification */
28  Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
29  /* Evaluation */
30  template<typename T> static Matrix * computeOnMatrixAndComplex(const Matrix * m, const Complex<T> * c) {
32  }
33  template<typename T> static Matrix * computeOnComplexAndMatrix(const Complex<T> * c, const Matrix * n);
34  template<typename T> static Matrix * computeOnMatrices(const Matrix * m, const Matrix * n) {
36  }
37 
38  Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override {
39  return ApproximationEngine::mapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
40  }
41  Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override {
42  return ApproximationEngine::mapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
43  }
44 };
45 
46 }
47 
48 #endif
static int writeInfixExpressionTextInBuffer(const Expression *expression, char *buffer, int bufferSize, int numberOfDigits, const char *operatorName)
Expression * clone() const override
Definition: subtraction.cpp:22
Type type() const override
Definition: subtraction.cpp:18
static Matrix * elementWiseOnComplexAndComplexMatrix(const Complex< T > *c, const Matrix *n, ComplexAndComplexReduction< T > computeOnComplexes)
c(generic_all_nodes)
int polynomialDegree(char symbolName) const override
Definition: subtraction.cpp:26
static Complex< T > compute(const Complex< T > c, const Complex< T > d)
Definition: subtraction.cpp:46
static ExpressionLayout * createInfixLayout(const Expression *expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char *operatorName)
static Matrix * elementWiseOnComplexMatrices(const Matrix *m, const Matrix *n, ComplexAndComplexReduction< T > computeOnComplexes)