From 48d5a656c996e112fae70c3a209417b9d0982fbf Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 11 Oct 2010 18:08:26 -0400 Subject: Add a simple vector class. --- src/vZ/EquationSystem.hpp | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'src/vZ/EquationSystem.hpp') diff --git a/src/vZ/EquationSystem.hpp b/src/vZ/EquationSystem.hpp index 790676c..5a50f6d 100644 --- a/src/vZ/EquationSystem.hpp +++ b/src/vZ/EquationSystem.hpp @@ -64,6 +64,38 @@ namespace vZ Traits(); }; + // Unary operators + + template + inline EquationSystem + operator+(const EquationSystem& rhs) + { + return rhs; + } + + template + inline EquationSystem + operator-(const EquationSystem& rhs) + { + EquationSystem res; + for (std::size_t i = 0; i < N; ++i) { + res[i] = -rhs[i]; + } + return res; + } + + template + typename EquationSystem::Scalar + abs(const EquationSystem& es) + { + typename EquationSystem::Scalar ret(0); + for (std::size_t i = 0; i < N; ++i) { + using std::abs; + ret = std::max(ret, abs(es[i])); + } + return ret; + } + // Binary operators template @@ -155,18 +187,6 @@ namespace vZ } return *this; } - - template - typename EquationSystem::Scalar - abs(const EquationSystem& es) - { - typename EquationSystem::Scalar ret(0); - for (std::size_t i = 0; i < N; ++i) { - using std::abs; - ret = std::max(ret, abs(es[i])); - } - return ret; - } } #endif // VZ_EQUATIONSYSTEM_HPP -- cgit v1.2.3