From ee65fce990b1dc683e1220c18c5f404a82373e55 Mon Sep 17 00:00:00 2001 From: Arnur Nigmetov Date: Tue, 14 Jan 2020 16:17:43 +0100 Subject: Interim: matching distance for modules 1. Templatize DistanceCalculator (DiagramProvider) 2. Add BifiltrationProxy with the same interface as ModulePresentation (dimension fixed). 3. Call Hera with relative error. 4. Add class ModulePresentation. To-Do: reading module presentations from Rivet format. --- matching/include/common_util.h | 43 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'matching/include/common_util.h') 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 #include "common_defs.h" +#include "phat/helpers/misc.h" namespace md { using Real = double; - using Index = long; + using RealVec = std::vector; + using Index = phat::index; + using IndexVec = std::vector; static constexpr Real pi = M_PI; using Column = std::vector; + 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 operator+(const Point& u, const Point& v); Point operator-(const Point& u, const Point& v); -- cgit v1.2.3