summaryrefslogtreecommitdiff
path: root/vector.hpp
diff options
context:
space:
mode:
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;
+}
+