From 5d4f47c3d20739c764a592562d8fcfa03efe2e62 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Mon, 7 Oct 2019 19:40:54 +0300 Subject: [PATCH] Added overloads for vector in-place addition and subtraction --- src/core/math_utils.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/math_utils.h b/src/core/math_utils.h index a7ea2e2..20d1ad0 100644 --- a/src/core/math_utils.h +++ b/src/core/math_utils.h @@ -101,6 +101,14 @@ operator+(const int3& a, const int3& b) return (int3){a.x + b.x, a.y + b.y, a.z + b.z}; } +static HOST_DEVICE_INLINE void +operator+=(AcReal3& lhs, const AcReal3& rhs) +{ + lhs.x += rhs.x; + lhs.y += rhs.y; + lhs.z += rhs.z; +} + static HOST_DEVICE_INLINE AcReal3 operator-(const AcReal3& a, const AcReal3& b) { @@ -119,6 +127,14 @@ operator-(const AcReal3& a) return (AcReal3){-a.x, -a.y, -a.z}; } +static HOST_DEVICE_INLINE void +operator-=(AcReal3& lhs, const AcReal3& rhs) +{ + lhs.x -= rhs.x; + lhs.y -= rhs.y; + lhs.z -= rhs.z; +} + static HOST_DEVICE_INLINE AcReal3 operator*(const AcReal& a, const AcReal3& b) { return (AcReal3){a * b.x, a * b.y, a * b.z};