summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-11-01 13:50:05 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-11-01 13:50:05 +0100
commit85e31eaad0ee25d71d025bdf50a92d59b3b797bb (patch)
tree0e41ad1baa6baaf7630fddf39944b181eab3ab83 /compat
parent2de33bda4758281b8c25d2786fd68769453bee3d (diff)
compat/mat: add elementwise mult
Diffstat (limited to 'compat')
-rw-r--r--compat/simple-mat.hpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/compat/simple-mat.hpp b/compat/simple-mat.hpp
index 5bc26a62..a806448b 100644
--- a/compat/simple-mat.hpp
+++ b/compat/simple-mat.hpp
@@ -199,6 +199,17 @@ public:
return ret;
}
+ constexpr Mat<num, h_, w_> mult_elementwise(const Mat<num, h_, w_>& other) const&
+ {
+ Mat<num, h_, w_> ret;
+
+ for (unsigned j = 0; j < h_; j++)
+ for (unsigned i = 0; i < w_; i++)
+ ret(j, i) = data[j][i] * other.data[j][i];
+
+ return ret;
+ }
+
constexpr inline num operator()(int j, int i) const& { return data[j][i]; }
constexpr inline num& operator()(int j, int i) & { return data[j][i]; }