mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps][poincare] Use special symbols when required
Change-Id: I376f15eb9e08fd26d34fffb6aa86d2097af4c2c4
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "finite_integral_calculation.h"
|
||||
#include <assert.h>
|
||||
#include <ion.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace Probability {
|
||||
@@ -23,7 +24,8 @@ const char * FiniteIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
return "P(";
|
||||
}
|
||||
if (index == 1) {
|
||||
return "<=X<=";
|
||||
constexpr static char comparison[] = {Ion::Charset::LessEqual, 'X', Ion::Charset::LessEqual, 0};
|
||||
return comparison;
|
||||
}
|
||||
return ")=";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "left_integral_calculation.h"
|
||||
#include <assert.h>
|
||||
#include <ion.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace Probability {
|
||||
@@ -19,7 +20,8 @@ int LeftIntegralCalculation::numberOfParameters() {
|
||||
const char * LeftIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
assert(index >= 0 && index < 2);
|
||||
if (index == 0) {
|
||||
return "P(X<=";
|
||||
constexpr static char comparison[] = {'P', '(', 'X', Ion::Charset::LessEqual, 0};
|
||||
return comparison;
|
||||
}
|
||||
return ")=";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "right_integral_calculation.h"
|
||||
#include <assert.h>
|
||||
#include <ion.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace Probability {
|
||||
@@ -21,7 +22,8 @@ const char * RightIntegralCalculation::legendForParameterAtIndex(int index) {
|
||||
if (index == 0) {
|
||||
return "P(";
|
||||
}
|
||||
return "<=X)=";
|
||||
constexpr static char comparison[] = {Ion::Charset::LessEqual, 'X', ')', '=', 0};
|
||||
return comparison;
|
||||
}
|
||||
|
||||
void RightIntegralCalculation::setParameterAtIndex(float f, int index) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <ion.h>
|
||||
|
||||
namespace Probability {
|
||||
|
||||
@@ -29,7 +30,8 @@ const char * ExponentialLaw::parameterNameAtIndex(int index) {
|
||||
|
||||
const char * ExponentialLaw::parameterDefinitionAtIndex(int index) {
|
||||
assert(index == 0);
|
||||
return "l : parametre";
|
||||
constexpr static char def[] = {Ion::Charset::SmallLambda, ' ', ':', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'r', 'e', 0};
|
||||
return def;
|
||||
}
|
||||
|
||||
float ExponentialLaw::xMin() {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <ion.h>
|
||||
|
||||
namespace Probability {
|
||||
|
||||
@@ -34,9 +35,11 @@ const char * NormalLaw::parameterNameAtIndex(int index) {
|
||||
const char * NormalLaw::parameterDefinitionAtIndex(int index) {
|
||||
assert(index >= 0 && index < 2);
|
||||
if (index == 0) {
|
||||
return "u : moyenne";
|
||||
constexpr static char meanDef[] = {Ion::Charset::SmallMu, ' ', ':', ' ', 'm', 'o', 'y', 'e', 'n', 'n', 'e', 0};
|
||||
return meanDef;
|
||||
} else {
|
||||
return "o : ecart-type";
|
||||
constexpr static char devDef[] = {Ion::Charset::SmallSigma, ' ', ':', ' ', 'e', 'c', 'a', 'r', 't', '-', 't', 'y', 'p', 'e', 0};
|
||||
return devDef;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@ void GraphController::reloadBannerView() {
|
||||
float x = m_cursor.x();
|
||||
// Display a specific legend if the mean dot is selected
|
||||
if (m_selectedDotIndex == m_store->numberOfPairs()) {
|
||||
legend = "x^ = ";
|
||||
constexpr static char legX[] = {Ion::Charset::XBar, ' ', '=', ' ', 0};
|
||||
legend = legX;
|
||||
x = m_store->meanOfColumn(0);
|
||||
}
|
||||
legendLength = strlen(legend);
|
||||
@@ -84,7 +85,8 @@ void GraphController::reloadBannerView() {
|
||||
legend = "y = ";
|
||||
float y = m_cursor.y();
|
||||
if (m_selectedDotIndex == m_store->numberOfPairs()) {
|
||||
legend = "y^ = ";
|
||||
constexpr static char legY[] = {Ion::Charset::YBar, ' ', '=', ' ', 0};
|
||||
legend = legY;
|
||||
y = m_store->meanOfColumn(1);
|
||||
}
|
||||
legendLength = strlen(legend);
|
||||
|
||||
@@ -24,13 +24,17 @@ private:
|
||||
#define U() EventData::Undefined()
|
||||
#define T(x) EventData::Text(x)
|
||||
|
||||
static constexpr const char k_pi[2] = {Ion::Charset::SmallPi, 0};
|
||||
static constexpr const char k_root[4] = {Ion::Charset::Root, '(', ')', 0};
|
||||
static constexpr const char k_complexI[2] = {Ion::Charset::SmallIota, 0};
|
||||
|
||||
static constexpr EventData s_dataForEvent[] = {
|
||||
// Plain
|
||||
TL(), TL(), TL(), TL(), TL(), TL(),
|
||||
TL(), TL(), U(), U(), U(), U(),
|
||||
TL(), TL(), TL(), TL(), TL(), TL(),
|
||||
T("exp()"), T("ln()"), T("log()"), T("i"), T(","), T("^"),
|
||||
T("sin()"), T("cos()"), T("tan()"), T("Pi"), T("v()"), T("^2"),
|
||||
T("exp()"), T("ln()"), T("log()"), T(k_complexI), T(","), T("^"),
|
||||
T("sin()"), T("cos()"), T("tan()"), T(k_pi), T(k_root), T("^2"),
|
||||
T("7"), T("8"), T("9"), T("("), T(")"), U(),
|
||||
T("4"), T("5"), T("6"), T("*"), T("/"), U(),
|
||||
T("1"), T("2"), T("3"), T("+"), T("-"), U(),
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
class Symbol : public LeafExpression {
|
||||
public:
|
||||
enum SpecialSymbols : char {
|
||||
Ans = '^',
|
||||
Pi = '*'
|
||||
Ans = '^'
|
||||
};
|
||||
Symbol(char name);
|
||||
ExpressionLayout * createLayout() const override;
|
||||
|
||||
@@ -75,6 +75,11 @@
|
||||
* by flex temporarily swapping the last character. Afterwards the pointer is
|
||||
* still valid but the string isn't null-terminated anymore.
|
||||
*/
|
||||
/* We designed our own extended-ASCII to include requiered symbols in less
|
||||
* than 255 glyphs. The file ion/include/ion/charset.h lists all added
|
||||
* non-ASCII symbols with their char associated. For example, the char \xa0
|
||||
* refered to Pi symbols. This artefact leads to the following lexer rules
|
||||
* starting with \x. */
|
||||
|
||||
[0-9]+ { poincare_expression_yylval.string.address = yytext; poincare_expression_yylval.string.length = yyleng; return DIGITS; }
|
||||
E { return EE; }
|
||||
@@ -92,8 +97,8 @@ ln { poincare_expression_yylval.expression = new NaperianLogarithm(); return FUN
|
||||
root { poincare_expression_yylval.expression = new NthRoot(); return FUNCTION; }
|
||||
sum { poincare_expression_yylval.expression = new Sum(); return FUNCTION; }
|
||||
product { poincare_expression_yylval.expression = new Product(); return FUNCTION; }
|
||||
Pi { poincare_expression_yylval.character = Symbol::SpecialSymbols::Pi; return SYMBOL; }
|
||||
v { poincare_expression_yylval.expression = new SquareRoot(); return FUNCTION; }
|
||||
\xa0 { poincare_expression_yylval.character = yytext[0]; return SYMBOL; }
|
||||
\xa5 { poincare_expression_yylval.expression = new SquareRoot(); return FUNCTION; }
|
||||
\+ { return PLUS; }
|
||||
\- { return MINUS; }
|
||||
\* { return MULTIPLY; }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <poincare/global_context.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <ion.h>
|
||||
|
||||
GlobalContext::GlobalContext() :
|
||||
m_pi(Float(M_PI))
|
||||
@@ -21,7 +22,7 @@ int GlobalContext::symbolIndex(const Symbol * symbol) const {
|
||||
}
|
||||
|
||||
const Expression * GlobalContext::expressionForSymbol(const Symbol * symbol) {
|
||||
if (symbol->name() == Symbol::SpecialSymbols::Pi) {
|
||||
if (symbol->name() == Ion::Charset::SmallPi) {
|
||||
return &m_pi;
|
||||
}
|
||||
int index = symbolIndex(symbol);
|
||||
|
||||
@@ -35,9 +35,6 @@ ExpressionLayout * Symbol::createLayout() const {
|
||||
if (m_name == SpecialSymbols::Ans) {
|
||||
return new StringLayout("ans", 4);
|
||||
}
|
||||
if (m_name == SpecialSymbols::Pi) {
|
||||
return new StringLayout("Pi", 4);
|
||||
}
|
||||
return new StringLayout(&m_name, 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user