diff options
author | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2019-06-12 07:46:27 +0200 |
---|---|---|
committer | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2019-06-12 07:46:27 +0200 |
commit | 6c57ce009e242db0554aaf9316750dd0bb693d6a (patch) | |
tree | 94409a8ae609c48a6212ff61a90f7c083e0d8fcf /src/Persistence_representations/example/persistence_heat_maps.cpp | |
parent | 4e33acbac51c8c2348dc88a16eb38e14c8ef724a (diff) | |
parent | f58f0bb2cb99076d0cd3a11ad39f3277213e3f5e (diff) |
Merge branch 'master' into main_documentation_pages
Diffstat (limited to 'src/Persistence_representations/example/persistence_heat_maps.cpp')
-rw-r--r-- | src/Persistence_representations/example/persistence_heat_maps.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/Persistence_representations/example/persistence_heat_maps.cpp b/src/Persistence_representations/example/persistence_heat_maps.cpp index 323b57e9..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 @@ -21,10 +24,20 @@ */ #include <gudhi/Persistence_heat_maps.h> +#include <gudhi/common_persistence_representations.h> #include <iostream> #include <vector> #include <utility> +#include <functional> +#include <cmath> + +std::function<double(std::pair<double, double>, std::pair<double, double>)> Gaussian_function(double sigma) { + return [=](std::pair<double, double> p, std::pair<double, double> 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; using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps<constant_scaling_function>; @@ -76,5 +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; + 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; + return 0; } |