|
|
@ -124,6 +124,18 @@ template<typename TYPE, typename ARRAY=TYPE*> class MatrixBase { |
|
|
|
return *this; |
|
|
|
return *this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MatrixBase& operator*=(const TYPE& o) { |
|
|
|
|
|
|
|
TYPE *res((TYPE*)(_c)+SIZE); |
|
|
|
|
|
|
|
while (res>(TYPE*)(_c)) *--res *= o; |
|
|
|
|
|
|
|
return *this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MatrixBase& operator/=(const TYPE& o) { |
|
|
|
|
|
|
|
TYPE *res((TYPE*)(_c)+SIZE); |
|
|
|
|
|
|
|
while (res>(TYPE*)(_c)) *--res /= o; |
|
|
|
|
|
|
|
return *this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///}
|
|
|
|
///}
|
|
|
|
|
|
|
|
|
|
|
|
/// @name element access
|
|
|
|
/// @name element access
|
|
|
@ -221,6 +233,16 @@ template<typename TYPE, size_t TROWS=0, size_t TCOLUMNS=0> class Matrix: |
|
|
|
return res; |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<size_t NEWCOLUMNS> |
|
|
|
|
|
|
|
Matrix operator*(const Matrix<TYPE, TCOLUMNS, NEWCOLUMNS>& o) { |
|
|
|
|
|
|
|
Matrix<TYPE, TROWS, NEWCOLUMNS> res; |
|
|
|
|
|
|
|
for (size_t i(0); i<TROWS; ++i) |
|
|
|
|
|
|
|
for (size_t k(0); k<NEWCOLUMNS; ++k) |
|
|
|
|
|
|
|
for (size_t j(0); j<TCOLUMNS; ++j) |
|
|
|
|
|
|
|
res(i, k) += (*this)(i, j) * o(j, k); |
|
|
|
|
|
|
|
return res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
//==============================================================================
|
|
|
@ -321,12 +343,6 @@ template<typename TYPE> class Matrix<TYPE, 0, 0>: public MatrixBase<TYPE> { |
|
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TYPE, size_t ROWS, size_t COLUMNS> |
|
|
|
|
|
|
|
Matrix<TYPE, ROWS, COLUMNS> operator+(const Matrix<TYPE, ROWS, COLUMNS>& m1, const Matrix<TYPE, ROWS, COLUMNS>& m2) { |
|
|
|
|
|
|
|
Matrix<TYPE, ROWS, COLUMNS> res(m1); |
|
|
|
|
|
|
|
return res+=m2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TYPE, size_t ROWS, size_t COLUMNS> |
|
|
|
template<typename TYPE, size_t ROWS, size_t COLUMNS> |
|
|
|
std::ostream& operator<<(std::ostream& s, const Matrix<TYPE, ROWS, COLUMNS>& m) { |
|
|
|
std::ostream& operator<<(std::ostream& s, const Matrix<TYPE, ROWS, COLUMNS>& m) { |
|
|
|
for (size_t w = 0; w < m.ROWS; ++w) { |
|
|
|
for (size_t w = 0; w < m.ROWS; ++w) { |
|
|
|