diff options
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 |