Numworks Epsilon  1.4.1
Graphing Calculator Operating System
symbol.h
Go to the documentation of this file.
1 #ifndef POINCARE_SYMBOL_H
2 #define POINCARE_SYMBOL_H
3 
5 
6 namespace Poincare {
7 
8 class Symbol : public StaticHierarchy<0> {
9 public:
10  enum SpecialSymbols : char {
11  /* We can use characters from 1 to 31 as they do not correspond to usual
12  * characters but events as 'end of text', 'backspace'... */
13  Ans = 1,
14  un = 2,
15  un1 = 3,
16  un2 = 4,
17  vn = 5,
18  vn1 = 6,
19  vn2 = 7,
20  M0 = 8,
21  M1 = 9,
22  M2,
23  M3,
24  M4,
25  M5,
26  M6,
27  M7,
28  M8,
29  M9 = 17
30  };
31  static SpecialSymbols matrixSymbol(char index);
32  Symbol(char name);
33  Symbol(Symbol&& other); // C++11 move constructor
34  Symbol(const Symbol& other); // C++11 copy constructor
35  char name() const;
36  Type type() const override;
37  Expression * clone() const override;
38  int polynomialDegree(char symbolName) const override;
39  Sign sign() const override;
40  bool isMatrixSymbol() const;
41  bool isScalarSymbol() const;
42  bool isApproximate(Context & context) const;
43  float characteristicXRange(Context & context, AngleUnit angleUnit = AngleUnit::Default) const override;
44  bool hasAnExactRepresentation(Context & context) const;
45 private:
46  const char * textForSpecialSymbols(char name) const;
47  Expression * replaceSymbolWithExpression(char symbol, Expression * expression) override;
48  /* Simplification */
49  Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
50  /* Comparison */
51  int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const override;
52  /* Layout */
53  ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override;
54  int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
55  /* Evaluation */
56  Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
57  Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<double>(context, angleUnit); }
58  template<typename T> Expression * templatedApproximate(Context& context, AngleUnit angleUnit) const;
59  const char m_name;
60 };
61 
62 }
63 
64 #endif
Sign sign() const override
Definition: symbol.cpp:123
char name() const
Definition: symbol.cpp:185
float characteristicXRange(Context &context, AngleUnit angleUnit=AngleUnit::Default) const override
Definition: symbol.cpp:145
bool isApproximate(Context &context) const
Definition: symbol.cpp:137
int polynomialDegree(char symbolName) const override
Definition: symbol.cpp:105
Type type() const override
Definition: symbol.cpp:181
Symbol(char name)
Definition: symbol.cpp:86
static SpecialSymbols matrixSymbol(char index)
Definition: symbol.cpp:58
bool hasAnExactRepresentation(Context &context) const
Definition: symbol.cpp:152
bool isScalarSymbol() const
Definition: symbol.cpp:238
bool isMatrixSymbol() const
Definition: symbol.cpp:231
Expression * clone() const override
Definition: symbol.cpp:101