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>
9
CacheContext<T>::CacheContext
(
Context
* parentContext) :
10
VariableContext
<
T
>(
'n'
, parentContext),
11
m_values{{
Complex<T>::Float
(
NAN
),
Complex<T>::Float
(
NAN
)},
12
{
Complex<T>::Float
(
NAN
),
Complex<T>::Float
(
NAN
)}}
13
{
14
}
15
16
template
<
typename
T>
17
const
Expression
*
CacheContext<T>::expressionForSymbol
(
const
Symbol
* symbol) {
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
}
22
return
VariableContext<T>::expressionForSymbol
(symbol);
23
}
24
25
template
<
typename
T>
26
void
CacheContext<T>::setValueForSymbol
(
T
value,
const
Poincare::Symbol
* symbol) {
27
m_values[nameIndexForSymbol(symbol)][rankIndexForSymbol(symbol)] =
Complex<T>::Float
(value);
28
}
29
30
template
<
typename
T>
31
int
CacheContext<T>::nameIndexForSymbol
(
const
Poincare::Symbol
* symbol) {
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
}
Poincare::Context
Definition:
context.h:9
NAN
#define NAN
Definition:
math.h:30
Poincare::Symbol::name
char name() const
Definition:
symbol.cpp:185
T
#define T(x)
Definition:
events.cpp:26
Poincare
Definition:
absolute_value.h:8
Sequence::CacheContext
Definition:
cache_context.h:10
Poincare::Complex
Definition:
complex.h:12
Poincare::Symbol
Definition:
symbol.h:8
cache_context.h
Sequence
Definition:
app.cpp:7
Poincare::VariableContext
Definition:
variable_context.h:10
Poincare::Expression
Definition:
expression.h:16
Sequence::CacheContext::setValueForSymbol
void setValueForSymbol(T value, const Poincare::Symbol *symbol)
Definition:
cache_context.cpp:26
Sequence::CacheContext::expressionForSymbol
const Poincare::Expression * expressionForSymbol(const Poincare::Symbol *symbol) override
Definition:
cache_context.cpp:17
epsilon
apps
sequence
cache_context.cpp
Generated by
1.8.14