mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[poincare] MatrixTranspose
This commit is contained in:
@@ -77,10 +77,10 @@ public:
|
||||
// Inverse the array in-place. Array has to be given in the form array[row_index][column_index]
|
||||
template<typename T> static int ArrayInverse(T * array, int numberOfRows, int numberOfColumns);
|
||||
static Matrix CreateIdentity(int dim);
|
||||
Matrix createTranspose() const;
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
Expression trace() const;
|
||||
Expression determinant() const;
|
||||
Matrix transpose() const;
|
||||
/* createInverse can be called on any matrix reduce or not, approximate or not. */
|
||||
Expression inverse(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const;
|
||||
#endif
|
||||
|
||||
@@ -296,21 +296,21 @@ Matrix Matrix::CreateIdentity(int dim) {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
Matrix Matrix::transpose() const {
|
||||
Matrix matrix();
|
||||
for (int i = 0; i < m_numberOfRows; i++) {
|
||||
for (int j = 0; j < m_numberOfColumns; j++) {
|
||||
matrix.addChildAtIndexInPlace(childAtIndex(i*m_numberOfRows+j), j*m_numberOfRows+i, j*m_numberOfRows+i);
|
||||
|
||||
Matrix Matrix::createTranspose() const {
|
||||
Matrix matrix = Matrix::Builder();
|
||||
for (int j = 0; j < numberOfColumns(); j++) {
|
||||
for (int i = 0; i < numberOfRows(); i++) {
|
||||
matrix.addChildAtIndexInPlace(const_cast<Matrix *>(this)->matrixChild(i, j).clone(), matrix.numberOfChildren(), matrix.numberOfChildren());
|
||||
}
|
||||
}
|
||||
// Intentionally swapping dimensions for transpose
|
||||
matrix.setDimensions(m_numberOfColumns, m_numberOfRows);
|
||||
matrix.setDimensions(numberOfColumns(), numberOfRows());
|
||||
return matrix;
|
||||
}
|
||||
|
||||
Expression Matrix::inverse(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const {
|
||||
#if 0
|
||||
#if MATRIX_EXACT_REDUCINGExpression Matrix::inverse(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const {
|
||||
if (m_numberOfRows != m_numberOfColumns) {
|
||||
return Undefined::Builder();
|
||||
}
|
||||
|
||||
@@ -46,22 +46,17 @@ Expression MatrixTranspose::shallowReduce() {
|
||||
}
|
||||
}
|
||||
Expression c = childAtIndex(0);
|
||||
#if MATRIX_EXACT_REDUCING
|
||||
if (c.type() == ExpressionNode::Type::Matrix) {
|
||||
Matrix transpose = static_cast<Matrix&>(c).createTranspose();
|
||||
return transpose;
|
||||
Expression result = static_cast<Matrix&>(c).createTranspose();
|
||||
replaceWithInPlace(result);
|
||||
return result;
|
||||
}
|
||||
if (!c.recursivelyMatches(Expression::IsMatrix)) {
|
||||
return c;
|
||||
}
|
||||
return *this;
|
||||
#else
|
||||
if (c.type() != ExpressionNode::Type::Matrix) {
|
||||
replaceWithInPlace(c);
|
||||
return c;
|
||||
}
|
||||
return *this;
|
||||
#endif
|
||||
/* TODO LEA
|
||||
if (c.recursivelyMatches(Expression::IsMatrix)) {
|
||||
return *this;
|
||||
}*/
|
||||
replaceWithInPlace(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user