TTK
Loading...
Searching...
No Matches
PairCellsWithOracle.h
Go to the documentation of this file.
1
13
14#pragma once
15
16#include <Debug.h>
18
19#include <set>
20
21namespace ttk::rpd {
22
23 class PairCellsWithOracle : virtual public Debug {
24 public:
25 PairCellsWithOracle(const PointCloud &points,
26 MultidimensionalDiagram const &oracle,
27 bool distanceMatrix = false,
28 bool parallelSort = false);
29 PairCellsWithOracle(float *data,
30 int n,
31 int dim,
32 MultidimensionalDiagram const &oracle,
33 bool parallelSort = false);
34
35 void run();
36
37 void getGenerators(std::vector<Generator1> &generators) const;
38
39 void getCascades(std::vector<Cascade> &cascades, EdgeSets3 &critical) const;
40 void getCascades(EdgeSets4 &critical) const;
41
42 static void callOracle(const PointCloud &points,
44 double threshold = inf,
45 bool distanceMatrix = false);
46
47 private:
48 const int n_;
49 std::vector<double> compressedDM_{};
50 const bool parallelSort_;
51
52 MultidimensionalDiagram const &oracle_;
53 double bound_{0.};
54
55 std::unordered_map<Edge, id_t, boost::hash<Edge>> edgeToIndex_;
56 std::vector<std::set<id_t, std::greater<>>>
57 graph_{}; // std::greater to match the reverse co-lexicographic order used
58 // in Ripser
59 std::vector<FiltratedEdge> edges_{};
60 std::vector<FiltratedTriangle> triangles_{};
61 std::vector<id_t> edgesIndices_{};
62 std::vector<id_t> edgesOrder_{};
63
64 std::vector<id_t> edgesPartner_{};
65 std::vector<id_t> trianglesPartner_{};
66 std::vector<std::vector<id_t>> boundaries_{};
67 int nEdges_{};
68
69 std::vector<std::vector<id_t>> cascadeEdges_{};
70
74 double &DM(unsigned i, unsigned j) {
75 return compressedDM_[std::max(i, j) * (std::max(i, j) - 1) / 2
76 + std::min(i, j)];
77 }
78
79 void initializeWithBound();
80 void pairCellsWithOracle();
81 void eliminateBoundaryWithOracle(id_t t_id, id_t e_id);
82
83 template <typename EdgeSets>
84 void fillRNG(EdgeSets &critical) const {
85 for(auto const &[birth, death] : oracle_[0]) {
86 if(death.second < inf)
87 critical[0].emplace_back(death.first[0], death.first[1]);
88 }
89 for(auto const &[birth, death] : oracle_[1])
90 critical[1].emplace_back(birth.first[0], birth.first[1]);
91 }
92 };
93} // namespace ttk::rpd
void getGenerators(std::vector< Generator1 > &generators) const
PairCellsWithOracle(const PointCloud &points, MultidimensionalDiagram const &oracle, bool distanceMatrix=false, bool parallelSort=false)
void getCascades(std::vector< Cascade > &cascades, EdgeSets3 &critical) const
static void callOracle(const PointCloud &points, MultidimensionalDiagram &oracle, double threshold=inf, bool distanceMatrix=false)
std::array< EdgeSet, 4 > EdgeSets4
constexpr value_t inf
std::vector< std::vector< value_t > > PointCloud
std::vector< Diagram > MultidimensionalDiagram
std::array< EdgeSet, 3 > EdgeSets3