diff --git a/geometry/src/algebra.hpp b/geometry/src/algebra.hpp index 89a2406..5ffd37d 100644 --- a/geometry/src/algebra.hpp +++ b/geometry/src/algebra.hpp @@ -224,6 +224,7 @@ struct algebra return multivector>{x, y}; } } + friend constexpr auto& operator+=(blade& x, blade y) { return x = x + y; } /// @} /// subtraction @@ -236,6 +237,7 @@ struct algebra { return x + -y; } + friend constexpr auto& operator-=(blade& x, blade y) { return x = x - y; } /// @} /// scalar multiplication diff --git a/test/algebra_blade_test.cpp b/test/algebra_blade_test.cpp index df26896..2fe48cd 100644 --- a/test/algebra_blade_test.cpp +++ b/test/algebra_blade_test.cpp @@ -59,6 +59,18 @@ auto main() -> int "blade subtraction"_ctest * param_ref = // [](auto ei) { return expect(eq(ei, 3 * ei - 2 * ei)); }; + "blade addition assignment"_ctest * param_ref = // + [](auto ei) { + auto x = ei; + return expect(eq(3 * ei, x += 2 * ei)); + }; + + "blade subtraction assignment"_ctest * param_ref = // + [](auto ei) { + auto x = ei; + return expect(eq(-ei, x -= 2 * ei)); + }; + "blade uses canonical dimensions"_ctest = [] { return expect( eq(-e<1, 0>, e<0, 1>) and //