diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-10-11 18:08:26 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-10-11 18:08:26 -0400 |
commit | 48d5a656c996e112fae70c3a209417b9d0982fbf (patch) | |
tree | 797a0fcbcbcfc67be3eac92f8260d38428a20bba /src/vZ/EquationSystem.hpp | |
parent | 1f9a9ef19af95bd8433274e4640f1b8b23f56d46 (diff) | |
download | vz-48d5a656c996e112fae70c3a209417b9d0982fbf.tar.xz |
Add a simple vector class.
Diffstat (limited to 'src/vZ/EquationSystem.hpp')
-rw-r--r-- | src/vZ/EquationSystem.hpp | 44 |
1 files changed, 32 insertions, 12 deletions
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 <std::size_t N, typename T> + inline EquationSystem<N, T> + operator+(const EquationSystem<N, T>& rhs) + { + return rhs; + } + + template <std::size_t N, typename T> + inline EquationSystem<N, T> + operator-(const EquationSystem<N, T>& rhs) + { + EquationSystem<N, T> res; + for (std::size_t i = 0; i < N; ++i) { + res[i] = -rhs[i]; + } + return res; + } + + template <std::size_t N, typename T> + typename EquationSystem<N, T>::Scalar + abs(const EquationSystem<N, T>& es) + { + typename EquationSystem<N, T>::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 <std::size_t N, typename T> @@ -155,18 +187,6 @@ namespace vZ } return *this; } - - template <std::size_t N, typename T> - typename EquationSystem<N, T>::Scalar - abs(const EquationSystem<N, T>& es) - { - typename EquationSystem<N, T>::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 |