mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 22:30:30 +01:00
In the Graph app, define f(x) = cos(x) and g(x)=diff(f(x),x,x). The graph and table are perfectly computed, but in the Calculation apps, g(5) fails.
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#include <poincare/parametered_expression_helper.h>
|
|
#include <poincare/symbol.h>
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
|
|
namespace Poincare {
|
|
|
|
Expression ParameteredExpressionHelper::ReplaceUnknownInExpression(Expression e, const Symbol & symbolToReplace) {
|
|
assert(!e.isUninitialized());
|
|
assert(e.type() == ExpressionNode::Type::Integral
|
|
|| e.type() == ExpressionNode::Type::Derivative
|
|
|| e.type() == ExpressionNode::Type::Sum
|
|
|| e.type() == ExpressionNode::Type::Product);
|
|
assert(!symbolToReplace.isUninitialized());
|
|
assert(symbolToReplace.type() == ExpressionNode::Type::Symbol);
|
|
|
|
int numberOfChildren = e.numberOfChildren();
|
|
assert(numberOfChildren > 2);
|
|
|
|
Expression child1 = e.childAtIndex(1);
|
|
assert(child1.type() == ExpressionNode::Type::Symbol);
|
|
|
|
Symbol& parameterChild = static_cast<Symbol &>(child1);
|
|
if (strcmp(parameterChild.name(), symbolToReplace.name()) != 0) {
|
|
return e.defaultReplaceUnknown(symbolToReplace);
|
|
}
|
|
for (int i = 2; i < numberOfChildren; i++) {
|
|
e.childAtIndex(i).replaceUnknown(symbolToReplace);
|
|
}
|
|
return e;
|
|
}
|
|
|
|
}
|