[poincare] Implement isPositive for symbols Pi and e

Change-Id: I6fb3f605eaf62848b2e90b186c9adb00b330f91d
This commit is contained in:
Émilie Feral
2017-10-09 14:02:16 +02:00
parent ea7a22aaa4
commit 5ddcbbe4b7
2 changed files with 17 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ public:
char name() const;
Type type() const override;
Expression * clone() const override;
bool isPositive() const override;
bool isMatrixSymbol() const;
private:
Evaluation<float> * privateEvaluate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedEvaluate<float>(context, angleUnit); }

View File

@@ -4,6 +4,7 @@
#include "layout/baseline_relative_layout.h"
#include "layout/string_layout.h"
#include <poincare/complex_matrix.h>
#include <ion.h>
extern "C" {
#include <assert.h>
}
@@ -53,6 +54,21 @@ Expression * Symbol::clone() const {
return new Symbol(m_name);
}
bool Symbol::isPositive() const {
/* TODO: Maybe, we will want to know that from a context given in parameter:
if (context.expressionForSymbol(this) != nullptr) {
return context.expressionForSymbol(this)->isPositive(context);
}
return false;*/
if (m_name == Ion::Charset::SmallPi) {
return true;
}
if (m_name == Ion::Charset::Exponential) {
return true;
}
return false;
}
template<typename T>
Evaluation<T> * Symbol::templatedEvaluate(Context& context, AngleUnit angleUnit) const {
if (context.expressionForSymbol(this) != nullptr) {