From 127b154aa45a5130ac6c476a07f72c085c3d94c8 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Tue, 19 Jun 2018 19:29:26 +0200 Subject: [PATCH] Added self multiplication by a T --- src/algebra/TinyVector.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/algebra/TinyVector.hpp b/src/algebra/TinyVector.hpp index 038741231..34b73118b 100644 --- a/src/algebra/TinyVector.hpp +++ b/src/algebra/TinyVector.hpp @@ -68,6 +68,15 @@ public: return std::move(t); } + KOKKOS_INLINE_FUNCTION + TinyVector& operator*=(const T& t) + { + for (size_t i=0; i<N; ++i) { + m_values[i] *= t; + } + return *this; + } + KOKKOS_INLINE_FUNCTION friend TinyVector operator*(const T& t, const TinyVector& v) { @@ -81,9 +90,7 @@ public: KOKKOS_INLINE_FUNCTION friend TinyVector operator*(const T& t, TinyVector&& v) { - for (size_t i=0; i<N; ++i) { - v.m_values[i] *= t; - } + v *= t; return std::move(v); } -- GitLab