mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/poincare] Do not replace symbols in result of 3+c->f(x)
This commit is contained in:
@@ -42,7 +42,7 @@ void Calculation::setContent(const char * c, Context * context, Expression ansEx
|
||||
* to keep Ans symbol in the calculation store. */
|
||||
PoincareHelpers::Serialize(input, m_inputText, sizeof(m_inputText));
|
||||
}
|
||||
Expression exactOutput = PoincareHelpers::ParseAndSimplify(m_inputText, *context);
|
||||
Expression exactOutput = PoincareHelpers::ParseAndSimplify(m_inputText, *context, false);
|
||||
PoincareHelpers::Serialize(exactOutput, m_exactOutputText, sizeof(m_exactOutputText));
|
||||
Expression approximateOutput = PoincareHelpers::Approximate<double>(exactOutput, *context);
|
||||
PoincareHelpers::Serialize(approximateOutput, m_approximateOutputText, sizeof(m_approximateOutputText));
|
||||
|
||||
@@ -37,8 +37,8 @@ inline T ApproximateToScalar(const char * text, Poincare::Context & context) {
|
||||
return Poincare::Expression::approximateToScalar<T>(text, context, Poincare::Preferences::sharedPreferences()->angleUnit());
|
||||
}
|
||||
|
||||
inline Poincare::Expression ParseAndSimplify(const char * text, Poincare::Context & context) {
|
||||
return Poincare::Expression::ParseAndSimplify(text, context, Poincare::Preferences::sharedPreferences()->angleUnit());
|
||||
inline Poincare::Expression ParseAndSimplify(const char * text, Poincare::Context & context, bool replaceSymbols = true) {
|
||||
return Poincare::Expression::ParseAndSimplify(text, context, Poincare::Preferences::sharedPreferences()->angleUnit(), replaceSymbols);
|
||||
}
|
||||
|
||||
inline void Simplify(Poincare::Expression * e, Poincare::Context & context) {
|
||||
|
||||
@@ -162,8 +162,8 @@ public:
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const;
|
||||
|
||||
/* Simplification */
|
||||
static Expression ParseAndSimplify(const char * text, Context & context, Preferences::AngleUnit angleUnit);
|
||||
Expression simplify(Context & context, Preferences::AngleUnit angleUnit);
|
||||
static Expression ParseAndSimplify(const char * text, Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
|
||||
Expression simplify(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
|
||||
Expression deepReduce(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols = true);
|
||||
void reduceChildren(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols) {
|
||||
return node()->reduceChildren(context, angleUnit, replaceSymbols);
|
||||
|
||||
@@ -270,12 +270,12 @@ int Expression::serialize(char * buffer, int bufferSize, Preferences::PrintFloat
|
||||
|
||||
/* Simplification */
|
||||
|
||||
Expression Expression::ParseAndSimplify(const char * text, Context & context, Preferences::AngleUnit angleUnit) {
|
||||
Expression Expression::ParseAndSimplify(const char * text, Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols) {
|
||||
Expression exp = parse(text);
|
||||
if (exp.isUninitialized()) {
|
||||
return Undefined();
|
||||
}
|
||||
exp = exp.simplify(context, angleUnit);
|
||||
exp = exp.simplify(context, angleUnit, replaceSymbols);
|
||||
/* simplify might have been interrupted, in which case the resulting
|
||||
* expression is uninitialized, so we need to check that. */
|
||||
if (exp.isUninitialized()) {
|
||||
@@ -284,7 +284,7 @@ Expression Expression::ParseAndSimplify(const char * text, Context & context, Pr
|
||||
return exp;
|
||||
}
|
||||
|
||||
Expression Expression::simplify(Context & context, Preferences::AngleUnit angleUnit) {
|
||||
Expression Expression::simplify(Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols) {
|
||||
sSimplificationHasBeenInterrupted = false;
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
#else
|
||||
@@ -292,7 +292,7 @@ Expression Expression::simplify(Context & context, Preferences::AngleUnit angleU
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
Expression e = deepReduce(context, angleUnit);
|
||||
Expression e = deepReduce(context, angleUnit, replaceSymbols);
|
||||
e = e.deepBeautify(context, angleUnit);
|
||||
if (sSimplificationHasBeenInterrupted) {
|
||||
e = Expression();
|
||||
|
||||
@@ -62,9 +62,9 @@ Expression Store::shallowReduce(Context & context, Preferences::AngleUnit angleU
|
||||
}
|
||||
finalValue = finalValue.deepReduce(context, angleUnit, false);
|
||||
context.setExpressionForSymbol(finalValue, symbol(), context);
|
||||
Expression c1 = childAtIndex(1);
|
||||
replaceWithInPlace(c1);
|
||||
return c1.shallowReduce(context, angleUnit, replaceSymbols);
|
||||
Expression e = context.expressionForSymbol(symbol());
|
||||
replaceWithInPlace(e);
|
||||
return e.shallowReduce(context, angleUnit, replaceSymbols);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user