mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-22 15:20:39 +01:00
[poincare] Update matrix transpose, dimension, inverse, trace
This commit is contained in:
@@ -41,6 +41,10 @@ class Expression : public TreeByReference {
|
||||
friend class Integral;
|
||||
friend class LeastCommonMultiple;
|
||||
friend class Logarithm;
|
||||
friend class MatrixDimension;
|
||||
friend class MatrixInverse;
|
||||
friend class MatrixTrace;
|
||||
friend class MatrixTranspose;
|
||||
|
||||
friend class Sine;
|
||||
friend class Store;
|
||||
|
||||
@@ -48,4 +48,3 @@ public:
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -40,9 +40,11 @@ Evaluation<T> MatrixDimensionNode::templatedApproximate(Context& context, Prefer
|
||||
}
|
||||
|
||||
Expression MatrixDimension::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) {
|
||||
Expression e = Expression::defaultShallowReduce(context, angleUnit);
|
||||
if (e.isUndefinedOrAllocationFailure()) {
|
||||
return e;
|
||||
{
|
||||
Expression e = Expression::defaultShallowReduce(context, angleUnit);
|
||||
if (e.isUndefinedOrAllocationFailure()) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
@@ -68,6 +70,7 @@ Expression MatrixDimension::shallowReduce(Context & context, Preferences::AngleU
|
||||
result.addChildAtIndexInPlace(Rational(1), 0, 0);
|
||||
result.addChildAtIndexInPlace(Rational(1), 1, 1);
|
||||
result.setDimensions(1, 2);
|
||||
replaceWithInPlace(result);
|
||||
return result;
|
||||
}
|
||||
return *this;
|
||||
|
||||
@@ -45,9 +45,11 @@ Evaluation<T> MatrixInverseNode::templatedApproximate(Context& context, Preferen
|
||||
}
|
||||
|
||||
Expression MatrixInverse::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) {
|
||||
Expression e = Expression::defaultShallowReduce(context, angleUnit);
|
||||
if (e.isUndefinedOrAllocationFailure()) {
|
||||
return e;
|
||||
{
|
||||
Expression e = Expression::defaultShallowReduce(context, angleUnit);
|
||||
if (e.isUndefinedOrAllocationFailure()) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
@@ -63,7 +65,9 @@ Expression MatrixInverse::shallowReduce(Context & context, Preferences::AngleUni
|
||||
return *this;
|
||||
#else
|
||||
if (c.type() != ExpressionNode::Type::Matrix) {
|
||||
return Power(c, Rational(-1)).shallowReduce(context, angleUnit);
|
||||
Expression result = Power(c, Rational(-1)).shallowReduce(context, angleUnit);
|
||||
replaceWithInPlace(result);
|
||||
return result;
|
||||
}
|
||||
return *this;
|
||||
#endif
|
||||
|
||||
@@ -35,9 +35,11 @@ Evaluation<T> MatrixTraceNode::templatedApproximate(Context& context, Preference
|
||||
}
|
||||
|
||||
Expression MatrixTrace::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) {
|
||||
Expression e = Expression::defaultShallowReduce(context, angleUnit);
|
||||
if (e.isUndefinedOrAllocationFailure()) {
|
||||
return e;
|
||||
{
|
||||
Expression e = Expression::defaultShallowReduce(context, angleUnit);
|
||||
if (e.isUndefinedOrAllocationFailure()) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
@@ -59,6 +61,7 @@ Expression MatrixTrace::shallowReduce(Context & context, Preferences::AngleUnit
|
||||
return *this;
|
||||
#else
|
||||
if (c.type() != ExpressionNode::Type::Matrix) {
|
||||
replaceWithInPlace(c);
|
||||
return c;
|
||||
}
|
||||
return *this;
|
||||
|
||||
@@ -39,9 +39,11 @@ Evaluation<T> MatrixTransposeNode::templatedApproximate(Context& context, Prefer
|
||||
}
|
||||
|
||||
Expression MatrixTranspose::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) {
|
||||
Expression e = Expression::defaultShallowReduce(context, angleUnit);
|
||||
if (e.isUndefinedOrAllocationFailure()) {
|
||||
return e;
|
||||
{
|
||||
Expression e = Expression::defaultShallowReduce(context, angleUnit);
|
||||
if (e.isUndefinedOrAllocationFailure()) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
@@ -55,6 +57,7 @@ Expression MatrixTranspose::shallowReduce(Context & context, Preferences::AngleU
|
||||
return *this;
|
||||
#else
|
||||
if (c.type() != ExpressionNode::Type::Matrix) {
|
||||
replaceWithInPlace(c);
|
||||
return c;
|
||||
}
|
||||
return *this;
|
||||
|
||||
Reference in New Issue
Block a user