[poincare] Fix Expression::IsMatrix

Change-Id: I7956ba5c293431f91020e2211245da8fafdd5e1b
This commit is contained in:
Émilie Feral
2017-11-17 11:36:10 +01:00
parent bfcd1377e6
commit b3f8156cfe
7 changed files with 8 additions and 8 deletions

View File

@@ -186,7 +186,7 @@ public:
virtual Sign sign() const { return Sign::Unknown; }
typedef bool (*ExpressionTest)(const Expression * e);
bool recursivelyMatches(ExpressionTest test) const;
static bool isMatrix(const Expression * e);
static bool IsMatrix(const Expression * e);
/* Comparison */
/* isIdenticalTo is the "easy" equality, it returns true if both trees have

View File

@@ -22,7 +22,7 @@ Expression * Determinant::shallowReduce(Context& context, AngleUnit angleUnit) {
return e;
}
Expression * op = editableOperand(0);
if (!op->recursivelyMatches(Expression::isMatrix)) {
if (!op->recursivelyMatches(Expression::IsMatrix)) {
return replaceWith(op, true);
}
return this;

View File

@@ -88,8 +88,8 @@ bool Expression::recursivelyMatches(ExpressionTest test) const {
return false;
}
bool Expression::isMatrix(const Expression * e) {
return e->type() == Type::Matrix || e->type() == Type::ConfidenceInterval || e->type() == Type::MatrixDimension || e->type() == Type::PredictionInterval;
bool Expression::IsMatrix(const Expression * e) {
return e->type() == Type::Matrix || e->type() == Type::ConfidenceInterval || e->type() == Type::MatrixDimension || e->type() == Type::PredictionInterval || e->type() == Type::MatrixInverse || e->type() == Type::MatrixTranspose;
}
/* Comparison */

View File

@@ -27,7 +27,7 @@ Expression * MatrixDimension::shallowReduce(Context& context, AngleUnit angleUni
const Expression * newOperands[2] = {new Rational(m->numberOfRows()), new Rational(m->numberOfColumns())};
return replaceWith(new Matrix(newOperands, 1, 2, false), true);
}
if (!op->recursivelyMatches(Expression::isMatrix)) {
if (!op->recursivelyMatches(Expression::IsMatrix)) {
const Expression * newOperands[2] = {new Rational(1), new Rational(1)};
return replaceWith(new Matrix(newOperands, 1, 2, false), true);
}

View File

@@ -26,7 +26,7 @@ Expression * MatrixInverse::shallowReduce(Context& context, AngleUnit angleUnit)
return e;
}
Expression * op = editableOperand(0);
if (!op->recursivelyMatches(Expression::isMatrix)) {
if (!op->recursivelyMatches(Expression::IsMatrix)) {
detachOperand(op);
return replaceWith(new Power(op, new Rational(-1), false), true)->shallowReduce(context, angleUnit);
}

View File

@@ -38,7 +38,7 @@ Expression * MatrixTrace::shallowReduce(Context& context, AngleUnit angleUnit) {
}
return replaceWith(a, true)->shallowReduce(context, angleUnit);
}
if (!op->recursivelyMatches(Expression::isMatrix)) {
if (!op->recursivelyMatches(Expression::IsMatrix)) {
return replaceWith(op, true);
}
return this;

View File

@@ -28,7 +28,7 @@ Expression * MatrixTranspose::shallowReduce(Context& context, AngleUnit angleUni
Matrix * transpose = static_cast<Matrix *>(op)->createTranspose();
return replaceWith(transpose, true);
}
if (!op->recursivelyMatches(Expression::isMatrix)) {
if (!op->recursivelyMatches(Expression::IsMatrix)) {
return replaceWith(op, true);
}
return this;