From 7f373a5c3c6958ad4eabc8eadbbd10cf2601a9b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 2 May 2019 15:38:33 +0200 Subject: [PATCH] [calculation] Calculations involving matrices display only approximate results and should not toggle the exact output. --- apps/calculation/calculation.cpp | 4 ++++ poincare/src/expression.cpp | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/calculation/calculation.cpp b/apps/calculation/calculation.cpp index 34044090b..a9d718484 100644 --- a/apps/calculation/calculation.cpp +++ b/apps/calculation/calculation.cpp @@ -180,6 +180,10 @@ Calculation::DisplayOutput Calculation::displayOutput(Context * context) { *context, true)) { m_displayOutput = DisplayOutput::ApproximateOnly; + } else if (exactOutput().recursivelyMatches(Expression::IsMatrix, *context, false)) { + /* We do not need to replace symbols here because we recursively test the + * exact output where symbol have already been replaced. */ + m_displayOutput = DisplayOutput::ApproximateOnly; } else if (strcmp(m_exactOutputText, m_approximateOutputText) == 0) { /* If the exact and approximate results' texts are equal and their layouts * too, do not display the exact result. If the two layouts are not equal diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 876913d34..2e40a4249 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -97,8 +97,7 @@ bool Expression::recursivelyMatches(ExpressionTest test, Context & context, bool bool Expression::isApproximate(Context & context) const { return recursivelyMatches([](const Expression e, Context & context, bool replaceSymbols) { return e.type() == ExpressionNode::Type::Decimal - || e.type() == ExpressionNode::Type::Float - || IsMatrix(e, context, replaceSymbols) + || e.type() == ExpressionNode::Type::Float || ((e.type() == ExpressionNode::Type::Symbol || e.type() == ExpressionNode::Type::Function) && replaceSymbols && SymbolAbstract::matches(