[poincare] Fix Multiplication between 0 and a unreduced matrix: it

should not be equal to 0 but to Matrix(0)
This commit is contained in:
Émilie Feral
2020-06-03 14:34:31 +02:00
parent 420dd04766
commit 4b83da21b7
2 changed files with 2 additions and 2 deletions

View File

@@ -698,7 +698,7 @@ Expression Multiplication::privateShallowReduce(ExpressionNode::ReductionContext
} else if (c.type() != ExpressionNode::Type::Rational) {
} else if (static_cast<const Rational &>(c).isZero()) {
// Check that other children don't match inf or unit
if (!recursivelyMatches(IsInfinity, context)) {
if (!recursivelyMatches([](const Expression e, Context * context) { return IsInfinity(e, context) || IsMatrix(e, context); }, context)) {
replaceWithInPlace(c);
return c;
}

View File

@@ -192,7 +192,7 @@ QUIZ_CASE(poincare_simplification_multiplication) {
assert_parsed_expression_simplify_to("[[1,2+𝐢][3,4][5,6]]×[[1,2+𝐢,3,4][5,6+𝐢,7,8]]", "[[11+5×𝐢,13+9×𝐢,17+7×𝐢,20+8×𝐢][23,30+7×𝐢,37,44][35,46+11×𝐢,57,68]]");
assert_parsed_expression_simplify_to("[[1,2][3,4]]×[[1,3][5,6]]×[[2,3][4,6]]", "[[82,123][178,267]]");
assert_parsed_expression_simplify_to("π×confidence(π/5,3)[[1,2]]", "π×confidence(π/5,3)×[[1,2]]");
assert_parsed_expression_simplify_to("0*[[1,0][0,1]]^500", "0*[[1,0][0,1]]^500");
assert_parsed_expression_simplify_to("0*[[1,0][0,1]]^500", "0×[[1,0][0,1]]^500");
}
QUIZ_CASE(poincare_simplification_units) {