8 std::vector<PersistencePair> &pairs,
9 std::vector<bool> &pairedExtrema,
10 std::vector<bool> &pairedSaddles,
11 std::vector<SimplexId> &reps,
12 std::vector<tripletType> &triplets,
20 const auto s0 = t0[0];
21 const auto s1 = t1[0];
22 const auto m0 = t0[2];
23 const auto m1 = t1[2];
33 return saddlesOrder[s0] > saddlesOrder[s1];
35 return extremaOrder[m0] < extremaOrder[m1];
40 const auto s0 = t0[0];
41 const auto s1 = t1[0];
42 const auto m0 = t0[2];
43 const auto m1 = t1[2];
45 return saddlesOrder[s0] < saddlesOrder[s1];
47 return extremaOrder[m0] > extremaOrder[m1];
52 TTK_PSORT(this->threadNumber_, triplets.begin(), triplets.end(), cmpSadMin);
55 TTK_PSORT(this->threadNumber_, triplets.begin(), triplets.end(), cmpSadMax);
68 const bool increasing = (pairDim > 0);
70 const auto addPair = [&pairs, &pairedExtrema, &pairedSaddles, increasing,
73 pairs.emplace_back(sad, extr, pairDim);
75 pairs.emplace_back(extr, sad, pairDim);
77 pairedSaddles[sad] =
true;
78 pairedExtrema[extr] =
true;
81 for(
const auto &t : triplets) {
84 auto r1 = getRep(t[1]);
89 if(!pairedExtrema[r1] && !pairedSaddles[sv]) {
100 auto r2 = getRep(t[2]);
103 if(((extremaOrder[r1] > extremaOrder[r2]) == increasing
104 || pairedExtrema[r1])
105 && !pairedExtrema[r2]) {
108 if(!pairedExtrema[r1]) {
118 const std::vector<PersistencePair> &pairs,
119 const std::array<std::vector<SimplexId>, 4> &criticalCellsByDim,
120 const std::vector<bool> &pairedMinima,
121 const std::vector<bool> &paired1Saddles,
122 const std::vector<bool> &paired2Saddles,
123 const std::vector<bool> &pairedMaxima)
const {
125 const auto dim = this->dg_.getDimensionality();
128 std::vector<std::vector<std::string>> rows{
129 {
" #Min-saddle pairs",
131 std::count_if(pairs.begin(), pairs.end(),
133 {
" #Saddle-saddle pairs",
134 std::to_string(dim == 3 ? std::count_if(
135 pairs.begin(), pairs.end(),
138 {
" #Saddle-max pairs",
139 std::to_string(std::count_if(
140 pairs.begin(), pairs.end(),
145 std::vector<size_t> nCritCells(dim + 1);
146 std::vector<size_t> nNonPairedCritCells(dim + 1);
148 for(
int i = 0; i < dim + 1; ++i) {
149 nCritCells[i] = criticalCellsByDim[i].size();
151 for(
size_t j = 0; j < criticalCellsByDim[i].size(); ++j) {
152 const auto cell = criticalCellsByDim[i][j];
153 if((i == 0 && !pairedMinima[cell]) || (i == 1 && !paired1Saddles[cell])
154 || (i == 2 && dim == 3 && !paired2Saddles[cell])
155 || (i == dim && !pairedMaxima[cell])) {
159 nNonPairedCritCells[i] = nNonPaired;
162 std::vector<std::string> critCellsLabels{
"Minima"};
164 critCellsLabels.emplace_back(
"1-saddles");
167 critCellsLabels.emplace_back(
"2-saddles");
169 critCellsLabels.emplace_back(
"Maxima");
171 for(
int i = 0; i < dim + 1; ++i) {
172 const std::string unpaired{nNonPairedCritCells[i] == 0
174 :
" (" + std::to_string(nNonPairedCritCells[i])
177 rows.emplace_back(std::vector<std::string>{
178 " #" + critCellsLabels[i], std::to_string(nCritCells[i]) + unpaired});
void displayStats(const std::vector< PersistencePair > &pairs, const std::array< std::vector< SimplexId >, 4 > &criticalCellsByDim, const std::vector< bool > &pairedMinima, const std::vector< bool > &paired1Saddles, const std::vector< bool > &paired2Saddles, const std::vector< bool > &pairedMaxima) const
Print number of pairs, critical cells per dimension & unpaired cells.
void tripletsToPersistencePairs(std::vector< PersistencePair > &pairs, std::vector< bool > &pairedExtrema, std::vector< bool > &pairedSaddles, std::vector< SimplexId > &reps, std::vector< tripletType > &triplets, const SimplexId *const saddlesOrder, const SimplexId *const extremaOrder, const SimplexId pairDim) const
Compute persistence pairs from triplets.
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)