Numworks Epsilon  1.4.1
Graphing Calculator Operating System
multiplication.h
Go to the documentation of this file.
1 #ifndef POINCARE_MULTIPLICATION_H
2 #define POINCARE_MULTIPLICATION_H
3 
7 
8 namespace Poincare {
9 
12  friend class Addition;
13  friend class Division;
14  friend class Logarithm;
15  friend class Opposite;
16  friend class Power;
17  friend class Subtraction;
18  friend class Symbol;
19  friend class Complex<float>;
20  friend class Complex<double>;
21 public:
22  Type type() const override;
23  Expression * clone() const override;
24  Sign sign() const override;
25  int polynomialDegree(char symbolName) const override;
26  /* Evaluation */
27  template<typename T> static Complex<T> compute(const Complex<T> c, const Complex<T> d);
28  template<typename T> static Matrix * computeOnComplexAndMatrix(const Complex<T> * c, const Matrix * m) {
30  }
31  template<typename T> static Matrix * computeOnMatrices(const Matrix * m, const Matrix * n);
32 private:
33  /* Property */
34  Expression * setSign(Sign s, Context & context, AngleUnit angleUnit) override;
35  /* Layout */
36  bool needParenthesisWithParent(const Expression * e) const override;
37  ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
38  int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
39  /* Simplification */
40  Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
41  Expression * privateShallowReduce(Context& context, AngleUnit angleUnit, bool expand, bool canBeInterrupted);
42  void mergeMultiplicationOperands();
43  void factorizeBase(Expression * e1, Expression * e2, Context & context, AngleUnit angleUnit);
44  void factorizeExponent(Expression * e1, Expression * e2, Context & context, AngleUnit angleUnit);
45  Expression * distributeOnOperandAtIndex(int index, Context & context, AngleUnit angleUnit);
46  Expression * cloneDenominator(Context & context, AngleUnit angleUnit) const override;
47  void addMissingFactors(Expression * factor, Context & context, AngleUnit angleUnit);
48  void factorizeSineAndCosine(Expression * o1, Expression * o2, Context & context, AngleUnit angleUnit);
49  static bool HaveSameNonRationalFactors(const Expression * e1, const Expression * e2);
50  static bool TermsHaveIdenticalBase(const Expression * e1, const Expression * e2);
51  static bool TermsHaveIdenticalExponent(const Expression * e1, const Expression * e2);
52  static bool TermHasRationalBase(const Expression * e);
53  static bool TermHasRationalExponent(const Expression * e);
54  static const Expression * CreateExponent(Expression * e);
55  Expression * shallowBeautify(Context & context, AngleUnit angleUnit) override;
56  // Warning: mergeNegativePower not always returns a multiplication: *(b^-1,c^-1) -> (bc)^-1
57  Expression * mergeNegativePower(Context & context, AngleUnit angleUnit);
58  /* Evaluation */
59 
60  template<typename T> static Matrix * computeOnMatrixAndComplex(const Matrix * m, const Complex<T> * c) {
62  }
63  Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override {
64  return ApproximationEngine::mapReduce<float>(this, context, angleUnit, compute<float>, computeOnComplexAndMatrix<float>, computeOnMatrixAndComplex<float>, computeOnMatrices<float>);
65  }
66  Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override {
67  return ApproximationEngine::mapReduce<double>(this, context, angleUnit, compute<double>, computeOnComplexAndMatrix<double>, computeOnMatrixAndComplex<double>, computeOnMatrices<double>);
68  }
69 };
70 
71 }
72 
73 #endif
static Matrix * computeOnMatrices(const Matrix *m, const Matrix *n)
Expression * clone() const override
static Matrix * elementWiseOnComplexAndComplexMatrix(const Complex< T > *c, const Matrix *n, ComplexAndComplexReduction< T > computeOnComplexes)
static Matrix * computeOnComplexAndMatrix(const Complex< T > *c, const Matrix *m)
c(generic_all_nodes)
Type type() const override
static Complex< T > compute(const Complex< T > c, const Complex< T > d)
int polynomialDegree(char symbolName) const override
Sign sign() const override