From b02a27fa4bc6712b761b26420d2f7f86d7c86578 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 19 Dec 2014 18:56:57 +0100 Subject: mat: add addition and subtraction operators --- opentrack/simple-mat.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'opentrack/simple-mat.hpp') diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index f1391f3c..158cb30d 100644 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -5,6 +5,24 @@ template struct Mat { num data[h][w]; + + Mat operator+(const Mat& other) const + { + Mat ret; + for (int j = 0; j < h; j++) + for (int i = 0; i < w; i++) + ret(j, i) = this->operator ()(j, i) + other(j, i); + return ret; + } + + Mat operator-(const Mat& other) const + { + Mat ret; + for (int j = 0; j < h; j++) + for (int i = 0; i < w; i++) + ret(j, i) = this->operator ()(j, i) - other(j, i); + return ret; + } template Mat operator*(const Mat& other) const -- cgit v1.2.3