Numworks Epsilon  1.4.1
Graphing Calculator Operating System
cache_context.cpp
Go to the documentation of this file.
1 #include "cache_context.h"
2 #include <cmath>
3 
4 using namespace Poincare;
5 
6 namespace Sequence {
7 
8 template<typename T>
10  VariableContext<T>('n', parentContext),
13 {
14 }
15 
16 template<typename T>
18  if (symbol->name() == Symbol::SpecialSymbols::un || symbol->name() == Symbol::SpecialSymbols::un1 ||
19  symbol->name() == Symbol::SpecialSymbols::vn || symbol->name() == Symbol::SpecialSymbols::vn1) {
20  return &m_values[nameIndexForSymbol(symbol)][rankIndexForSymbol(symbol)];
21  }
23 }
24 
25 template<typename T>
27  m_values[nameIndexForSymbol(symbol)][rankIndexForSymbol(symbol)] = Complex<T>::Float(value);
28 }
29 
30 template<typename T>
32  switch (symbol->name()) {
33  case Symbol::SpecialSymbols::un:
34  return 0;
35  case Symbol::SpecialSymbols::un1:
36  return 0;
37  case Symbol::SpecialSymbols::vn:
38  return 1;
39  case Symbol::SpecialSymbols::vn1:
40  return 1;
41  default:
42  return 0;
43  }
44 }
45 
46 template<typename T>
47 int CacheContext<T>::rankIndexForSymbol(const Poincare::Symbol * symbol) {
48  switch (symbol->name()) {
49  case Symbol::SpecialSymbols::un:
50  return 0;
51  case Symbol::SpecialSymbols::un1:
52  return 1;
53  case Symbol::SpecialSymbols::vn:
54  return 0;
55  case Symbol::SpecialSymbols::vn1:
56  return 1;
57  default:
58  return 0;
59  }
60 }
61 
62 template class CacheContext<float>;
63 template class CacheContext<double>;
64 
65 }
#define NAN
Definition: math.h:30
char name() const
Definition: symbol.cpp:185
#define T(x)
Definition: events.cpp:26
Definition: app.cpp:7
void setValueForSymbol(T value, const Poincare::Symbol *symbol)
const Poincare::Expression * expressionForSymbol(const Poincare::Symbol *symbol) override