summaryrefslogtreecommitdiff
path: root/src/Gudhi_stat/test
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-24 20:22:47 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-24 20:22:47 +0000
commitee086a78f61f1ac6dd14ecab6e34d6710c971f64 (patch)
tree91d7bec2f0d8bca9b84f31d523a82240d79cd12a /src/Gudhi_stat/test
parent5b6290423812b24cc3f67a4a8e9c9027b9d95cd6 (diff)
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
Diffstat (limited to 'src/Gudhi_stat/test')
-rw-r--r--src/Gudhi_stat/test/persistence_heat_maps_test.cpp120
-rw-r--r--src/Gudhi_stat/test/persistence_intervals_test.cpp2
-rw-r--r--src/Gudhi_stat/test/persistence_lanscapes_on_grid_test.cpp109
-rw-r--r--src/Gudhi_stat/test/persistence_lanscapes_test.cpp129
-rw-r--r--src/Gudhi_stat/test/vector_representation_test.cpp2
5 files changed, 357 insertions, 5 deletions
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 <boost/test/unit_test.hpp>
#include <gudhi/reader_utils.h>
-#include <gudhi/concretizations/Persistence_heat_maps.h>
+#include <gudhi/persistence_representations/Persistence_heat_maps.h>
#include <iostream>
@@ -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<double> > 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<double> > 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<double> > 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<double> > 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<double> > 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<double> > 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<double> > 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<double> > 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<double> > 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 <boost/test/unit_test.hpp>
#include <gudhi/reader_utils.h>
-#include "gudhi/concretizations/Persistence_intervals.h"
+#include "gudhi/persistence_representations/Persistence_intervals.h"
#include <iostream>
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 <boost/test/unit_test.hpp>
#include <gudhi/reader_utils.h>
-#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
+#include <gudhi/persistence_representations/Persistence_landscape_on_grid.h>
#include <iostream>
@@ -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<double>::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 <boost/test/unit_test.hpp>
#include <gudhi/reader_utils.h>
-#include <gudhi/concretizations/Persistence_landscape.h>
+#include <gudhi/persistence_representations/Persistence_landscape.h>
#include <iostream>
@@ -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 <<endl;
+
+ //compute integral for each level separatelly
+ for ( size_t level = 0 ; level != p.size() ; ++level )
+ {
+ cout << p.compute_integral_of_landscape( level ) << endl;
+ }
+
+ //compute integral of p-th power of landscspe
+ for ( size_t power = 0 ; power != 5 ; ++power )
+ {
+ cout << p.compute_integral_of_landscape( power ) << endl;
+ }
+
+ cout << "Value of level 1 at 0 : " << p.compute_value_at_a_given_point(1,0.0) << endl;
+ cout << "Value of level 1 at 1 : " << p.compute_value_at_a_given_point(1,0.1) << endl;
+ cout << "Value of level 1 at 2 : " << p.compute_value_at_a_given_point(1,0.2) << endl;
+ cout << "Value of level 1 at 3 : " << p.compute_value_at_a_given_point(1,0.3) << endl;
+
+
+ cout << "Value of level 2 at 0 : " << p.compute_value_at_a_given_point(2,0.0) << endl;
+ cout << "Value of level 2 at 1 : " << p.compute_value_at_a_given_point(2,0.1) << endl;
+ cout << "Value of level 2 at 2 : " << p.compute_value_at_a_given_point(2,0.2) << endl;
+ cout << "Value of level 2 at 3 : " << p.compute_value_at_a_given_point(2,0.3) << endl;
+
+
+ cout << "Value of level 3 at 0 : " << p.compute_value_at_a_given_point(3,0.0) << endl;
+ cout << "Value of level 3 at 1 : " << p.compute_value_at_a_given_point(3,0.1) << endl;
+ cout << "Value of level 3 at 2 : " << p.compute_value_at_a_given_point(3,0.2) << endl;
+ cout << "Value of level 3 at 3 : " << p.compute_value_at_a_given_point(3,0.3) << endl;
+
+
+
+ Persistence_landscape second;
+ second.load_landscape_from_file("file_with_landscape_from_file_with_diagram_1" );
+
+ Persistence_landscape sum = p + second;
+ Persistence_landscape difference = p - second;
+ Persistence_landscape multiply_by_scalar = 10*p;
+
+ //sum.print_to_file("sum");
+ //difference.print_to_file("difference");
+ //multiply_by_scalar.print_to_file("multiply_by_scalar");
+
+ Persistence_landscape template_sum;
+ template_sum.load_landscape_from_file( "sum" );
+ Persistence_landscape template_difference;
+ template_difference.load_landscape_from_file( "difference" );
+ Persistence_landscape template_multiply_by_scalar;
+ template_multiply_by_scalar.load_landscape_from_file( "multiply_by_scalar" );
+
+ if ( sum != template_sum )
+ {
+ cerr << "Problem with sums \n";
+ }
+ if ( difference != template_difference )
+ {
+ cerr << "Problem with differences \n";
+ }
+ if ( multiply_by_scalar != template_multiply_by_scalar )
+ {
+ cerr << "Problem with multiplication by scalar \n";
+ }
+
+
+
+ cout << "Maximum : " << p.compute_maximum() << endl;
+
+ cout << "L^1 norm : " << p.compute_norm_of_landscape(1) << endl;
+ cout << "L^2 norm : " << p.compute_norm_of_landscape(2) << endl;
+ cout << "L^3 norm : " << p.compute_norm_of_landscape(3) << endl;
+
+
+ cout << "L^1 distance : " << compute_distance_of_landscapes(p,sum,1) << endl;
+ cout << "L^2 distance : " << compute_distance_of_landscapes(p,sum,2) << endl;
+ cout << "L^infty distance : " << compute_distance_of_landscapes(p,sum,std::numeric_limits<double>::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<double>::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 <gudhi/concretizations/Vector_distances_in_diagram.h>
+#include <gudhi/persistence_representations/Vector_distances_in_diagram.h>
#include <gudhi/common_gudhi_stat.h>
#include <iostream>