[poincare] Fix shallowReduce that return Undefined

This commit is contained in:
Léa Saviot
2019-07-03 17:13:44 +02:00
committed by Émilie Feral
parent 1bce23ccda
commit c525386e4c
4 changed files with 12 additions and 4 deletions

View File

@@ -65,7 +65,9 @@ Expression BinomialCoefficient::shallowReduce(Context * context) {
Expression c1 = childAtIndex(1);
if (SortedIsMatrix(c0, context) || SortedIsMatrix(c1, context)) {
return Undefined::Builder();
Expression result = Undefined::Builder();
replaceWithInPlace(result);
return result;
}
if (c0.type() == ExpressionNode::Type::Rational) {

View File

@@ -62,7 +62,9 @@ Expression ConfidenceInterval::shallowReduce(ExpressionNode::ReductionContext re
Expression c0 = childAtIndex(0);
Expression c1 = childAtIndex(1);
if (SortedIsMatrix(c0, reductionContext.context()) || SortedIsMatrix(c1, reductionContext.context())) {
return Undefined::Builder();
Expression result = Undefined::Builder();
replaceWithInPlace(result);
return result;
}
if (c0.type() == ExpressionNode::Type::Rational) {
Rational r0 = static_cast<Rational&>(c0);

View File

@@ -146,7 +146,9 @@ Expression Derivative::shallowReduce(Context * context) {
|| SortedIsMatrix(childAtIndex(1), context)
|| SortedIsMatrix(childAtIndex(2), context))
{
return Undefined::Builder();
Expression result = Undefined::Builder();
replaceWithInPlace(result);
return result;
}
// TODO: to be implemented diff(+) -> +diff() etc
return *this;

View File

@@ -225,7 +225,9 @@ Expression Integral::shallowReduce(Context * context) {
|| SortedIsMatrix(childAtIndex(2), context)
|| SortedIsMatrix(childAtIndex(3), context))
{
return Undefined::Builder();
Expression result = Undefined::Builder();
replaceWithInPlace(result);
return result;
}
return *this;
}