From ee086a78f61f1ac6dd14ecab6e34d6710c971f64 Mon Sep 17 00:00:00 2001 From: pdlotko Date: Fri, 24 Mar 2017 20:22:47 +0000 Subject: Answer to Marc's comments. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@2240 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 20c02d536373553322a3e10eb4aacc2959db654a --- src/Gudhi_stat/test/persistence_heat_maps_test.cpp | 120 ++++++++++++++++++- src/Gudhi_stat/test/persistence_intervals_test.cpp | 2 +- .../test/persistence_lanscapes_on_grid_test.cpp | 109 ++++++++++++++++- src/Gudhi_stat/test/persistence_lanscapes_test.cpp | 129 ++++++++++++++++++++- src/Gudhi_stat/test/vector_representation_test.cpp | 2 +- 5 files changed, 357 insertions(+), 5 deletions(-) (limited to 'src/Gudhi_stat/test') diff --git a/src/Gudhi_stat/test/persistence_heat_maps_test.cpp b/src/Gudhi_stat/test/persistence_heat_maps_test.cpp index 4447ba37..fb094912 100644 --- a/src/Gudhi_stat/test/persistence_heat_maps_test.cpp +++ b/src/Gudhi_stat/test/persistence_heat_maps_test.cpp @@ -26,7 +26,7 @@ #define BOOST_TEST_MODULE "gudhi_stat" #include #include -#include +#include #include @@ -258,3 +258,121 @@ BOOST_AUTO_TEST_CASE(check_arythmetic_operations_for_heat_maps) } + + + +//Below I am storing the code used to generate tests for that functionality. +/* + std::vector< std::pair< double,double > > intervals; + intervals.push_back( std::make_pair(0.5,0.5) ); + std::vector< std::vector > filter = create_Gaussian_filter(5,1); + Persistence_heat_maps p( intervals , filter , constant_function, false , 100 , 0 , 1 ); + p.plot( "heat_map_1" ); + + + std::vector< std::pair< double,double > > intervals2; + intervals2.push_back( std::make_pair(7,12) ); + Persistence_heat_maps q( intervals2 , filter , constant_function, false , 100 , 0 , 10 ); + q.plot( "heat_map_2" ); +*/ +/* + std::vector< std::pair< double,double > > intervals; + intervals.push_back( std::make_pair(0.5,0.5) ); + std::vector< std::vector > filter = create_Gaussian_filter(5,1); + Persistence_heat_maps p( intervals , filter , constant_function, false , 10 , 0 , 1 ); + p.write_to_file( "aaa" ); + + Persistence_heat_maps q; + q.load_from_file( "aaa" ); + + cerr << ( p == q ) << endl; + */ + +/* + std::vector< std::vector > filter = create_Gaussian_filter(30,1); + Persistence_heat_maps p( "file_with_diagram" , filter , constant_function, false , 100 , 0 , 1 ); + p.plot( "heat_map_1" ); +*/ + +/* + //test to construct persistence heat map: + std::vector< std::vector > filter = create_Gaussian_filter(100,1); + Persistence_heat_maps p( "file_with_diagram" , filter , constant_function, false , 1000 , 0 , 1 ); + p.print_to_file( "persistence_heat_map_from_file_with_diagram" ); + + Persistence_heat_maps q; + q.load_from_file( "persistence_heat_map_from_file_with_diagram" ); + + cerr << (p == q) << endl; +*/ +/* + //test of computations of a mean: + std::vector< std::pair< double,double > > intervals; + intervals.push_back( std::make_pair(5,5) ); + std::vector< std::vector > filter = create_Gaussian_filter(5,1); + Persistence_heat_maps p( intervals , filter , constant_function, false , 100 , 0 , 10 ); + p.plot( "heat_map_1" ); + + + std::vector< std::pair< double,double > > intervals2; + intervals2.push_back( std::make_pair(7,7) ); + Persistence_heat_maps q( intervals2 , filter , constant_function, false , 100 , 0 , 10 ); + q.plot( "heat_map_2" ); + + + Persistence_heat_maps av; + av.compute_average( { &P , &q } ); + av.plot( "average" ); +*/ + +/* + std::vector< std::vector > filter = create_Gaussian_filter(30,1); + Persistence_heat_maps p( "file_with_diagram" , filter , constant_function, false , 1000 , 0 , 10 ); + Persistence_heat_maps q( "file_with_diagram_1" , filter , constant_function, false , 1000 , 0 , 10 ); + Persistence_heat_maps r( "file_with_diagram_2" , filter , constant_function, false , 1000 , 0 , 10 ); + Persistence_heat_maps av; + av.compute_average( {&p,&q,&r} ); + + av.print_to_file( "template_average_of_heat_maps" ); +*/ + +/* + std::vector< std::pair< double,double > > intervals; + intervals.push_back( std::make_pair(5,5) ); + std::vector< std::vector > filter = create_Gaussian_filter(5,1); + Persistence_heat_maps p( intervals , filter , constant_function, false , 10 , 0 , 10 ); + p.plot( "heat_map_1" ); + + std::vector< std::pair< double,double > > intervals2; + intervals2.push_back( std::make_pair(7,7) ); + Persistence_heat_maps q( intervals2 , filter , constant_function, false , 10 , 0 , 10 ); + q.plot( "heat_map_2" ); + + Persistence_heat_maps median; + median.compute_median( {&p,&q} ); + median.plot( "median" ); +*/ + +/* + std::vector< std::vector > filter = create_Gaussian_filter(30,1); + Persistence_heat_maps p( "file_with_diagram" , filter , constant_function, false , 1000 , 0 , 1 ); + Persistence_heat_maps q( "file_with_diagram_1" , filter , constant_function, false , 1000 , 0 , 1 ); + Persistence_heat_maps r( "file_with_diagram_2" , filter , constant_function, false , 1000 , 0 , 1 ); + Persistence_heat_maps median; + median.compute_median( {&p,&q,&r} ); + median.print_to_file( "template_median_of_heat_maps" ); +*/ + + +/* + std::vector< std::vector > filter = create_Gaussian_filter(30,1); + Persistence_heat_maps p( "file_with_diagram" , filter , constant_function, false , 1000 , 0 , 1 ); + Persistence_heat_maps q( "file_with_diagram_1" , filter , constant_function, false , 1000 , 0 , 1 ); + Persistence_heat_maps r( "file_with_diagram_2" , filter , constant_function, false , 1000 , 0 , 1 ); + + Persistence_heat_maps percentage_of_active; + percentage_of_active.compute_percentage_of_active( {&p,&q,&r} , 0.1 ); + + percentage_of_active.print_to_file( "template_percentage_of_active_of_heat_maps" ); + //percentage_of_active.plot( "template_percentage_of_active_of_heat_maps" ); +*/ diff --git a/src/Gudhi_stat/test/persistence_intervals_test.cpp b/src/Gudhi_stat/test/persistence_intervals_test.cpp index 96d913e0..d46d009b 100644 --- a/src/Gudhi_stat/test/persistence_intervals_test.cpp +++ b/src/Gudhi_stat/test/persistence_intervals_test.cpp @@ -26,7 +26,7 @@ #define BOOST_TEST_MODULE "gudhi_stat" #include #include -#include "gudhi/concretizations/Persistence_intervals.h" +#include "gudhi/persistence_representations/Persistence_intervals.h" #include diff --git a/src/Gudhi_stat/test/persistence_lanscapes_on_grid_test.cpp b/src/Gudhi_stat/test/persistence_lanscapes_on_grid_test.cpp index 84b01f3e..2e4ba8d9 100644 --- a/src/Gudhi_stat/test/persistence_lanscapes_on_grid_test.cpp +++ b/src/Gudhi_stat/test/persistence_lanscapes_on_grid_test.cpp @@ -26,7 +26,7 @@ #define BOOST_TEST_MODULE "gudhi_stat" #include #include -#include +#include #include @@ -247,3 +247,110 @@ BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product) } + + +//Below I am storing the code used to generate tests for that functionality. +/* + Persistence_landscape_on_grid l( "file_with_diagram_1" , 100 ); + l.print_to_file( "landscape_from_file_with_diagram_1" ); + + Persistence_landscape_on_grid g; + g.load_landscape_from_file( "landscape_from_file_with_diagram_1" ); + + cerr << ( l == g ); + */ + + /* + Persistence_landscape_on_grid l( "file_with_diagram_1" , 100 ); + cerr << l << endl; + cerr << l.compute_integral_of_landscape() << endl; + */ + + /* + Persistence_landscape_on_grid p( "file_with_diagram_1" , 100 ); + for ( size_t level = 0 ; level != 30 ; ++level ) + { + double integral = p.compute_integral_of_landscape( level ); + cerr << integral << endl; + } + */ + + /* + Persistence_landscape_on_grid p( "file_with_diagram_1" , 100 ); + for ( size_t power = 0 ; power != 5 ; ++power ) + { + double integral = p.compute_integral_of_landscape( (double)power ); + cerr << integral << endl; + } + */ + + /* + Persistence_landscape_on_grid p( "file_with_diagram_1" , 100 ); + double x = 0.0012321; + double dx = 0.05212; + for ( size_t i = 0 ; i != 10 ; ++i ) + { + cerr << p.compute_value_at_a_given_point(10,x) << endl; + x += dx; + } + */ + + /* + Persistence_landscape_on_grid p( "file_with_diagram_1",100 ); + Persistence_landscape_on_grid second("file_with_diagram_1",100 ); + Persistence_landscape_on_grid sum = p + second; + Persistence_landscape_on_grid difference = p - second; + Persistence_landscape_on_grid multiply_by_scalar = 10*p; + sum.print_to_file( "sum_on_grid_test" ); + difference.print_to_file( "difference_on_grid_test" ); + multiply_by_scalar.print_to_file( "multiply_by_scalar_on_grid_test" ); + */ + + + /* + Persistence_landscape_on_grid p( "file_with_diagram_1" , 0 , 1 , 100 ); + Persistence_landscape_on_grid second("file_with_diagram_1", 0 , 1 , 100 ); + Persistence_landscape_on_grid sum = p + second; + + cerr << "max : " << p.compute_maximum() << endl; + cerr << "1-norm : " << p.compute_norm_of_landscape(1) << endl; + cerr << "2-norm : " << p.compute_norm_of_landscape(2) << endl; + cerr << "3-norm : " << p.compute_norm_of_landscape(3) << endl; + + cerr << compute_distance_of_landscapes_on_grid(p,sum,1) << endl; + cerr << compute_distance_of_landscapes_on_grid(p,sum,2) << endl; + cerr << compute_distance_of_landscapes_on_grid(p,sum,-1) << endl; + */ + + /* + Persistence_landscape_on_grid p( "file_with_diagram", 0,1,100 ); + Persistence_landscape_on_grid q( "file_with_diagram_1", 0,1,100 ); + Persistence_landscape_on_grid av; + av.compute_average( {&p,&q} ); + av.print_to_file("average_on_a_grid"); + + Persistence_landscape_on_grid template_average; + template_average.load_landscape_from_file( "average_on_a_grid" ); + if ( template_average == av ) + { + cerr << "OK OK \n"; + }*/ + + /* + Persistence_landscape_on_grid p( "file_with_diagram" , 0,1,10000); + Persistence_landscape_on_grid q( "file_with_diagram_1" , 0,1,10000); + cerr << p.distance( &q )<< endl; + cerr << p.distance( &q , 2 ) << endl; + cerr << p.distance( &q , std::numeric_limits::max() ) << endl; + */ + +/* + Persistence_landscape_on_grid p( "file_with_diagram", 0,1,10000 ); + Persistence_landscape_on_grid q( "file_with_diagram_1", 0,1,10000 ); + + //std::vector< std::pair< double,double > > aa; + //aa.push_back( std::make_pair( 0,1 ) ); + //Persistence_landscape_on_grid p( aa, 0,1,10 ); + //Persistence_landscape_on_grid q( aa, 0,1,10 ); + cerr << p.compute_scalar_product( &q ) << endl; +*/ diff --git a/src/Gudhi_stat/test/persistence_lanscapes_test.cpp b/src/Gudhi_stat/test/persistence_lanscapes_test.cpp index dd010174..9b9f9d7b 100644 --- a/src/Gudhi_stat/test/persistence_lanscapes_test.cpp +++ b/src/Gudhi_stat/test/persistence_lanscapes_test.cpp @@ -26,7 +26,7 @@ #define BOOST_TEST_MODULE "gudhi_stat" #include #include -#include +#include #include @@ -217,3 +217,130 @@ BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product) BOOST_CHECK( fabs( p.compute_scalar_product( q ) - 0.754498 ) <= 0.00001 ); } + + +//Below I am storing the code used to generate tests for that functionality. +/* +if ( argc != 2 ) + { + std::cerr << "To run this program, please provide a name of a file with persistence landscape \n"; + //return 1; + } + Persistence_landscape p("../test/data/file_with_diagram"); + + Persistence_landscape q; + q.load_landscape_from_file( "file_with_landscape_from_file_with_diagram" ); + + if ( p != q ) + { + cout << "Not equal \n"; + } + + double integral = p.compute_integral_of_landscape(); + cout << "integral : " << integral <::max() ) << endl; + + { + Persistence_landscape p( "../test/data/file_with_diagram" ); + Persistence_landscape q( "../test/data/file_with_diagram_1" ); + Persistence_landscape av; + av.compute_average( {&p,&q} ); + + Persistence_landscape template_average; + template_average.load_landscape_from_file( "average" ); + if ( template_average != av ) + { + cerr << "We have a problem with average \n"; + } + } + + + { + Persistence_landscape p( "../test/data/file_with_diagram" ); + Persistence_landscape q( "../test/data/file_with_diagram_1" ); + cout << "L^1 distance : " << p.distance( &q ) << endl; + cout << "L^2 distance : " << p.distance( &q , 2) << endl; + cout << "L^infty distance : " << p.distance( &q , std::numeric_limits::max() ) << endl; + } + + + { + Persistence_landscape p( "../test/data/file_with_diagram" ); + Persistence_landscape q( "../test/data/file_with_diagram_1" ); + cout << "Scalar product : " << p.compute_scalar_product( &q ) << endl; + } +*/ diff --git a/src/Gudhi_stat/test/vector_representation_test.cpp b/src/Gudhi_stat/test/vector_representation_test.cpp index dd84fc33..f69673dd 100644 --- a/src/Gudhi_stat/test/vector_representation_test.cpp +++ b/src/Gudhi_stat/test/vector_representation_test.cpp @@ -21,7 +21,7 @@ */ -#include +#include #include #include -- cgit v1.2.3