From f53f0c3ebb3553543dcd0814d6d1fe54faef030e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 18 Dec 2015 00:54:45 +0100 Subject: api/mat: fix typos/breakage --- opentrack/simple-mat.hpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'opentrack/simple-mat.hpp') diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index 59afbbf0..4f885f4f 100644 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -157,7 +157,7 @@ public: return ret; } - Mat operator*(const num& other) const + Mat operator*(const num other) const { Mat ret; for (int j = 0; j < h_; j++) @@ -167,20 +167,16 @@ public: } template - Mat operator*(const Mat& other) const + Mat operator*(const Mat& other) const { - Mat ret; - for (int j = 0; j < w_; j++) + Mat ret; + for (int k = 0; k < h_; k++) for (int i = 0; i < p; i++) { - num sum = num(0); - - for (int k = 0; k < h_; k++) - sum += data[j][k]*other(k, i); - - ret(j, i) = sum; + ret(k, i) = 0; + for (int j = 0; j < w_; j++) + ret(k, i) += data[k][j] * other(j, i); } - return ret; } @@ -189,7 +185,7 @@ public: template::value>::type> - Mat(ts const&... xs) + Mat(const ts... xs) { const std::initializer_list init = { static_cast(xs)... }; auto iter = init.begin(); @@ -236,7 +232,7 @@ public: for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) - ret.data[i][j] = data[j][i]; + ret(i, j) = data[j][i]; return ret; } -- cgit v1.2.3