From ef407f0e40099a832f13371401b44ac565325aff Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 15 Mar 2019 15:09:32 +0100 Subject: Remove comments and identify both contributions. Include what is used and add some std::. Use std::sqrt instead of std::pow(x,0.5) --- .../example/persistence_heat_maps.cpp | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/Persistence_representations/example/persistence_heat_maps.cpp') diff --git a/src/Persistence_representations/example/persistence_heat_maps.cpp b/src/Persistence_representations/example/persistence_heat_maps.cpp index 0beb1052..45208b68 100644 --- a/src/Persistence_representations/example/persistence_heat_maps.cpp +++ b/src/Persistence_representations/example/persistence_heat_maps.cpp @@ -2,9 +2,12 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * - * Author(s): Pawel Dlotko + * Author(s): Pawel Dlotko and Mathieu Carriere * - * Copyright (C) 2016 Inria + * Copyright (C) 2019 Inria + * + * Modifications: + * - 2018/04 MC: Add persistence heat maps computation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,10 +29,14 @@ #include #include #include - - -std::function, std::pair)> Gaussian_function(double sigma){ - return [=](std::pair p, std::pair q){return std::exp( -( (p.first-q.first)*(p.first-q.first) + (p.second-q.second)*(p.second-q.second) )/(sigma) );}; +#include +#include + +std::function, std::pair)> Gaussian_function(double sigma) { + return [=](std::pair p, std::pair q) { + return std::exp(-((p.first - q.first) * (p.first - q.first) + (p.second - q.second) * (p.second - q.second)) / + (sigma)); + }; } using constant_scaling_function = Gudhi::Persistence_representations::constant_scaling_function; @@ -82,14 +89,13 @@ int main(int argc, char** argv) { // to compute scalar product of hm1 and hm2: std::cout << "Scalar product is : " << hm1.compute_scalar_product(hm2) << std::endl; - // Mathieu's code ************************************************************************************************************ Persistence_heat_maps hm1k(persistence1, Gaussian_function(1.0)); Persistence_heat_maps hm2k(persistence2, Gaussian_function(1.0)); Persistence_heat_maps hm1i(persistence1, Gaussian_function(1.0), 20, 20, 0, 11, 0, 11); Persistence_heat_maps hm2i(persistence2, Gaussian_function(1.0), 20, 20, 0, 11, 0, 11); - std::cout << "Scalar product computed with exact 2D kernel on grid is : " << hm1i.compute_scalar_product(hm2i) << std::endl; - std::cout << "Scalar product computed with exact 2D kernel is : " << hm1k.compute_scalar_product(hm2k) << std::endl; - // *************************************************************************************************************************** + std::cout << "Scalar product computed with exact 2D kernel on grid is : " << hm1i.compute_scalar_product(hm2i) + << std::endl; + std::cout << "Scalar product computed with exact 2D kernel is : " << hm1k.compute_scalar_product(hm2k) << std::endl; return 0; } -- cgit v1.2.3