summaryrefslogtreecommitdiffstats
path: root/src/vZ/EquationSystem.hpp
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-10-11 18:08:26 -0400
committerTavian Barnes <tavianator@gmail.com>2010-10-11 18:08:26 -0400
commit48d5a656c996e112fae70c3a209417b9d0982fbf (patch)
tree797a0fcbcbcfc67be3eac92f8260d38428a20bba /src/vZ/EquationSystem.hpp
parent1f9a9ef19af95bd8433274e4640f1b8b23f56d46 (diff)
downloadvz-48d5a656c996e112fae70c3a209417b9d0982fbf.tar.xz
Add a simple vector class.
Diffstat (limited to 'src/vZ/EquationSystem.hpp')
-rw-r--r--src/vZ/EquationSystem.hpp44
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