From 8fb72abe8d5eb4fe715b69545422b16655cc1ec3 Mon Sep 17 00:00:00 2001 From: Arnur Nigmetov Date: Mon, 24 Apr 2017 21:55:17 +0200 Subject: Lots of debug output for sampling heuristic To fix a problem on Mac OS. --- geom_bottleneck/bottleneck/src/bottleneck.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/geom_bottleneck/bottleneck/src/bottleneck.cpp b/geom_bottleneck/bottleneck/src/bottleneck.cpp index f90e5c9..05e0e27 100644 --- a/geom_bottleneck/bottleneck/src/bottleneck.cpp +++ b/geom_bottleneck/bottleneck/src/bottleneck.cpp @@ -93,6 +93,9 @@ std::pair bottleneckDistApproxInterval(DiagramPointSet& A, Diagr void sampleDiagramForHeur(const DiagramPointSet& dgmIn, DiagramPointSet& dgmOut) { +#ifdef VERBOSE_BOTTLENECK + std::cout << "Entered sampleDiagramForHeur, dgmIn.size = " << dgmIn.size() << std::endl; +#endif struct pair_hash { std::size_t operator()(const std::pair p) const { @@ -105,7 +108,10 @@ void sampleDiagramForHeur(const DiagramPointSet& dgmIn, DiagramPointSet& dgmOut) m[std::make_pair(ptIter->getRealX(), ptIter->getRealY())]++; } } - if (m.size() < 2) { +#ifdef VERBOSE_BOTTLENECK + std::cout << "map filled in, m.size = " << m.size() << std::endl; +#endif + if (m.size() < 2) { dgmOut = dgmIn; return; } @@ -113,7 +119,13 @@ void sampleDiagramForHeur(const DiagramPointSet& dgmIn, DiagramPointSet& dgmOut) for(const auto& ptQtyPair : m) { v.push_back(ptQtyPair.second); } +#ifdef VERBOSE_BOTTLENECK + std::cout << "v filled in, v.size = " << v.size() << std::endl; +#endif std::sort(v.begin(), v.end()); +#ifdef VERBOSE_BOTTLENECK + std::cout << "v sorted" << std::endl; +#endif int maxLeap = v[1] - v[0]; int cutVal = v[0]; for(int i = 1; i < v.size() - 1; ++i) { @@ -123,7 +135,10 @@ void sampleDiagramForHeur(const DiagramPointSet& dgmIn, DiagramPointSet& dgmOut) cutVal = v[i]; } } - std::vector> vv; +#ifdef VERBOSE_BOTTLENECK + std::cout << "cutVal found, cutVal = " << cutVal << std::endl; +#endif + std::vector> vv; // keep points whose multiplicites are at most cutVal // quick-and-dirty: fill in vv with copies of each point // to construct DiagramPointSet from it later @@ -134,8 +149,14 @@ void sampleDiagramForHeur(const DiagramPointSet& dgmIn, DiagramPointSet& dgmOut) } } } +#ifdef VERBOSE_BOTTLENECK + std::cout << "vv filled in, vv.size = " << v.size() << std::endl; +#endif dgmOut.clear(); dgmOut = DiagramPointSet(vv.begin(), vv.end()); +#ifdef VERBOSE_BOTTLENECK + std::cout << "dgmOut filled in, dgmOut.size = " << dgmOut.size() << std::endl; +#endif } @@ -714,7 +735,9 @@ bool readDiagramPointSet(const char* fname, std::vector