summaryrefslogtreecommitdiff
path: root/vector.hpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2020-01-15 19:17:50 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2020-01-15 19:17:50 -0500
commit53f05e5f0bc0b79b4422ecfbb3dde7e346fdddd4 (patch)
tree7dc204f70eef4796812a45621de2b5e2da2c8ce6 /vector.hpp
parent614575bb88a2cadc9e35b684d0f1712de822ef0d (diff)
downloadspace_wolff-53f05e5f0bc0b79b4422ecfbb3dde7e346fdddd4.tar.gz
space_wolff-53f05e5f0bc0b79b4422ecfbb3dde7e346fdddd4.tar.bz2
space_wolff-53f05e5f0bc0b79b4422ecfbb3dde7e346fdddd4.zip
refactor
Diffstat (limited to 'vector.hpp')
-rw-r--r--vector.hpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/vector.hpp b/vector.hpp
new file mode 100644
index 0000000..2e87acd
--- /dev/null
+++ b/vector.hpp
@@ -0,0 +1,20 @@
+
+#pragma once
+
+#include <eigen3/Eigen/Dense>
+
+template <class T, int D> using Vector = Eigen::Matrix<T, D, 1>;
+
+template <class T, int D> Vector<T, D> diff(T L, Vector<T, D> v1, Vector<T, D> v2) {
+ Vector<T, D> v;
+
+ for (unsigned i = 0; i < D; i++) {
+ v(i) = std::abs(v1(i) - v2(i));
+ if (v(i) > L / 2) {
+ v(i) = L - v(i);
+ }
+ }
+
+ return v;
+}
+