mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Simplify expressions in sequence and function applications
Change-Id: I2708934d3b5c90e8692e50d939b3a13028b8615e
This commit is contained in:
@@ -69,16 +69,23 @@ const char * Function::name() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
Poincare::Expression * Function::expression() const {
|
||||
Poincare::Expression * Function::expression(Poincare::Context * context) const {
|
||||
if (m_expression == nullptr) {
|
||||
m_expression = Expression::parse(m_text);
|
||||
if (m_expression) {
|
||||
Expression::Simplify(&m_expression, *context);
|
||||
}
|
||||
}
|
||||
return m_expression;
|
||||
}
|
||||
|
||||
Poincare::ExpressionLayout * Function::layout() {
|
||||
if (m_layout == nullptr && expression() != nullptr) {
|
||||
m_layout = expression()->createLayout(Expression::FloatDisplayMode::Decimal);
|
||||
if (m_layout == nullptr) {
|
||||
Expression * nonSimplifiedExpression = Expression::parse(m_text);
|
||||
if (nonSimplifiedExpression != nullptr) {
|
||||
m_layout = nonSimplifiedExpression->createLayout(Expression::FloatDisplayMode::Decimal);
|
||||
delete nonSimplifiedExpression;
|
||||
}
|
||||
}
|
||||
return m_layout;
|
||||
}
|
||||
@@ -105,7 +112,7 @@ T Function::templatedApproximateAtAbscissa(T x, Poincare::Context * context) con
|
||||
Poincare::Symbol xSymbol(symbol());
|
||||
Poincare::Complex<T> e = Poincare::Complex<T>::Float(x);
|
||||
variableContext.setExpressionForSymbolName(&e, &xSymbol, variableContext);
|
||||
return expression()->approximateToScalar<T>(variableContext);
|
||||
return expression(context)->approximateToScalar<T>(variableContext);
|
||||
}
|
||||
|
||||
void Function::tidy() {
|
||||
|
||||
Reference in New Issue
Block a user