mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-25 00:30:46 +01:00
[poincare] Fix bug
Change-Id: I49b0ac9d71a1d541f94030de275a5e6498823f4f
This commit is contained in:
@@ -23,6 +23,7 @@ public:
|
||||
static constexpr uint16_t k_maxNumberOfMatrixExpressions = 10;
|
||||
static Complex * defaultExpression();
|
||||
private:
|
||||
static Complex * nanExpression();
|
||||
int symbolIndex(const Symbol * symbol) const;
|
||||
Expression * m_expressions[k_maxNumberOfScalarExpressions];
|
||||
Complex m_pi;
|
||||
|
||||
@@ -28,6 +28,11 @@ Complex * GlobalContext::defaultExpression() {
|
||||
return defaultExpression;
|
||||
}
|
||||
|
||||
Complex * GlobalContext::nanExpression() {
|
||||
static Complex * nanExpression = new Complex(Complex::Float(NAN));
|
||||
return nanExpression;
|
||||
}
|
||||
|
||||
int GlobalContext::symbolIndex(const Symbol * symbol) const {
|
||||
int index = symbol->name() - 'A';
|
||||
return index;
|
||||
@@ -42,7 +47,7 @@ const Expression * GlobalContext::expressionForSymbol(const Symbol * symbol) {
|
||||
}
|
||||
int index = symbolIndex(symbol);
|
||||
if (index < 0 || index >= k_maxNumberOfScalarExpressions) {
|
||||
return nullptr;
|
||||
return nanExpression();
|
||||
}
|
||||
if (m_expressions[index] == nullptr) {
|
||||
return defaultExpression();
|
||||
|
||||
@@ -25,7 +25,7 @@ float Symbol::privateApproximate(Context& context, AngleUnit angleUnit) const {
|
||||
|
||||
Expression * Symbol::privateEvaluate(Context& context, AngleUnit angleUnit) const {
|
||||
assert(angleUnit != AngleUnit::Default);
|
||||
if (context.expressionForSymbol(this)) {
|
||||
if (context.expressionForSymbol(this) != nullptr) {
|
||||
return context.expressionForSymbol(this)->evaluate(context, angleUnit);
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user