diff options
author | Arnur Nigmetov <nigmetov@tugraz.at> | 2020-01-14 16:17:43 +0100 |
---|---|---|
committer | Arnur Nigmetov <nigmetov@tugraz.at> | 2020-02-18 15:02:39 +0100 |
commit | ee65fce990b1dc683e1220c18c5f404a82373e55 (patch) | |
tree | 6c4aabba39f4f302024d17ff088d14653a12563e /matching/include/common_util.h | |
parent | 6942d80c4d49239bca9cace9833aa74aee11ddcb (diff) |
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.
Diffstat (limited to 'matching/include/common_util.h')
-rw-r--r-- | matching/include/common_util.h | 43 |
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); |