From 0c6aafa07857042e92857fec6969d0caf89e187e Mon Sep 17 00:00:00 2001 From: Gard Spreemann Date: Mon, 14 May 2018 17:25:40 +0200 Subject: Support for finitization. --- geom_matching/wasserstein/include/diagram_reader.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'geom_matching/wasserstein/include/diagram_reader.h') diff --git a/geom_matching/wasserstein/include/diagram_reader.h b/geom_matching/wasserstein/include/diagram_reader.h index 84bf49c..55228b4 100644 --- a/geom_matching/wasserstein/include/diagram_reader.h +++ b/geom_matching/wasserstein/include/diagram_reader.h @@ -324,6 +324,26 @@ void remove_duplicates(ContType& dgm_A, ContType& dgm_B) } } +template +int finitize(RealType finitization, std::vector >& diagram) +{ + if (finitization == std::numeric_limits::infinity()) + return 0; + + int altered = 0; + + for (auto it = diagram.begin(); it != diagram.end(); ++it) + { + if (it->second > finitization) + { + it->second = finitization; + ++altered; + } + } + + return altered; +} + #ifdef WASSERSTEIN_PURE_GEOM -- cgit v1.2.3