diff options
author | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-02-16 15:43:29 +0000 |
---|---|---|
committer | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-02-16 15:43:29 +0000 |
commit | ff0dc023588e3b33bc4bc7f26ce1f68c647ae441 (patch) | |
tree | a6f839885acbbefe07ffeeca996eea77dc136e96 /src/Persistence_representations/example | |
parent | 69c683e663329d8410ca77c371f877bcc3bef906 (diff) |
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/kernels@3251 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 80f084fc990df6e5c6b60ac83514220aba2ceb5c
Diffstat (limited to 'src/Persistence_representations/example')
3 files changed, 39 insertions, 21 deletions
diff --git a/src/Persistence_representations/example/CMakeLists.txt b/src/Persistence_representations/example/CMakeLists.txt index 54d719ac..79d39c4d 100644 --- a/src/Persistence_representations/example/CMakeLists.txt +++ b/src/Persistence_representations/example/CMakeLists.txt @@ -27,3 +27,13 @@ add_test(NAME Persistence_representations_example_heat_maps COMMAND $<TARGET_FILE:Persistence_representations_example_heat_maps>) install(TARGETS Persistence_representations_example_heat_maps DESTINATION bin) +add_executable ( Sliced_Wasserstein sliced_wasserstein.cpp ) +add_test(NAME Sliced_Wasserstein + COMMAND $<TARGET_FILE:Sliced_Wasserstein>) +install(TARGETS Sliced_Wasserstein DESTINATION bin) + +add_executable ( Persistence_weighted_gaussian persistence_weighted_gaussian.cpp ) +add_test(NAME Persistence_weighted_gaussian + COMMAND $<TARGET_FILE:Persistence_weighted_gaussian>) +install(TARGETS Persistence_weighted_gaussian DESTINATION bin) + diff --git a/src/Persistence_representations/example/persistence_weighted_gaussian.cpp b/src/Persistence_representations/example/persistence_weighted_gaussian.cpp index e95b9445..a0e820ea 100644 --- a/src/Persistence_representations/example/persistence_weighted_gaussian.cpp +++ b/src/Persistence_representations/example/persistence_weighted_gaussian.cpp @@ -44,21 +44,24 @@ int main(int argc, char** argv) { persistence2.push_back(std::make_pair(3, 5)); persistence2.push_back(std::make_pair(6, 10)); - PWG PWG1(persistence1); - PWG PWG2(persistence2); double sigma = 1; double tau = 1; - int m = 1000; + int m = 10000; + PWG PWG1(persistence1, sigma, m, PWG::arctan_weight); + PWG PWG2(persistence2, sigma, m, PWG::arctan_weight); + + PWG PWGex1(persistence1, sigma, -1, PWG::arctan_weight); + PWG PWGex2(persistence2, sigma, -1, PWG::arctan_weight); // Linear PWG - std::cout << PWG1.compute_scalar_product (PWG2, sigma, PWG::arctan_weight, m) << std::endl; - std::cout << PWG1.compute_scalar_product (PWG2, sigma, PWG::arctan_weight, -1) << std::endl; + std::cout << PWG1.compute_scalar_product (PWG2) << std::endl; + std::cout << PWGex1.compute_scalar_product (PWGex2) << std::endl; - std::cout << PWG1.distance (PWG2, sigma, PWG::arctan_weight, m) << std::endl; - std::cout << PWG1.distance (PWG2, sigma, PWG::arctan_weight, -1) << std::endl; + std::cout << PWG1.distance (PWG2) << std::endl; + std::cout << PWGex1.distance (PWGex2) << std::endl; @@ -68,8 +71,8 @@ int main(int argc, char** argv) { // Gaussian PWG - std::cout << std::exp( -PWG1.distance (PWG2, sigma, PWG::arctan_weight, m, 2) ) / (2*tau*tau) << std::endl; - std::cout << std::exp( -PWG1.distance (PWG2, sigma, PWG::arctan_weight, -1, 2) ) / (2*tau*tau) << std::endl; + std::cout << std::exp( -PWG1.distance (PWG2, 2) ) / (2*tau*tau) << std::endl; + std::cout << std::exp( -PWGex1.distance (PWGex2, 2) ) / (2*tau*tau) << std::endl; @@ -82,14 +85,15 @@ int main(int argc, char** argv) { PD pd1 = persistence1; int numpts = persistence1.size(); for(int i = 0; i < numpts; i++) pd1.emplace_back(persistence1[i].second,persistence1[i].first); PD pd2 = persistence2; numpts = persistence2.size(); for(int i = 0; i < numpts; i++) pd2.emplace_back(persistence2[i].second,persistence2[i].first); - PWG pwg1(pd1); - PWG pwg2(pd2); + PWG pwg1(pd1, 2*std::sqrt(sigma), m, PWG::pss_weight); + PWG pwg2(pd2, 2*std::sqrt(sigma), m, PWG::pss_weight); + + PWG pwgex1(pd1, 2*std::sqrt(sigma), -1, PWG::pss_weight); + PWG pwgex2(pd2, 2*std::sqrt(sigma), -1, PWG::pss_weight); - std::cout << pwg1.compute_scalar_product (pwg2, 2*std::sqrt(sigma), PWG::pss_weight, m) / (16*pi*sigma) << std::endl; - std::cout << pwg1.compute_scalar_product (pwg2, 2*std::sqrt(sigma), PWG::pss_weight, -1) / (16*pi*sigma) << std::endl; + std::cout << pwg1.compute_scalar_product (pwg2) / (16*pi*sigma) << std::endl; + std::cout << pwgex1.compute_scalar_product (pwgex2) / (16*pi*sigma) << std::endl; - std::cout << pwg1.distance (pwg2, 2*std::sqrt(sigma), PWG::pss_weight, m) / (16*pi*sigma) << std::endl; - std::cout << pwg1.distance (pwg2, 2*std::sqrt(sigma), PWG::pss_weight, -1) / (16*pi*sigma) << std::endl; return 0; diff --git a/src/Persistence_representations/example/sliced_wasserstein.cpp b/src/Persistence_representations/example/sliced_wasserstein.cpp index 673d8474..f153fbe8 100644 --- a/src/Persistence_representations/example/sliced_wasserstein.cpp +++ b/src/Persistence_representations/example/sliced_wasserstein.cpp @@ -43,13 +43,17 @@ int main(int argc, char** argv) { persistence2.push_back(std::make_pair(3, 5)); persistence2.push_back(std::make_pair(6, 10)); - SW SW1(persistence1); - SW SW2(persistence2); - std::cout << SW1.compute_sliced_wasserstein_distance(SW2,100) << std::endl; - std::cout << SW1.compute_sliced_wasserstein_distance(SW2,-1) << std::endl; - std::cout << SW1.compute_scalar_product(SW2,1,100) << std::endl; - std::cout << SW1.distance(SW2,1,100,1) << std::endl; + SW sw1(persistence1, 1, 100); + SW sw2(persistence2, 1, 100); + + SW swex1(persistence1, 1, -1); + SW swex2(persistence2, 1, -1); + + std::cout << sw1.compute_sliced_wasserstein_distance(sw2) << std::endl; + std::cout << swex1.compute_sliced_wasserstein_distance(swex2) << std::endl; + std::cout << sw1.compute_scalar_product(sw2) << std::endl; + std::cout << swex1.distance(swex2) << std::endl; return 0; } |