more operators
This commit is contained in:
22
ChangeLog
22
ChangeLog
@@ -1,3 +1,25 @@
|
|||||||
|
2016-08-16 14:41
|
||||||
|
|
||||||
|
* COPYING, INSTALL, ax_init_standard_project.m4, configure.ac,
|
||||||
|
src/matrix.hxx, test/basic.cxx: remove redundancy, collect common
|
||||||
|
functionality in base class
|
||||||
|
|
||||||
|
2016-08-08 20:03
|
||||||
|
|
||||||
|
* src/matrix.hxx, test/basic.cxx: more operator, more checks passed
|
||||||
|
|
||||||
|
2016-08-03 18:43
|
||||||
|
|
||||||
|
* configure.ac, test/makefile.am: all tests passed
|
||||||
|
|
||||||
|
2016-08-03 18:39
|
||||||
|
|
||||||
|
* COPYING, ChangeLog, INSTALL, ax_cxx_compile_stdcxx_11.m4,
|
||||||
|
ax_init_standard_project.m4, configure.ac, examples/makefile.am,
|
||||||
|
examples/matrix-sample.cxx, src/makefile.am, src/matrix.hxx,
|
||||||
|
test/basic.cxx, test/makefile.am: first approach including first
|
||||||
|
tests
|
||||||
|
|
||||||
2016-07-30 08:50
|
2016-07-30 08:50
|
||||||
|
|
||||||
* ., AUTHORS, ChangeLog, NEWS, README, autogen.sh, ax_check_qt.m4,
|
* ., AUTHORS, ChangeLog, NEWS, README, autogen.sh, ax_check_qt.m4,
|
||||||
|
@@ -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) {
|
||||||
|
Reference in New Issue
Block a user