summaryrefslogtreecommitdiff
path: root/matching/include/common_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'matching/include/common_util.h')
-rw-r--r--matching/include/common_util.h43
1 files changed, 42 insertions, 1 deletions
diff --git a/matching/include/common_util.h b/matching/include/common_util.h
index 674783b..b2ee22d 100644
--- a/matching/include/common_util.h
+++ b/matching/include/common_util.h
@@ -11,18 +11,51 @@
#include <map>
#include "common_defs.h"
+#include "phat/helpers/misc.h"
namespace md {
using Real = double;
- using Index = long;
+ using RealVec = std::vector<Real>;
+ using Index = phat::index;
+ using IndexVec = std::vector<Index>;
static constexpr Real pi = M_PI;
using Column = std::vector<Index>;
+ struct IntPoint {
+ Index x;
+ Index y;
+
+ IntPoint(Index x, Index y) :x(x), y(y) { }
+
+ IntPoint() :x(0), y(0) { }
+
+ inline bool operator==(const IntPoint& v) const
+ {
+ return this->x == v.x && this->y == v.y;
+ }
+
+ // compare both coordinates, as needed in persistence
+ // do not overload operator<, requirements are not satisfied
+ inline bool is_less(const IntPoint& other, bool strict = false) const
+ {
+ if (x <= other.x and y <= other.y) {
+ if (strict) {
+ return x != other.x or y != other.y;
+ }
+ else {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+
+
struct Point {
Real x;
Real y;
@@ -39,6 +72,12 @@ namespace md {
y /= nor;
}
+ inline void translate(Real a)
+ {
+ x += a;
+ y += a;
+ }
+
inline bool operator==(const Point& v) const
{
return this->x == v.x && this->y == v.y;
@@ -60,6 +99,8 @@ namespace md {
}
};
+ using PointVec = std::vector<Point>;
+
Point operator+(const Point& u, const Point& v);
Point operator-(const Point& u, const Point& v);