TTK
Loading...
Searching...
No Matches
BottleneckDistance.h
Go to the documentation of this file.
1
4#pragma once
5
6// base code includes
7#include <Debug.h>
9
10namespace ttk {
11 constexpr unsigned long long str2int(const char *str, int h = 0) {
12 return !str[h] ? 5381 : (str2int(str, h + 1) * 33) ^ str[h];
13 }
14
15 class BottleneckDistance : virtual public Debug {
16 public:
18
19 int execute(const ttk::DiagramType &diag0,
20 const ttk::DiagramType &diag1,
21 std::vector<MatchingType> &matchings);
22
23 inline void setPersistencePercentThreshold(const double t) {
24 Tolerance = t;
25 }
26 inline void setPX(const double px) {
27 PX = px;
28 }
29 inline void setPY(const double py) {
30 PY = py;
31 }
32 inline void setPZ(const double pz) {
33 PZ = pz;
34 }
35 inline void setPE(const double pe) {
36 PE = pe;
37 }
38 inline void setPS(const double ps) {
39 PS = ps;
40 }
41 inline void setAlgorithm(const std::string &algorithm) {
42 DistanceAlgorithm = algorithm;
43 }
44 inline void setPVAlgorithm(const int algorithm) {
45 PVAlgorithm = algorithm;
46 }
47 inline void setWasserstein(const std::string &wasserstein) {
48 WassersteinMetric = wasserstein;
49 }
50
51 double getDistance() {
52 return distance_;
53 }
54
55 protected:
56 double distance_{-1.0};
57 std::array<double, 3> costs_{};
58
59 std::string WassersteinMetric{"2"};
60 std::string DistanceAlgorithm{};
61 int PVAlgorithm{-1};
62 double Tolerance{1.0};
63 double PX{0.0};
64 double PY{0.0};
65 double PZ{0.0};
66 double PE{1.0};
67 double PS{1.0};
68
69 private:
70 int computeBottleneck(const ttk::DiagramType &d1,
71 const ttk::DiagramType &d2,
72 std::vector<MatchingType> &matchings);
73
74 double computeGeometricalRange(const ttk::DiagramType &CTDiagram1,
75 const ttk::DiagramType &CTDiagram2) const;
76
77 double computeMinimumRelevantPersistence(
78 const ttk::DiagramType &CTDiagram1,
79 const ttk::DiagramType &CTDiagram2) const;
80
81 double distanceFunction(const PersistencePair &a,
82 const PersistencePair &b,
83 const int wasserstein) const;
84 double diagonalDistanceFunction(const PersistencePair &a,
85 const int wasserstein) const;
86
87 void computeMinMaxSaddleNumberAndMapping(const ttk::DiagramType &CTDiagram,
88 int &nbMin,
89 int &nbMax,
90 int &nbSaddle,
91 std::vector<int> &minMap,
92 std::vector<int> &maxMap,
93 std::vector<int> &sadMap,
94 const double zeroThresh) const;
95
96 void buildCostMatrices(const ttk::DiagramType &CTDiagram1,
97 const ttk::DiagramType &CTDiagram2,
98 double zeroThresh,
99 std::vector<std::vector<double>> &minMatrix,
100 std::vector<std::vector<double>> &maxMatrix,
101 std::vector<std::vector<double>> &sadMatrix,
102 bool reverseMin,
103 bool reverseMax,
104 bool reverseSad,
105 int wasserstein) const;
106
107 double buildMappings(const std::vector<MatchingType> &inputMatchings,
108 bool transposeGlobal,
109 bool transposeLocal,
110 std::vector<MatchingType> &outputMatchings,
111 const std::vector<int> &m1,
112 const std::vector<int> &m2,
113 int wasserstein) const;
114 };
115
116} // namespace ttk
void setPVAlgorithm(const int algorithm)
void setWasserstein(const std::string &wasserstein)
void setPY(const double py)
int execute(const ttk::DiagramType &diag0, const ttk::DiagramType &diag1, std::vector< MatchingType > &matchings)
void setPX(const double px)
void setAlgorithm(const std::string &algorithm)
std::array< double, 3 > costs_
void setPZ(const double pz)
void setPersistencePercentThreshold(const double t)
void setPS(const double ps)
void setPE(const double pe)
Minimalist debugging class.
Definition Debug.h:88
The Topology ToolKit.
constexpr unsigned long long str2int(const char *str, int h=0)
std::vector< PersistencePair > DiagramType
Persistence Diagram type as a vector of Persistence pairs.