mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare] Fix: always attach to parent before shallow reducing an
expression
This commit is contained in:
@@ -49,6 +49,7 @@ Expression MatrixInverse::shallowReduce(Context & context, Preferences::AngleUni
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
#if 0
|
||||
if (!c.recursivelyMatches(Expression::IsMatrix)) {
|
||||
return Power(c, Rational(-1).shallowReduce(context, angleUnit);
|
||||
}
|
||||
@@ -59,10 +60,12 @@ Expression MatrixInverse::shallowReduce(Context & context, Preferences::AngleUni
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
#endif
|
||||
#else
|
||||
if (c.type() != ExpressionNode::Type::Matrix) {
|
||||
Expression result = Power(c, Rational(-1)).shallowReduce(context, angleUnit);
|
||||
Expression result = Power(c, Rational(-1));
|
||||
replaceWithInPlace(result);
|
||||
result = result.shallowReduce(context, angleUnit);
|
||||
return result;
|
||||
}
|
||||
return *this;
|
||||
|
||||
@@ -39,6 +39,7 @@ Expression MatrixTrace::shallowReduce(Context & context, Preferences::AngleUnit
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
#if 0
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
Matrix m = static_cast<Matrix&>(c);
|
||||
if (m.numberOfRows() != m.numberOfColumns()) {
|
||||
@@ -55,6 +56,7 @@ Expression MatrixTrace::shallowReduce(Context & context, Preferences::AngleUnit
|
||||
return c;
|
||||
}
|
||||
return *this;
|
||||
#endif
|
||||
#else
|
||||
if (c.type() != ExpressionNode::Type::Matrix) {
|
||||
replaceWithInPlace(c);
|
||||
|
||||
@@ -24,9 +24,8 @@ Expression NaperianLogarithm::shallowReduce(Context & context, Preferences::Angl
|
||||
}
|
||||
#endif
|
||||
Logarithm l = Logarithm(childAtIndex(0), Symbol(Ion::Charset::Exponential));
|
||||
Expression result = l.shallowReduce(context, angleUnit);
|
||||
replaceWithInPlace(result);
|
||||
return result;
|
||||
replaceWithInPlace(l);
|
||||
return l.shallowReduce(context, angleUnit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@ Expression SimplificationHelper::Map(const Expression & e, Context & context, Pr
|
||||
Matrix matrix;
|
||||
for (int i = 0; i < c->numberOfChildren(); i++) {
|
||||
Expression f = e.replaceChildAtIndexInPlace(0, e.childAtIndex(0).childAtIndex(i));
|
||||
matrix.addChildAtIndexInPlace(f.shallowReduce(context, angleUnit), i, i);
|
||||
matrix.addChildAtIndexInPlace(f, i, i);
|
||||
f.shallowReduce(context, angleUnit);
|
||||
}
|
||||
replaceWithInPlace(matrix);
|
||||
return matrix.shallowReduce(context, angleUnit);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user