summaryrefslogtreecommitdiffhomepage
path: root/opentrack/simple-mat.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-12-19 18:56:57 +0100
committerStanislaw Halik <sthalik@misaki.pl>2014-12-19 18:56:57 +0100
commitb02a27fa4bc6712b761b26420d2f7f86d7c86578 (patch)
tree3ff51a626938dabd4c33c85f128073c933aefcfe /opentrack/simple-mat.hpp
parent4e6f0d11c62318d70147ac0bee16f3377114e0db (diff)
mat: add addition and subtraction operators
Diffstat (limited to 'opentrack/simple-mat.hpp')
-rw-r--r--opentrack/simple-mat.hpp18
1 files changed, 18 insertions, 0 deletions
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<typename num, int h, int w>
struct Mat
{
num data[h][w];
+
+ Mat<num, h, w> operator+(const Mat<num, h, w>& other) const
+ {
+ Mat<num, h, w> 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<num, h, w> operator-(const Mat<num, h, w>& other) const
+ {
+ Mat<num, h, w> 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<int p>
Mat<num, w, p> operator*(const Mat<num, w, p>& other) const