summaryrefslogtreecommitdiff
path: root/geom_bottleneck/include/bottleneck.h
diff options
context:
space:
mode:
Diffstat (limited to 'geom_bottleneck/include/bottleneck.h')
-rw-r--r--geom_bottleneck/include/bottleneck.h151
1 files changed, 93 insertions, 58 deletions
diff --git a/geom_bottleneck/include/bottleneck.h b/geom_bottleneck/include/bottleneck.h
index 0d4e1ed..64da2c8 100644
--- a/geom_bottleneck/include/bottleneck.h
+++ b/geom_bottleneck/include/bottleneck.h
@@ -43,75 +43,110 @@ derivative works thereof, in binary and source code form.
#include "bound_match.h"
namespace hera {
+ // internal_p defines cost function on edges (use hera::get_infinity(),
+ // if you want to explicitly refer to l_inf, but that's default value
+ // delta is relative error, default is 1 percent
+ template<class Real = double>
+ struct BottleneckParams
+ {
+ Real internal_p { hera::get_infinity() };
+ Real delta { 0.01 };
+ };
+
+ // functions taking containers as input
+ // template parameter PairContainer must be a container of pairs of real
+ // numbers (pair.first = x-coordinate, pair.second = y-coordinate)
+ // PairContainer class must support iteration of the form
+ // for(it = pairContainer.begin(); it != pairContainer.end(); ++it)
+
+ // all functions in this header are wrappers around
+ // functions from hera::bt namespace
+
+ // get exact bottleneck distance,
+ template<class PairContainer>
+ typename DiagramTraits<PairContainer>::RealType
+ bottleneckDistExact(PairContainer& dgm_A, PairContainer& dgm_B, const int decPrecision,
+ hera::bt::MatchingEdge<typename DiagramTraits<PairContainer>::RealType>& longest_edge,
+ bool compute_longest_edge = true)
+ {
+ using Real = typename DiagramTraits<PairContainer>::RealType;
+ hera::bt::DiagramPointSet<Real> a(dgm_A);
+ hera::bt::DiagramPointSet<Real> b(dgm_B);
+ return hera::bt::bottleneckDistExact(a, b, decPrecision, longest_edge, compute_longest_edge);
+ }
+
+ template<class PairContainer>
+ typename DiagramTraits<PairContainer>::RealType
+ bottleneckDistExact(PairContainer& dgm_A, PairContainer& dgm_B, const int decPrecision)
+ {
+ using Real = typename DiagramTraits<PairContainer>::RealType;
+ hera::bt::MatchingEdge<Real> longest_edge;
+ return bottleneckDistExact(dgm_A, dgm_B, decPrecision, longest_edge, false);
+ }
+
+
+ template<class PairContainer>
+ typename DiagramTraits<PairContainer>::RealType
+ bottleneckDistExact(PairContainer& dgm_A, PairContainer& dgm_B)
+ {
+ int dec_precision = 14;
+ return bottleneckDistExact(dgm_A, dgm_B, dec_precision);
+ }
-// functions taking containers as input
-// template parameter PairContainer must be a container of pairs of real
-// numbers (pair.first = x-coordinate, pair.second = y-coordinate)
-// PairContainer class must support iteration of the form
-// for(it = pairContainer.begin(); it != pairContainer.end(); ++it)
-
-// all functions in this header are wrappers around
-// functions from hera::bt namespace
-
-// get exact bottleneck distance,
-template<class PairContainer>
-typename DiagramTraits<PairContainer>::RealType
-bottleneckDistExact(PairContainer& dgm_A, PairContainer& dgm_B)
-{
- using Real = typename DiagramTraits<PairContainer>::RealType;
- hera::bt::DiagramPointSet<Real> a(dgm_A);
- hera::bt::DiagramPointSet<Real> b(dgm_B);
- return hera::bt::bottleneckDistExact<Real>(a, b, 14);
-}
-
-// get exact bottleneck distance,
-template<class PairContainer>
-typename DiagramTraits<PairContainer>::RealType
-bottleneckDistExact(PairContainer& dgm_A, PairContainer& dgm_B, const int decPrecision)
-{
- using Real = typename DiagramTraits<PairContainer>::RealType;
- hera::bt::DiagramPointSet<Real> a(dgm_A);
- hera::bt::DiagramPointSet<Real> b(dgm_B);
- return hera::bt::bottleneckDistExact(a, b, decPrecision);
-}
// return the interval (distMin, distMax) such that:
// a) actual bottleneck distance between A and B is contained in the interval
// b) if the interval is not (0,0), then (distMax - distMin) / distMin < delta
-template<class PairContainer>
-std::pair<typename DiagramTraits<PairContainer>::RealType, typename DiagramTraits<PairContainer>::RealType>
-bottleneckDistApproxInterval(PairContainer& dgm_A, PairContainer& dgm_B, const typename DiagramTraits<PairContainer>::RealType delta)
-{
- using Real = typename DiagramTraits<PairContainer>::RealType;
- hera::bt::DiagramPointSet<Real> a(dgm_A);
- hera::bt::DiagramPointSet<Real> b(dgm_B);
- return hera::bt::bottleneckDistApproxInterval(a, b, delta);
-}
+ template<class PairContainer>
+ std::pair<typename DiagramTraits<PairContainer>::RealType, typename DiagramTraits<PairContainer>::RealType>
+ bottleneckDistApproxInterval(PairContainer& dgm_A, PairContainer& dgm_B,
+ const typename DiagramTraits<PairContainer>::RealType delta)
+ {
+ using Real = typename DiagramTraits<PairContainer>::RealType;
+ hera::bt::DiagramPointSet<Real> a(dgm_A);
+ hera::bt::DiagramPointSet<Real> b(dgm_B);
+ return hera::bt::bottleneckDistApproxInterval(a, b, delta);
+ }
// use sampling heuristic: discard most of the points with small persistency
// to get a good initial approximation of the bottleneck distance
-template<class PairContainer>
-typename DiagramTraits<PairContainer>::RealType
-bottleneckDistApproxHeur(PairContainer& dgm_A, PairContainer& dgm_B, const typename DiagramTraits<PairContainer>::RealType delta)
-{
- using Real = typename DiagramTraits<PairContainer>::RealType;
- hera::bt::DiagramPointSet<Real> a(dgm_A);
- hera::bt::DiagramPointSet<Real> b(dgm_B);
- std::pair<Real, Real> resPair = hera::bt::bottleneckDistApproxIntervalHeur(a, b, delta);
- return resPair.second;
-}
+ template<class PairContainer>
+ typename DiagramTraits<PairContainer>::RealType
+ bottleneckDistApproxHeur(PairContainer& dgm_A, PairContainer& dgm_B,
+ const typename DiagramTraits<PairContainer>::RealType delta)
+ {
+ using Real = typename DiagramTraits<PairContainer>::RealType;
+ hera::bt::DiagramPointSet<Real> a(dgm_A);
+ hera::bt::DiagramPointSet<Real> b(dgm_B);
+ std::pair<Real, Real> resPair = hera::bt::bottleneckDistApproxIntervalHeur(a, b, delta);
+ return resPair.second;
+ }
// get approximate distance,
// see bottleneckDistApproxInterval
-template<class PairContainer>
-typename DiagramTraits<PairContainer>::RealType
-bottleneckDistApprox(PairContainer& A, PairContainer& B, const typename DiagramTraits<PairContainer>::RealType delta)
-{
- using Real = typename DiagramTraits<PairContainer>::RealType;
- hera::bt::DiagramPointSet<Real> a(A.begin(), A.end());
- hera::bt::DiagramPointSet<Real> b(B.begin(), B.end());
- return hera::bt::bottleneckDistApprox(a, b, delta);
-}
+ template<class PairContainer>
+ typename DiagramTraits<PairContainer>::RealType
+ bottleneckDistApprox(PairContainer& A, PairContainer& B,
+ const typename DiagramTraits<PairContainer>::RealType delta,
+ hera::bt::MatchingEdge<typename DiagramTraits<PairContainer>::RealType>& longest_edge,
+ bool compute_longest_edge = true)
+ {
+ using Real = typename DiagramTraits<PairContainer>::RealType;
+ hera::bt::DiagramPointSet<Real> a(A.begin(), A.end());
+ hera::bt::DiagramPointSet<Real> b(B.begin(), B.end());
+ return hera::bt::bottleneckDistApprox(a, b, delta, longest_edge, compute_longest_edge);
+ }
+
+ template<class PairContainer>
+ typename DiagramTraits<PairContainer>::RealType
+ bottleneckDistApprox(PairContainer& A, PairContainer& B,
+ const typename DiagramTraits<PairContainer>::RealType delta)
+ {
+ using Real = typename DiagramTraits<PairContainer>::RealType;
+ hera::bt::MatchingEdge<Real> longest_edge;
+ return hera::bottleneckDistApprox(A, B, delta, longest_edge, false);
+ }
+
} // end namespace hera