From 092d194b95e3d7b1e7e3ae90604d72051a6a1eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Thu, 18 Aug 2016 22:03:29 +0000 Subject: [PATCH] more operators --- COPYING | 2 +- ChangeLog | 22 ++++++++++++++++++++++ INSTALL | 2 +- src/matrix.hxx | 28 ++++++++++++++++++++++------ 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/COPYING b/COPYING index caeca07..88798ab 120000 --- a/COPYING +++ b/COPYING @@ -1 +1 @@ -/usr/share/automake-1.14/COPYING \ No newline at end of file +/usr/share/automake-1.15/COPYING \ No newline at end of file diff --git a/ChangeLog b/ChangeLog index df7a739..9112906 100644 --- a/ChangeLog +++ b/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 * ., AUTHORS, ChangeLog, NEWS, README, autogen.sh, ax_check_qt.m4, diff --git a/INSTALL b/INSTALL index f812f5a..ddcdb76 120000 --- a/INSTALL +++ b/INSTALL @@ -1 +1 @@ -/usr/share/automake-1.14/INSTALL \ No newline at end of file +/usr/share/automake-1.15/INSTALL \ No newline at end of file diff --git a/src/matrix.hxx b/src/matrix.hxx index c4e20e8..f6c3538 100644 --- a/src/matrix.hxx +++ b/src/matrix.hxx @@ -124,6 +124,18 @@ template class MatrixBase { 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 @@ -221,6 +233,16 @@ template class Matrix: return res; } + template + Matrix operator*(const Matrix& o) { + Matrix res; + for (size_t i(0); i class Matrix: public MatrixBase { //============================================================================== -template - Matrix operator+(const Matrix& m1, const Matrix& m2) { - Matrix res(m1); - return res+=m2; -} - template std::ostream& operator<<(std::ostream& s, const Matrix& m) { for (size_t w = 0; w < m.ROWS; ++w) {