From 85e31eaad0ee25d71d025bdf50a92d59b3b797bb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Nov 2017 13:50:05 +0100 Subject: compat/mat: add elementwise mult --- compat/simple-mat.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 mult_elementwise(const Mat& other) const& + { + Mat 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]; } -- cgit v1.2.3