summaryrefslogtreecommitdiff
path: root/src/Persistence_representations/test
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-05-30 15:52:00 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-05-30 15:52:00 +0000
commit9d1a526de85694b5f075bb88dbd7097a40abf10a (patch)
treebbcd0cef32610d2f5e9c0209b48c58f73fbf379a /src/Persistence_representations/test
parent2bcb3d7cb47ce71803f2464cc822346ed2e1b039 (diff)
clang format all sources
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration@2477 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 326d664483d6700f82be824f79a0bf5c082b4945
Diffstat (limited to 'src/Persistence_representations/test')
-rw-r--r--src/Persistence_representations/test/persistence_heat_maps_test.cpp582
-rw-r--r--src/Persistence_representations/test/persistence_intervals_test.cpp545
-rw-r--r--src/Persistence_representations/test/persistence_intervals_with_distances_test.cpp49
-rw-r--r--src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp580
-rw-r--r--src/Persistence_representations/test/persistence_lanscapes_test.cpp610
-rw-r--r--src/Persistence_representations/test/read_persistence_from_file_test.cpp131
-rw-r--r--src/Persistence_representations/test/vector_representation_test.cpp681
7 files changed, 1489 insertions, 1689 deletions
diff --git a/src/Persistence_representations/test/persistence_heat_maps_test.cpp b/src/Persistence_representations/test/persistence_heat_maps_test.cpp
index b997382e..48086ba8 100644
--- a/src/Persistence_representations/test/persistence_heat_maps_test.cpp
+++ b/src/Persistence_representations/test/persistence_heat_maps_test.cpp
@@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "Persistence_representations"
#include <boost/test/unit_test.hpp>
@@ -30,365 +28,333 @@
#include <iostream>
-
-
using namespace Gudhi;
using namespace Gudhi::Persistence_representations;
+BOOST_AUTO_TEST_CASE(check_construction_of_heat_maps) {
+ std::vector<std::vector<double> > filter = create_Gaussian_filter(100, 1);
+ Persistence_heat_maps<constant_scaling_function> p("data/file_with_diagram", filter, false, 1000, 0, 1);
+ p.print_to_file("data/persistence_heat_map_from_file_with_diagram");
+ Persistence_heat_maps<constant_scaling_function> q;
+ q.load_from_file("data/persistence_heat_map_from_file_with_diagram");
-
-
-BOOST_AUTO_TEST_CASE(check_construction_of_heat_maps)
-{
- std::vector< std::vector<double> > filter = create_Gaussian_filter(100,1);
- Persistence_heat_maps<constant_scaling_function> p( "data/file_with_diagram" , filter , false , 1000 , 0 , 1 );
- p.print_to_file( "data/persistence_heat_map_from_file_with_diagram" );
-
- Persistence_heat_maps<constant_scaling_function> q;
- q.load_from_file( "data/persistence_heat_map_from_file_with_diagram" );
-
- BOOST_CHECK( p == q );
+ BOOST_CHECK(p == q);
}
+BOOST_AUTO_TEST_CASE(check_averages_of_heat_maps) {
+ std::vector<std::vector<double> > filter = create_Gaussian_filter(30, 1);
+ Persistence_heat_maps<constant_scaling_function> p("data/file_with_diagram", filter, false, 1000, 0, 10);
+ Persistence_heat_maps<constant_scaling_function> q("data/file_with_diagram_1", filter, false, 1000, 0, 10);
+ Persistence_heat_maps<constant_scaling_function> r("data/file_with_diagram_2", filter, false, 1000, 0, 10);
-BOOST_AUTO_TEST_CASE(check_averages_of_heat_maps)
-{
- std::vector< std::vector<double> > filter = create_Gaussian_filter(30,1);
- Persistence_heat_maps<constant_scaling_function> p( "data/file_with_diagram" , filter , false , 1000 , 0 , 10 );
- Persistence_heat_maps<constant_scaling_function> q( "data/file_with_diagram_1" , filter , false , 1000 , 0 , 10 );
- Persistence_heat_maps<constant_scaling_function> r( "data/file_with_diagram_2" , filter , false , 1000 , 0 , 10 );
-
- Persistence_heat_maps<constant_scaling_function> av;
- av.compute_average( {&p,&q,&r} );
-
- Persistence_heat_maps<constant_scaling_function> template_average;
- template_average.load_from_file( "data/template_average_of_heat_maps" );
-
- BOOST_CHECK( av == template_average );
+ Persistence_heat_maps<constant_scaling_function> av;
+ av.compute_average({&p, &q, &r});
+
+ Persistence_heat_maps<constant_scaling_function> template_average;
+ template_average.load_from_file("data/template_average_of_heat_maps");
+
+ BOOST_CHECK(av == template_average);
}
+BOOST_AUTO_TEST_CASE(check_median_of_heat_maps) {
+ std::vector<std::vector<double> > filter = create_Gaussian_filter(30, 1);
+ Persistence_heat_maps<constant_scaling_function> p("data/file_with_diagram", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> q("data/file_with_diagram_1", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> r("data/file_with_diagram_2", filter, false, 1000, 0, 1);
+
+ std::vector<Persistence_heat_maps<constant_scaling_function>*> to_compute_median;
+ to_compute_median.push_back(&p);
+ to_compute_median.push_back(&q);
+ to_compute_median.push_back(&r);
+ Persistence_heat_maps<constant_scaling_function> median;
+ median.compute_median(to_compute_median);
+
+ Persistence_heat_maps<constant_scaling_function> template_median;
+ template_median.load_from_file("data/template_median_of_heat_maps");
-BOOST_AUTO_TEST_CASE(check_median_of_heat_maps)
-{
- std::vector< std::vector<double> > filter = create_Gaussian_filter(30,1);
- Persistence_heat_maps<constant_scaling_function> p( "data/file_with_diagram" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> q( "data/file_with_diagram_1" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> r( "data/file_with_diagram_2" , filter , false , 1000 , 0 , 1 );
-
- std::vector< Persistence_heat_maps<constant_scaling_function>* > to_compute_median;
- to_compute_median.push_back( &p );
- to_compute_median.push_back( &q );
- to_compute_median.push_back( &r );
- Persistence_heat_maps<constant_scaling_function> median;
- median.compute_median( to_compute_median );
-
- Persistence_heat_maps<constant_scaling_function> template_median;
- template_median.load_from_file( "data/template_median_of_heat_maps" );
-
- BOOST_CHECK( median == template_median );
+ BOOST_CHECK(median == template_median);
}
+BOOST_AUTO_TEST_CASE(check_compute_percentage_of_active_of_heat_maps) {
+ std::vector<std::vector<double> > filter = create_Gaussian_filter(30, 1);
+ Persistence_heat_maps<constant_scaling_function> p("data/file_with_diagram", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> q("data/file_with_diagram_1", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> r("data/file_with_diagram_2", filter, false, 1000, 0, 1);
-BOOST_AUTO_TEST_CASE(check_compute_percentage_of_active_of_heat_maps)
-{
- std::vector< std::vector<double> > filter = create_Gaussian_filter(30,1);
- Persistence_heat_maps<constant_scaling_function> p( "data/file_with_diagram" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> q( "data/file_with_diagram_1" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> r( "data/file_with_diagram_2" , filter , false , 1000 , 0 , 1 );
-
- std::vector< Persistence_heat_maps<constant_scaling_function>* > to_compute_percentage_of_active;
- to_compute_percentage_of_active.push_back( &p );
- to_compute_percentage_of_active.push_back( &q );
- to_compute_percentage_of_active.push_back( &r );
- Persistence_heat_maps<constant_scaling_function> percentage_of_active;
- percentage_of_active.compute_percentage_of_active( to_compute_percentage_of_active , 0.1 );
-
- Persistence_heat_maps<constant_scaling_function> template_percentage_of_active;
- template_percentage_of_active.load_from_file( "data/template_percentage_of_active_of_heat_maps" );
-
- BOOST_CHECK( percentage_of_active == template_percentage_of_active );
+ std::vector<Persistence_heat_maps<constant_scaling_function>*> to_compute_percentage_of_active;
+ to_compute_percentage_of_active.push_back(&p);
+ to_compute_percentage_of_active.push_back(&q);
+ to_compute_percentage_of_active.push_back(&r);
+ Persistence_heat_maps<constant_scaling_function> percentage_of_active;
+ percentage_of_active.compute_percentage_of_active(to_compute_percentage_of_active, 0.1);
+
+ Persistence_heat_maps<constant_scaling_function> template_percentage_of_active;
+ template_percentage_of_active.load_from_file("data/template_percentage_of_active_of_heat_maps");
+
+ BOOST_CHECK(percentage_of_active == template_percentage_of_active);
+}
+
+BOOST_AUTO_TEST_CASE(check_vectorize_for_heat_maps) {
+ std::vector<std::vector<double> > filter = create_Gaussian_filter(30, 1);
+ Persistence_heat_maps<constant_scaling_function> p("data/file_with_diagram", filter, false, 5, 0, 1);
+
+ std::vector<double> p_vect_template;
+
+ p_vect_template.push_back(0.0606728);
+ p_vect_template.push_back(0.0610023);
+ p_vect_template.push_back(0.0607978);
+ p_vect_template.push_back(0.0600647);
+ p_vect_template.push_back(0.0588224);
+ p_vect_template.push_back(0.0619829);
+ p_vect_template.push_back(0.0623218);
+ p_vect_template.push_back(0.0621152);
+ p_vect_template.push_back(0.0613686);
+ p_vect_template.push_back(0.0601016);
+ p_vect_template.push_back(0.0627679);
+ p_vect_template.push_back(0.0631134);
+ p_vect_template.push_back(0.0629066);
+ p_vect_template.push_back(0.0621528);
+ p_vect_template.push_back(0.0608719);
+ p_vect_template.push_back(0.0630073);
+ p_vect_template.push_back(0.0633564);
+ p_vect_template.push_back(0.0631511);
+ p_vect_template.push_back(0.0623968);
+ p_vect_template.push_back(0.0611132);
+ p_vect_template.push_back(0.0626947);
+ p_vect_template.push_back(0.0630445);
+ p_vect_template.push_back(0.0628425);
+ p_vect_template.push_back(0.0620941);
+ p_vect_template.push_back(0.060819);
+
+ std::vector<double> p_vect = p.vectorize(0);
+ for (size_t i = 0; i != p_vect.size(); ++i) {
+ BOOST_CHECK(almost_equal(p_vect_template[i], p_vect[i]));
+ }
}
-BOOST_AUTO_TEST_CASE(check_vectorize_for_heat_maps)
-{
- std::vector< std::vector<double> > filter = create_Gaussian_filter(30,1);
- Persistence_heat_maps<constant_scaling_function> p( "data/file_with_diagram" , filter , false , 5 , 0 , 1 );
-
- std::vector<double> p_vect_template;
-
- p_vect_template.push_back(0.0606728);
- p_vect_template.push_back(0.0610023);
- p_vect_template.push_back(0.0607978 );
- p_vect_template.push_back(0.0600647 );
- p_vect_template.push_back(0.0588224 );
- p_vect_template.push_back(0.0619829 );
- p_vect_template.push_back(0.0623218 );
- p_vect_template.push_back(0.0621152 );
- p_vect_template.push_back(0.0613686 );
- p_vect_template.push_back(0.0601016 );
- p_vect_template.push_back(0.0627679 );
- p_vect_template.push_back(0.0631134 );
- p_vect_template.push_back(0.0629066 );
- p_vect_template.push_back(0.0621528 );
- p_vect_template.push_back(0.0608719 );
- p_vect_template.push_back(0.0630073 );
- p_vect_template.push_back(0.0633564 );
- p_vect_template.push_back(0.0631511 );
- p_vect_template.push_back(0.0623968 );
- p_vect_template.push_back(0.0611132 );
- p_vect_template.push_back(0.0626947 );
- p_vect_template.push_back(0.0630445 );
- p_vect_template.push_back(0.0628425 );
- p_vect_template.push_back(0.0620941 );
- p_vect_template.push_back(0.060819);
-
- std::vector<double> p_vect = p.vectorize(0);
- for ( size_t i = 0 ; i != p_vect.size() ; ++i )
- {
- BOOST_CHECK( almost_equal( p_vect_template[i] , p_vect[i] ) );
- }
+BOOST_AUTO_TEST_CASE(check_distance_for_heat_maps) {
+ std::vector<std::vector<double> > filter = create_Gaussian_filter(30, 1);
+ Persistence_heat_maps<constant_scaling_function> p("data/file_with_diagram", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> q("data/file_with_diagram_1", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> r("data/file_with_diagram_2", filter, false, 1000, 0, 1);
+
+ // cerr << p.distance( p ) << endl;
+ // cerr << p.distance( q ) << endl;
+ // cerr << p.distance( r ) << endl;
+ // cerr << q.distance( p ) << endl;
+ // cerr << q.distance( q ) << endl;
+ // cerr << q.distance( r ) << endl;
+ // cerr << r.distance( p ) << endl;
+ // cerr << r.distance( q ) << endl;
+ // cerr << r.distance( r ) << endl;
+ // 0 624.183 415.815
+ // 624.183 0 528.06Z
+ // 415.815 528.066 0
+
+ BOOST_CHECK(fabs(p.distance(p) - 0) < 0.0005);
+ BOOST_CHECK(fabs(p.distance(q) - 624.183) < 0.0005);
+ BOOST_CHECK(fabs(p.distance(r) - 415.815) < 0.0005);
+ BOOST_CHECK(fabs(q.distance(p) - 624.183) < 0.0005);
+ BOOST_CHECK(fabs(q.distance(q) - 0) < 0.0005);
+ BOOST_CHECK(fabs(q.distance(r) - 528.066) < 0.0005);
+ BOOST_CHECK(fabs(r.distance(p) - 415.815) < 0.0005);
+ BOOST_CHECK(fabs(r.distance(q) - 528.066) < 0.0005);
+ BOOST_CHECK(fabs(r.distance(r) - 0) < 0.0005);
}
+BOOST_AUTO_TEST_CASE(check_projections_to_R_for_heat_maps) {
+ std::vector<std::vector<double> > filter = create_Gaussian_filter(30, 1);
+ Persistence_heat_maps<constant_scaling_function> p("data/file_with_diagram", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> q("data/file_with_diagram_1", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> r("data/file_with_diagram_2", filter, false, 1000, 0, 1);
-BOOST_AUTO_TEST_CASE(check_distance_for_heat_maps)
-{
- std::vector< std::vector<double> > filter = create_Gaussian_filter(30,1);
- Persistence_heat_maps<constant_scaling_function> p( "data/file_with_diagram" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> q( "data/file_with_diagram_1" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> r( "data/file_with_diagram_2" , filter , false , 1000 , 0 , 1 );
-
- //cerr << p.distance( p ) << endl;
- //cerr << p.distance( q ) << endl;
- //cerr << p.distance( r ) << endl;
- //cerr << q.distance( p ) << endl;
- //cerr << q.distance( q ) << endl;
- //cerr << q.distance( r ) << endl;
- //cerr << r.distance( p ) << endl;
- //cerr << r.distance( q ) << endl;
- //cerr << r.distance( r ) << endl;
- //0 624.183 415.815
- //624.183 0 528.06Z
- //415.815 528.066 0
-
- BOOST_CHECK( fabs( p.distance( p ) - 0) < 0.0005);
- BOOST_CHECK( fabs( p.distance( q ) - 624.183)< 0.0005);
- BOOST_CHECK( fabs( p.distance( r ) - 415.815)< 0.0005);
- BOOST_CHECK( fabs( q.distance( p ) - 624.183)< 0.0005);
- BOOST_CHECK( fabs( q.distance( q ) - 0)< 0.0005);
- BOOST_CHECK( fabs( q.distance( r ) - 528.066)< 0.0005);
- BOOST_CHECK( fabs( r.distance( p ) - 415.815)< 0.0005);
- BOOST_CHECK( fabs( r.distance( q ) - 528.066)< 0.0005);
- BOOST_CHECK( fabs( r.distance( r ) - 0)< 0.0005);
+ // cerr << p.project_to_R(0) << endl;
+ // cerr << q.project_to_R(0) << endl;
+ // cerr << r.project_to_R(0) << endl;
+
+ BOOST_CHECK(fabs(p.project_to_R(0) - 44.3308) < 0.0005);
+ BOOST_CHECK(fabs(q.project_to_R(0) - 650.568) < 0.0005);
+ BOOST_CHECK(fabs(r.project_to_R(0) - 429.287) < 0.0005);
+}
+
+BOOST_AUTO_TEST_CASE(check_scalar_products_for_heat_maps) {
+ std::vector<std::vector<double> > filter = create_Gaussian_filter(30, 1);
+ Persistence_heat_maps<constant_scaling_function> p("data/file_with_diagram", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> q("data/file_with_diagram_1", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> r("data/file_with_diagram_2", filter, false, 1000, 0, 1);
+
+ // cerr << p.compute_scalar_product( p ) << endl;
+ // cerr << p.compute_scalar_product( q ) << endl;
+ // cerr << p.compute_scalar_product( r ) << endl;
+ // cerr << q.compute_scalar_product( p ) << endl;
+ // cerr << q.compute_scalar_product( q ) << endl;
+ // cerr << q.compute_scalar_product( r ) << endl;
+ // cerr << r.compute_scalar_product( p ) << endl;
+ // cerr << r.compute_scalar_product( q ) << endl;
+ // cerr << r.compute_scalar_product( r ) << endl;
+
+ BOOST_CHECK(fabs(p.compute_scalar_product(p) - 0.0345687) < 0.0005);
+ BOOST_CHECK(fabs(p.compute_scalar_product(q) - 0.0509357) < 0.0005);
+ BOOST_CHECK(fabs(p.compute_scalar_product(r) - 0.0375608) < 0.0005);
+ BOOST_CHECK(fabs(q.compute_scalar_product(p) - 0.0509357) < 0.0005);
+ BOOST_CHECK(fabs(q.compute_scalar_product(q) - 1.31293) < 0.0005);
+ BOOST_CHECK(fabs(q.compute_scalar_product(r) - 0.536799) < 0.0005);
+ BOOST_CHECK(fabs(r.compute_scalar_product(p) - 0.0375608) < 0.0005);
+ BOOST_CHECK(fabs(r.compute_scalar_product(q) - 0.536799) < 0.0005);
+ BOOST_CHECK(fabs(r.compute_scalar_product(r) - 0.672907) < 0.0005);
}
+BOOST_AUTO_TEST_CASE(check_arythmetic_operations_for_heat_maps) {
+ std::vector<std::vector<double> > filter = create_Gaussian_filter(30, 1);
+ Persistence_heat_maps<constant_scaling_function> p("data/file_with_diagram", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> q("data/file_with_diagram_1", filter, false, 1000, 0, 1);
+ Persistence_heat_maps<constant_scaling_function> sum = p + q;
+ Persistence_heat_maps<constant_scaling_function> difference = p - q;
+ Persistence_heat_maps<constant_scaling_function> multiply_by_scalar = 2 * p;
-BOOST_AUTO_TEST_CASE(check_projections_to_R_for_heat_maps)
-{
- std::vector< std::vector<double> > filter = create_Gaussian_filter(30,1);
- Persistence_heat_maps<constant_scaling_function> p( "data/file_with_diagram" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> q( "data/file_with_diagram_1" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> r( "data/file_with_diagram_2" , filter , false , 1000 , 0 , 1 );
+ // sum.print_to_file( "sum" );
+ // difference.print_to_file( "difference" );
+ // multiply_by_scalar.print_to_file( "multiply_by_scalar" );
- //cerr << p.project_to_R(0) << endl;
- //cerr << q.project_to_R(0) << endl;
- //cerr << r.project_to_R(0) << endl;
+ Persistence_heat_maps<constant_scaling_function> sum_template;
+ sum_template.load_from_file("data/heat_map_sum");
+ Persistence_heat_maps<constant_scaling_function> difference_template;
+ difference_template.load_from_file("data/heat_map_difference");
+ Persistence_heat_maps<constant_scaling_function> multiply_by_scalar_template;
+ multiply_by_scalar_template.load_from_file("data/heat_map_multiply_by_scalar");
- BOOST_CHECK( fabs( p.project_to_R(0) - 44.3308 )< 0.0005);
- BOOST_CHECK( fabs( q.project_to_R(0) - 650.568 )< 0.0005);
- BOOST_CHECK( fabs( r.project_to_R(0) - 429.287 )< 0.0005);
+ BOOST_CHECK(sum == sum_template);
}
+BOOST_AUTO_TEST_CASE(check_distance_of_heat_maps_infinite_power_parameters) {
+ std::vector<std::vector<double> > filter = create_Gaussian_filter(100, 1);
+ Persistence_heat_maps<constant_scaling_function> p("data/file_with_diagram", filter, false, 1000, 0, 1);
-BOOST_AUTO_TEST_CASE(check_scalar_products_for_heat_maps)
-{
- std::vector< std::vector<double> > filter = create_Gaussian_filter(30,1);
- Persistence_heat_maps<constant_scaling_function> p( "data/file_with_diagram" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> q( "data/file_with_diagram_1" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> r( "data/file_with_diagram_2" , filter , false , 1000 , 0 , 1 );
-
- //cerr << p.compute_scalar_product( p ) << endl;
- //cerr << p.compute_scalar_product( q ) << endl;
- //cerr << p.compute_scalar_product( r ) << endl;
- //cerr << q.compute_scalar_product( p ) << endl;
- //cerr << q.compute_scalar_product( q ) << endl;
- //cerr << q.compute_scalar_product( r ) << endl;
- //cerr << r.compute_scalar_product( p ) << endl;
- //cerr << r.compute_scalar_product( q ) << endl;
- //cerr << r.compute_scalar_product( r ) << endl;
-
-
- BOOST_CHECK( fabs( p.compute_scalar_product( p ) - 0.0345687 )< 0.0005);
- BOOST_CHECK( fabs( p.compute_scalar_product( q ) - 0.0509357 )< 0.0005);
- BOOST_CHECK( fabs( p.compute_scalar_product( r ) - 0.0375608 )< 0.0005);
- BOOST_CHECK( fabs( q.compute_scalar_product( p ) - 0.0509357 )< 0.0005);
- BOOST_CHECK( fabs( q.compute_scalar_product( q ) - 1.31293 )< 0.0005);
- BOOST_CHECK( fabs( q.compute_scalar_product( r ) - 0.536799)< 0.0005);
- BOOST_CHECK( fabs( r.compute_scalar_product( p ) - 0.0375608)< 0.0005);
- BOOST_CHECK( fabs( r.compute_scalar_product( q ) - 0.536799)< 0.0005);
- BOOST_CHECK( fabs( r.compute_scalar_product( r ) - 0.672907)< 0.0005);
-
-}
+ std::vector<std::vector<double> > filter_2 = create_Gaussian_filter(150, 1);
+ Persistence_heat_maps<constant_scaling_function> q("data/file_with_diagram", filter_2, true, 1000, 0, 1);
+ double distance_max_double_parameter = p.distance(q, std::numeric_limits<double>::max());
+ double distance_inf_double_parameter = p.distance(q, std::numeric_limits<double>::infinity());
+ // std::cerr << "distance_max_double_parameter: " << distance_max_double_parameter << std::endl;
+ // std::cerr << "distance_inf_double_parameter: " << distance_inf_double_parameter << std::endl;
-BOOST_AUTO_TEST_CASE(check_arythmetic_operations_for_heat_maps)
-{
- std::vector< std::vector<double> > filter = create_Gaussian_filter(30,1);
- Persistence_heat_maps<constant_scaling_function> p( "data/file_with_diagram" , filter , false , 1000 , 0 , 1 );
- Persistence_heat_maps<constant_scaling_function> q( "data/file_with_diagram_1" , filter , false , 1000 , 0 , 1 );
-
- Persistence_heat_maps<constant_scaling_function> sum = p + q;
- Persistence_heat_maps<constant_scaling_function> difference = p - q;
- Persistence_heat_maps<constant_scaling_function> multiply_by_scalar = 2*p;
-
- //sum.print_to_file( "sum" );
- //difference.print_to_file( "difference" );
- //multiply_by_scalar.print_to_file( "multiply_by_scalar" );
-
- Persistence_heat_maps<constant_scaling_function> sum_template;
- sum_template.load_from_file( "data/heat_map_sum" );
- Persistence_heat_maps<constant_scaling_function> difference_template;
- difference_template.load_from_file( "data/heat_map_difference" );
- Persistence_heat_maps<constant_scaling_function> multiply_by_scalar_template;
- multiply_by_scalar_template.load_from_file( "data/heat_map_multiply_by_scalar" );
-
- BOOST_CHECK( sum == sum_template );
+ BOOST_CHECK(distance_max_double_parameter == distance_inf_double_parameter);
}
-BOOST_AUTO_TEST_CASE(check_distance_of_heat_maps_infinite_power_parameters)
-{
- std::vector< std::vector<double> > filter = create_Gaussian_filter(100,1);
- Persistence_heat_maps<constant_scaling_function> p( "data/file_with_diagram" , filter , false , 1000 , 0 , 1 );
-
- std::vector< std::vector<double> > filter_2 = create_Gaussian_filter(150,1);
- Persistence_heat_maps<constant_scaling_function> q( "data/file_with_diagram" , filter_2 , true , 1000 , 0 , 1 );
-
- double distance_max_double_parameter = p.distance( q , std::numeric_limits<double>::max() );
- double distance_inf_double_parameter = p.distance( q , std::numeric_limits<double>::infinity() );
-
- //std::cerr << "distance_max_double_parameter: " << distance_max_double_parameter << std::endl;
- //std::cerr << "distance_inf_double_parameter: " << distance_inf_double_parameter << std::endl;
-
- BOOST_CHECK( distance_max_double_parameter == distance_inf_double_parameter );
-}
+// 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;
+ */
-//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::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" );
*/
-/*
- 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;
+ 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" );
+ //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::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::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 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" );
+ 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/Persistence_representations/test/persistence_intervals_test.cpp b/src/Persistence_representations/test/persistence_intervals_test.cpp
index 8bad499a..a0580bb8 100644
--- a/src/Persistence_representations/test/persistence_intervals_test.cpp
+++ b/src/Persistence_representations/test/persistence_intervals_test.cpp
@@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "Persistence_representations"
#include <boost/test/unit_test.hpp>
@@ -30,314 +28,275 @@
#include <iostream>
-
-
using namespace Gudhi;
using namespace Gudhi::Persistence_representations;
-
double epsilon = 0.0000005;
+// cout << "Left most end of the interval : " << min_max_.first << std::endl;
+// cout << "Right most end of the interval : " << min_max_.second << std::endl;
+BOOST_AUTO_TEST_CASE(check_min_max_function) {
+ Persistence_intervals p("data/file_with_diagram");
+ std::pair<double, double> min_max_ = p.get_x_range();
-
-
+ // cout << min_max_.first << " " << min_max_.second << std::endl;getchar();
-//cout << "Left most end of the interval : " << min_max_.first << std::endl;
-//cout << "Right most end of the interval : " << min_max_.second << std::endl;
-BOOST_AUTO_TEST_CASE(check_min_max_function)
-{
- Persistence_intervals p( "data/file_with_diagram" );
- std::pair<double,double> min_max_ = p.get_x_range();
-
- //cout << min_max_.first << " " << min_max_.second << std::endl;getchar();
-
- BOOST_CHECK( fabs ( min_max_.first - 0.0290362 ) <= epsilon );
- BOOST_CHECK( fabs ( min_max_.second - 0.994537 ) <= epsilon );
+ BOOST_CHECK(fabs(min_max_.first - 0.0290362) <= epsilon);
+ BOOST_CHECK(fabs(min_max_.second - 0.994537) <= epsilon);
}
-
-
-
-
-BOOST_AUTO_TEST_CASE(check_length_of_dominant_intervals)
-{
- Persistence_intervals p( "data/file_with_diagram" );
- std::vector<double> dominant_ten_intervals_length = p.length_of_dominant_intervals(10);
- std::vector< double > dominant_intervals_length;
- dominant_intervals_length.push_back(0.862625);
- dominant_intervals_length.push_back(0.800893);
- dominant_intervals_length.push_back(0.762061);
- dominant_intervals_length.push_back(0.756501);
- dominant_intervals_length.push_back(0.729367);
- dominant_intervals_length.push_back(0.718177);
- dominant_intervals_length.push_back(0.708395);
- dominant_intervals_length.push_back(0.702844);
- dominant_intervals_length.push_back(0.700468);
- dominant_intervals_length.push_back(0.622177);
- for ( size_t i = 0 ; i != dominant_ten_intervals_length.size() ; ++i )
- {
- BOOST_CHECK( fabs ( dominant_ten_intervals_length[i] - dominant_intervals_length[i] ) <= epsilon );
- }
+BOOST_AUTO_TEST_CASE(check_length_of_dominant_intervals) {
+ Persistence_intervals p("data/file_with_diagram");
+ std::vector<double> dominant_ten_intervals_length = p.length_of_dominant_intervals(10);
+ std::vector<double> dominant_intervals_length;
+ dominant_intervals_length.push_back(0.862625);
+ dominant_intervals_length.push_back(0.800893);
+ dominant_intervals_length.push_back(0.762061);
+ dominant_intervals_length.push_back(0.756501);
+ dominant_intervals_length.push_back(0.729367);
+ dominant_intervals_length.push_back(0.718177);
+ dominant_intervals_length.push_back(0.708395);
+ dominant_intervals_length.push_back(0.702844);
+ dominant_intervals_length.push_back(0.700468);
+ dominant_intervals_length.push_back(0.622177);
+ for (size_t i = 0; i != dominant_ten_intervals_length.size(); ++i) {
+ BOOST_CHECK(fabs(dominant_ten_intervals_length[i] - dominant_intervals_length[i]) <= epsilon);
+ }
}
-BOOST_AUTO_TEST_CASE(check_dominant_intervals)
-{
- Persistence_intervals p( "data/file_with_diagram" );
- std::vector< std::pair<double,double> > ten_dominant_intervals = p.dominant_intervals( 10 );
-
- std::vector< std::pair<double,double> > templ;
- templ.push_back( std::pair<double,double>( 0.114718,0.977343) );
- templ.push_back( std::pair<double,double>( 0.133638,0.93453) );
- templ.push_back( std::pair<double,double>( 0.104599,0.866659) );
- templ.push_back( std::pair<double,double>( 0.149798,0.906299) );
- templ.push_back( std::pair<double,double>( 0.247352,0.976719) );
- templ.push_back( std::pair<double,double>( 0.192675,0.910852) );
- templ.push_back( std::pair<double,double>( 0.191836,0.900231) );
- templ.push_back( std::pair<double,double>( 0.284998,0.987842) );
- templ.push_back( std::pair<double,double>( 0.294069,0.994537) );
- templ.push_back( std::pair<double,double>( 0.267421,0.889597) );
-
- for ( size_t i = 0 ; i != ten_dominant_intervals.size() ; ++i )
- {
- BOOST_CHECK( fabs ( ten_dominant_intervals[i].first - templ[i].first ) <= epsilon );
- BOOST_CHECK( fabs ( ten_dominant_intervals[i].second - templ[i].second ) <= epsilon );
- }
+BOOST_AUTO_TEST_CASE(check_dominant_intervals) {
+ Persistence_intervals p("data/file_with_diagram");
+ std::vector<std::pair<double, double> > ten_dominant_intervals = p.dominant_intervals(10);
+
+ std::vector<std::pair<double, double> > templ;
+ templ.push_back(std::pair<double, double>(0.114718, 0.977343));
+ templ.push_back(std::pair<double, double>(0.133638, 0.93453));
+ templ.push_back(std::pair<double, double>(0.104599, 0.866659));
+ templ.push_back(std::pair<double, double>(0.149798, 0.906299));
+ templ.push_back(std::pair<double, double>(0.247352, 0.976719));
+ templ.push_back(std::pair<double, double>(0.192675, 0.910852));
+ templ.push_back(std::pair<double, double>(0.191836, 0.900231));
+ templ.push_back(std::pair<double, double>(0.284998, 0.987842));
+ templ.push_back(std::pair<double, double>(0.294069, 0.994537));
+ templ.push_back(std::pair<double, double>(0.267421, 0.889597));
+
+ for (size_t i = 0; i != ten_dominant_intervals.size(); ++i) {
+ BOOST_CHECK(fabs(ten_dominant_intervals[i].first - templ[i].first) <= epsilon);
+ BOOST_CHECK(fabs(ten_dominant_intervals[i].second - templ[i].second) <= epsilon);
+ }
}
-BOOST_AUTO_TEST_CASE(check_histogram_of_lengths)
-{
- Persistence_intervals p( "data/file_with_diagram" );
- std::vector< size_t > histogram = p.histogram_of_lengths( 10 );
- std::vector< size_t > template_histogram;
- template_histogram.push_back(10);
- template_histogram.push_back(5);
- template_histogram.push_back(3);
- template_histogram.push_back(4);
- template_histogram.push_back(4);
- template_histogram.push_back(3);
- template_histogram.push_back(6);
- template_histogram.push_back(1);
- template_histogram.push_back(7);
- template_histogram.push_back(1);
- template_histogram.push_back(1);
- for ( size_t i = 0 ; i != histogram.size() ; ++i )
- {
- BOOST_CHECK( fabs ( histogram[i] - template_histogram[i] ) <= epsilon );
- }
+BOOST_AUTO_TEST_CASE(check_histogram_of_lengths) {
+ Persistence_intervals p("data/file_with_diagram");
+ std::vector<size_t> histogram = p.histogram_of_lengths(10);
+ std::vector<size_t> template_histogram;
+ template_histogram.push_back(10);
+ template_histogram.push_back(5);
+ template_histogram.push_back(3);
+ template_histogram.push_back(4);
+ template_histogram.push_back(4);
+ template_histogram.push_back(3);
+ template_histogram.push_back(6);
+ template_histogram.push_back(1);
+ template_histogram.push_back(7);
+ template_histogram.push_back(1);
+ template_histogram.push_back(1);
+ for (size_t i = 0; i != histogram.size(); ++i) {
+ BOOST_CHECK(fabs(histogram[i] - template_histogram[i]) <= epsilon);
+ }
}
-BOOST_AUTO_TEST_CASE(check_cumulative_histograms_of_lengths)
-{
- Persistence_intervals p( "data/file_with_diagram" );
- std::vector< size_t > cumulative_histogram = p.cumulative_histogram_of_lengths( 10 );
- std::vector< size_t > template_cumulative_histogram;
- template_cumulative_histogram.push_back(10);
- template_cumulative_histogram.push_back(15);
- template_cumulative_histogram.push_back(18);
- template_cumulative_histogram.push_back(22);
- template_cumulative_histogram.push_back(26);
- template_cumulative_histogram.push_back(29);
- template_cumulative_histogram.push_back(35);
- template_cumulative_histogram.push_back(36);
- template_cumulative_histogram.push_back(43);
- template_cumulative_histogram.push_back(44);
- template_cumulative_histogram.push_back(45);
-
- for ( size_t i = 0 ; i != cumulative_histogram.size() ; ++i )
- {
- BOOST_CHECK( fabs ( cumulative_histogram[i] - template_cumulative_histogram[i] ) <= epsilon );
- }
-}
-BOOST_AUTO_TEST_CASE(check_characteristic_function_of_diagram)
-{
- Persistence_intervals p( "data/file_with_diagram" );
- std::pair<double,double> min_max_ = p.get_x_range();
- std::vector< double > char_funct_diag = p.characteristic_function_of_diagram( min_max_.first , min_max_.second );
- std::vector< double > template_char_funct_diag;
- template_char_funct_diag.push_back( 0.370665 );
- template_char_funct_diag.push_back( 0.84058 );
- template_char_funct_diag.push_back( 1.24649 );
- template_char_funct_diag.push_back( 1.3664 );
- template_char_funct_diag.push_back( 1.34032 );
- template_char_funct_diag.push_back( 1.31904 );
- template_char_funct_diag.push_back( 1.14076 );
- template_char_funct_diag.push_back( 0.991259 );
- template_char_funct_diag.push_back( 0.800714 );
- template_char_funct_diag.push_back( 0.0676303 );
-
- for ( size_t i = 0 ; i != char_funct_diag.size() ; ++i )
- {
- //cout << char_funct_diag[i] << std::endl;
- if ( fabs ( char_funct_diag[i] - template_char_funct_diag[i] ) >= 0.0001 )
- {
- std::cout << "Boost test fail check_characteristic_function_of_diagram : " << std::endl;
- std::cerr << char_funct_diag[i] << " " << template_char_funct_diag[i] << std::endl;
- std::cerr << fabs ( char_funct_diag[i] - template_char_funct_diag[i] ) << std::endl;
- std::cerr << 0.0001 << std::endl;
- getchar();
- }
- BOOST_CHECK( fabs ( char_funct_diag[i] - template_char_funct_diag[i] ) <= 0.0001 );
- }
-}
-
-
-BOOST_AUTO_TEST_CASE(check_cumulative_characteristic_function_of_diagram)
-{
- Persistence_intervals p( "data/file_with_diagram" );
- std::pair<double,double> min_max_ = p.get_x_range();
- std::vector< double > cumul_char_funct_diag = p.cumulative_characteristic_function_of_diagram( min_max_.first , min_max_.second );
- std::vector< double > template_char_funct_diag_cumul;
-
- template_char_funct_diag_cumul.push_back(0.370665);
- template_char_funct_diag_cumul.push_back(1.21125);
- template_char_funct_diag_cumul.push_back(2.45774);
- template_char_funct_diag_cumul.push_back(3.82414);
- template_char_funct_diag_cumul.push_back(5.16446);
- template_char_funct_diag_cumul.push_back(6.4835);
- template_char_funct_diag_cumul.push_back(7.62426);
- template_char_funct_diag_cumul.push_back(8.61552);
- template_char_funct_diag_cumul.push_back(9.41623);
- template_char_funct_diag_cumul.push_back(9.48386);
-
- for ( size_t i = 0 ; i != cumul_char_funct_diag.size() ; ++i )
- {
- //cout << cumul_char_funct_diag[i] << std::endl;
- BOOST_CHECK( fabs (cumul_char_funct_diag[i] - template_char_funct_diag_cumul[i] ) <= 0.0001 );
- }
+BOOST_AUTO_TEST_CASE(check_cumulative_histograms_of_lengths) {
+ Persistence_intervals p("data/file_with_diagram");
+ std::vector<size_t> cumulative_histogram = p.cumulative_histogram_of_lengths(10);
+ std::vector<size_t> template_cumulative_histogram;
+ template_cumulative_histogram.push_back(10);
+ template_cumulative_histogram.push_back(15);
+ template_cumulative_histogram.push_back(18);
+ template_cumulative_histogram.push_back(22);
+ template_cumulative_histogram.push_back(26);
+ template_cumulative_histogram.push_back(29);
+ template_cumulative_histogram.push_back(35);
+ template_cumulative_histogram.push_back(36);
+ template_cumulative_histogram.push_back(43);
+ template_cumulative_histogram.push_back(44);
+ template_cumulative_histogram.push_back(45);
+
+ for (size_t i = 0; i != cumulative_histogram.size(); ++i) {
+ BOOST_CHECK(fabs(cumulative_histogram[i] - template_cumulative_histogram[i]) <= epsilon);
+ }
}
-
-
-BOOST_AUTO_TEST_CASE(check_compute_persistent_betti_numbers)
-{
- Persistence_intervals p( "data/file_with_diagram" );
- std::vector< std::pair< double , double > > pbns;
- pbns.push_back(std::pair<double,double>( 0.0290362,1 ));
- pbns.push_back(std::pair<double,double>( 0.0307676,2 ));
- pbns.push_back(std::pair<double,double>( 0.0366312,3 ));
- pbns.push_back(std::pair<double,double>( 0.0544614,4 ));
- pbns.push_back(std::pair<double,double>( 0.0920033,5 ));
- pbns.push_back(std::pair<double,double>( 0.104599,6 ));
- pbns.push_back(std::pair<double,double>( 0.114718,7 ));
- pbns.push_back(std::pair<double,double>( 0.117379,8 ));
- pbns.push_back(std::pair<double,double>( 0.123493,9 ));
- pbns.push_back(std::pair<double,double>( 0.133638,10 ));
- pbns.push_back(std::pair<double,double>( 0.137798,9 ));
- pbns.push_back(std::pair<double,double>( 0.149798,10 ));
- pbns.push_back(std::pair<double,double>( 0.155421,11 ));
- pbns.push_back(std::pair<double,double>( 0.158443,12 ));
- pbns.push_back(std::pair<double,double>( 0.176956,13 ));
- pbns.push_back(std::pair<double,double>( 0.183234,12 ));
- pbns.push_back(std::pair<double,double>( 0.191069,13 ));
- pbns.push_back(std::pair<double,double>( 0.191333,14 ));
- pbns.push_back(std::pair<double,double>( 0.191836,15 ));
- pbns.push_back(std::pair<double,double>( 0.192675,16 ));
- pbns.push_back(std::pair<double,double>( 0.208564,17 ));
- pbns.push_back(std::pair<double,double>( 0.218425,18 ));
- pbns.push_back(std::pair<double,double>( 0.219902,17 ));
- pbns.push_back(std::pair<double,double>( 0.23233,16 ));
- pbns.push_back(std::pair<double,double>( 0.234558,17 ));
- pbns.push_back(std::pair<double,double>( 0.237166,16 ));
- pbns.push_back(std::pair<double,double>( 0.247352,17 ));
- pbns.push_back(std::pair<double,double>( 0.267421,18 ));
- pbns.push_back(std::pair<double,double>( 0.268093,19 ));
- pbns.push_back(std::pair<double,double>( 0.278734,18 ));
- pbns.push_back(std::pair<double,double>( 0.284722,19 ));
- pbns.push_back(std::pair<double,double>( 0.284998,20 ));
- pbns.push_back(std::pair<double,double>( 0.294069,21 ));
- pbns.push_back(std::pair<double,double>( 0.306293,22 ));
- pbns.push_back(std::pair<double,double>( 0.322361,21 ));
- pbns.push_back(std::pair<double,double>( 0.323152,22 ));
- pbns.push_back(std::pair<double,double>( 0.371021,23 ));
- pbns.push_back(std::pair<double,double>( 0.372395,24 ));
- pbns.push_back(std::pair<double,double>( 0.387744,25 ));
- pbns.push_back(std::pair<double,double>( 0.435537,26 ));
- pbns.push_back(std::pair<double,double>( 0.462911,25 ));
- pbns.push_back(std::pair<double,double>( 0.483569,26 ));
- pbns.push_back(std::pair<double,double>( 0.489209,25 ));
- pbns.push_back(std::pair<double,double>( 0.517115,24 ));
- pbns.push_back(std::pair<double,double>( 0.522197,23 ));
- pbns.push_back(std::pair<double,double>( 0.532665,22 ));
- pbns.push_back(std::pair<double,double>( 0.545262,23 ));
- pbns.push_back(std::pair<double,double>( 0.587227,22 ));
- pbns.push_back(std::pair<double,double>( 0.593036,23 ));
- pbns.push_back(std::pair<double,double>( 0.602647,24 ));
- pbns.push_back(std::pair<double,double>( 0.605044,25 ));
- pbns.push_back(std::pair<double,double>( 0.621962,24 ));
- pbns.push_back(std::pair<double,double>( 0.629449,23 ));
- pbns.push_back(std::pair<double,double>( 0.636719,22 ));
- pbns.push_back(std::pair<double,double>( 0.64957,21 ));
- pbns.push_back(std::pair<double,double>( 0.650781,22 ));
- pbns.push_back(std::pair<double,double>( 0.654951,23 ));
- pbns.push_back(std::pair<double,double>( 0.683489,24 ));
- pbns.push_back(std::pair<double,double>( 0.687172,23 ));
- pbns.push_back(std::pair<double,double>( 0.69703,22 ));
- pbns.push_back(std::pair<double,double>( 0.701174,21 ));
- pbns.push_back(std::pair<double,double>( 0.717623,22 ));
- pbns.push_back(std::pair<double,double>( 0.722023,21 ));
- pbns.push_back(std::pair<double,double>( 0.722298,20 ));
- pbns.push_back(std::pair<double,double>( 0.725347,19 ));
- pbns.push_back(std::pair<double,double>( 0.73071,18 ));
- pbns.push_back(std::pair<double,double>( 0.758355,17 ));
- pbns.push_back(std::pair<double,double>( 0.770913,18 ));
- pbns.push_back(std::pair<double,double>( 0.790833,17 ));
- pbns.push_back(std::pair<double,double>( 0.821211,16 ));
- pbns.push_back(std::pair<double,double>( 0.849305,17 ));
- pbns.push_back(std::pair<double,double>( 0.853669,16 ));
- pbns.push_back(std::pair<double,double>( 0.866659,15 ));
- pbns.push_back(std::pair<double,double>( 0.872896,16 ));
- pbns.push_back(std::pair<double,double>( 0.889597,15 ));
- pbns.push_back(std::pair<double,double>( 0.900231,14 ));
- pbns.push_back(std::pair<double,double>( 0.903847,13 ));
- pbns.push_back(std::pair<double,double>( 0.906299,12 ));
- pbns.push_back(std::pair<double,double>( 0.910852,11 ));
- pbns.push_back(std::pair<double,double>( 0.93453,10 ));
- pbns.push_back(std::pair<double,double>( 0.944757,9 ));
- pbns.push_back(std::pair<double,double>( 0.947812,8 ));
- pbns.push_back(std::pair<double,double>( 0.959154,7 ));
- pbns.push_back(std::pair<double,double>( 0.975654,6 ));
- pbns.push_back(std::pair<double,double>( 0.976719,5 ));
- pbns.push_back(std::pair<double,double>( 0.977343,4 ));
- pbns.push_back(std::pair<double,double>( 0.980129,3 ));
- pbns.push_back(std::pair<double,double>( 0.987842,2 ));
- pbns.push_back(std::pair<double,double>( 0.990127,1 ));
- pbns.push_back(std::pair<double,double>( 0.994537,0 ));
-
-
-
-
- std::vector< std::pair< double , size_t > > pbns_new = p.compute_persistent_betti_numbers();
- for ( size_t i = 0 ; i != pbns.size() ; ++i )
- {
- //cout << pbns_new[i].first << "," << pbns_new[i].second << std::endl;
- BOOST_CHECK( fabs ( pbns[i].first - pbns_new[i].first ) <= epsilon );
- BOOST_CHECK( fabs ( pbns[i].second - pbns_new[i].second ) <= epsilon );
- }
+BOOST_AUTO_TEST_CASE(check_characteristic_function_of_diagram) {
+ Persistence_intervals p("data/file_with_diagram");
+ std::pair<double, double> min_max_ = p.get_x_range();
+ std::vector<double> char_funct_diag = p.characteristic_function_of_diagram(min_max_.first, min_max_.second);
+ std::vector<double> template_char_funct_diag;
+ template_char_funct_diag.push_back(0.370665);
+ template_char_funct_diag.push_back(0.84058);
+ template_char_funct_diag.push_back(1.24649);
+ template_char_funct_diag.push_back(1.3664);
+ template_char_funct_diag.push_back(1.34032);
+ template_char_funct_diag.push_back(1.31904);
+ template_char_funct_diag.push_back(1.14076);
+ template_char_funct_diag.push_back(0.991259);
+ template_char_funct_diag.push_back(0.800714);
+ template_char_funct_diag.push_back(0.0676303);
+
+ for (size_t i = 0; i != char_funct_diag.size(); ++i) {
+ // cout << char_funct_diag[i] << std::endl;
+ if (fabs(char_funct_diag[i] - template_char_funct_diag[i]) >= 0.0001) {
+ std::cout << "Boost test fail check_characteristic_function_of_diagram : " << std::endl;
+ std::cerr << char_funct_diag[i] << " " << template_char_funct_diag[i] << std::endl;
+ std::cerr << fabs(char_funct_diag[i] - template_char_funct_diag[i]) << std::endl;
+ std::cerr << 0.0001 << std::endl;
+ getchar();
+ }
+ BOOST_CHECK(fabs(char_funct_diag[i] - template_char_funct_diag[i]) <= 0.0001);
+ }
}
-
-
-BOOST_AUTO_TEST_CASE(check_k_n_n)
-{
- Persistence_intervals p( "data/file_with_diagram" );
- std::vector< double > knn = p.k_n_n( 5 );
- std::vector< double > knn_template;
- knn_template.push_back( 1.04208 );
- knn_template.push_back( 1.00344 );
- knn_template.push_back( 0.979395 );
- knn_template.push_back( 0.890643 );
- knn_template.push_back( 0.874769 );
- knn_template.push_back( 0.845787 );
- knn_template.push_back( 0.819713 );
- knn_template.push_back( 0.803984 );
- knn_template.push_back( 0.799864 );
- knn_template.push_back( 0.786945 );
-
- for ( size_t i = 0 ; i != knn.size() ; ++i )
- {
- //cout << knn[i] << std::endl;
- BOOST_CHECK( fabs ( knn[i] - knn_template[i] ) <= 0.000005 );
- }
+BOOST_AUTO_TEST_CASE(check_cumulative_characteristic_function_of_diagram) {
+ Persistence_intervals p("data/file_with_diagram");
+ std::pair<double, double> min_max_ = p.get_x_range();
+ std::vector<double> cumul_char_funct_diag =
+ p.cumulative_characteristic_function_of_diagram(min_max_.first, min_max_.second);
+ std::vector<double> template_char_funct_diag_cumul;
+
+ template_char_funct_diag_cumul.push_back(0.370665);
+ template_char_funct_diag_cumul.push_back(1.21125);
+ template_char_funct_diag_cumul.push_back(2.45774);
+ template_char_funct_diag_cumul.push_back(3.82414);
+ template_char_funct_diag_cumul.push_back(5.16446);
+ template_char_funct_diag_cumul.push_back(6.4835);
+ template_char_funct_diag_cumul.push_back(7.62426);
+ template_char_funct_diag_cumul.push_back(8.61552);
+ template_char_funct_diag_cumul.push_back(9.41623);
+ template_char_funct_diag_cumul.push_back(9.48386);
+
+ for (size_t i = 0; i != cumul_char_funct_diag.size(); ++i) {
+ // cout << cumul_char_funct_diag[i] << std::endl;
+ BOOST_CHECK(fabs(cumul_char_funct_diag[i] - template_char_funct_diag_cumul[i]) <= 0.0001);
+ }
}
+BOOST_AUTO_TEST_CASE(check_compute_persistent_betti_numbers) {
+ Persistence_intervals p("data/file_with_diagram");
+ std::vector<std::pair<double, double> > pbns;
+ pbns.push_back(std::pair<double, double>(0.0290362, 1));
+ pbns.push_back(std::pair<double, double>(0.0307676, 2));
+ pbns.push_back(std::pair<double, double>(0.0366312, 3));
+ pbns.push_back(std::pair<double, double>(0.0544614, 4));
+ pbns.push_back(std::pair<double, double>(0.0920033, 5));
+ pbns.push_back(std::pair<double, double>(0.104599, 6));
+ pbns.push_back(std::pair<double, double>(0.114718, 7));
+ pbns.push_back(std::pair<double, double>(0.117379, 8));
+ pbns.push_back(std::pair<double, double>(0.123493, 9));
+ pbns.push_back(std::pair<double, double>(0.133638, 10));
+ pbns.push_back(std::pair<double, double>(0.137798, 9));
+ pbns.push_back(std::pair<double, double>(0.149798, 10));
+ pbns.push_back(std::pair<double, double>(0.155421, 11));
+ pbns.push_back(std::pair<double, double>(0.158443, 12));
+ pbns.push_back(std::pair<double, double>(0.176956, 13));
+ pbns.push_back(std::pair<double, double>(0.183234, 12));
+ pbns.push_back(std::pair<double, double>(0.191069, 13));
+ pbns.push_back(std::pair<double, double>(0.191333, 14));
+ pbns.push_back(std::pair<double, double>(0.191836, 15));
+ pbns.push_back(std::pair<double, double>(0.192675, 16));
+ pbns.push_back(std::pair<double, double>(0.208564, 17));
+ pbns.push_back(std::pair<double, double>(0.218425, 18));
+ pbns.push_back(std::pair<double, double>(0.219902, 17));
+ pbns.push_back(std::pair<double, double>(0.23233, 16));
+ pbns.push_back(std::pair<double, double>(0.234558, 17));
+ pbns.push_back(std::pair<double, double>(0.237166, 16));
+ pbns.push_back(std::pair<double, double>(0.247352, 17));
+ pbns.push_back(std::pair<double, double>(0.267421, 18));
+ pbns.push_back(std::pair<double, double>(0.268093, 19));
+ pbns.push_back(std::pair<double, double>(0.278734, 18));
+ pbns.push_back(std::pair<double, double>(0.284722, 19));
+ pbns.push_back(std::pair<double, double>(0.284998, 20));
+ pbns.push_back(std::pair<double, double>(0.294069, 21));
+ pbns.push_back(std::pair<double, double>(0.306293, 22));
+ pbns.push_back(std::pair<double, double>(0.322361, 21));
+ pbns.push_back(std::pair<double, double>(0.323152, 22));
+ pbns.push_back(std::pair<double, double>(0.371021, 23));
+ pbns.push_back(std::pair<double, double>(0.372395, 24));
+ pbns.push_back(std::pair<double, double>(0.387744, 25));
+ pbns.push_back(std::pair<double, double>(0.435537, 26));
+ pbns.push_back(std::pair<double, double>(0.462911, 25));
+ pbns.push_back(std::pair<double, double>(0.483569, 26));
+ pbns.push_back(std::pair<double, double>(0.489209, 25));
+ pbns.push_back(std::pair<double, double>(0.517115, 24));
+ pbns.push_back(std::pair<double, double>(0.522197, 23));
+ pbns.push_back(std::pair<double, double>(0.532665, 22));
+ pbns.push_back(std::pair<double, double>(0.545262, 23));
+ pbns.push_back(std::pair<double, double>(0.587227, 22));
+ pbns.push_back(std::pair<double, double>(0.593036, 23));
+ pbns.push_back(std::pair<double, double>(0.602647, 24));
+ pbns.push_back(std::pair<double, double>(0.605044, 25));
+ pbns.push_back(std::pair<double, double>(0.621962, 24));
+ pbns.push_back(std::pair<double, double>(0.629449, 23));
+ pbns.push_back(std::pair<double, double>(0.636719, 22));
+ pbns.push_back(std::pair<double, double>(0.64957, 21));
+ pbns.push_back(std::pair<double, double>(0.650781, 22));
+ pbns.push_back(std::pair<double, double>(0.654951, 23));
+ pbns.push_back(std::pair<double, double>(0.683489, 24));
+ pbns.push_back(std::pair<double, double>(0.687172, 23));
+ pbns.push_back(std::pair<double, double>(0.69703, 22));
+ pbns.push_back(std::pair<double, double>(0.701174, 21));
+ pbns.push_back(std::pair<double, double>(0.717623, 22));
+ pbns.push_back(std::pair<double, double>(0.722023, 21));
+ pbns.push_back(std::pair<double, double>(0.722298, 20));
+ pbns.push_back(std::pair<double, double>(0.725347, 19));
+ pbns.push_back(std::pair<double, double>(0.73071, 18));
+ pbns.push_back(std::pair<double, double>(0.758355, 17));
+ pbns.push_back(std::pair<double, double>(0.770913, 18));
+ pbns.push_back(std::pair<double, double>(0.790833, 17));
+ pbns.push_back(std::pair<double, double>(0.821211, 16));
+ pbns.push_back(std::pair<double, double>(0.849305, 17));
+ pbns.push_back(std::pair<double, double>(0.853669, 16));
+ pbns.push_back(std::pair<double, double>(0.866659, 15));
+ pbns.push_back(std::pair<double, double>(0.872896, 16));
+ pbns.push_back(std::pair<double, double>(0.889597, 15));
+ pbns.push_back(std::pair<double, double>(0.900231, 14));
+ pbns.push_back(std::pair<double, double>(0.903847, 13));
+ pbns.push_back(std::pair<double, double>(0.906299, 12));
+ pbns.push_back(std::pair<double, double>(0.910852, 11));
+ pbns.push_back(std::pair<double, double>(0.93453, 10));
+ pbns.push_back(std::pair<double, double>(0.944757, 9));
+ pbns.push_back(std::pair<double, double>(0.947812, 8));
+ pbns.push_back(std::pair<double, double>(0.959154, 7));
+ pbns.push_back(std::pair<double, double>(0.975654, 6));
+ pbns.push_back(std::pair<double, double>(0.976719, 5));
+ pbns.push_back(std::pair<double, double>(0.977343, 4));
+ pbns.push_back(std::pair<double, double>(0.980129, 3));
+ pbns.push_back(std::pair<double, double>(0.987842, 2));
+ pbns.push_back(std::pair<double, double>(0.990127, 1));
+ pbns.push_back(std::pair<double, double>(0.994537, 0));
+
+ std::vector<std::pair<double, size_t> > pbns_new = p.compute_persistent_betti_numbers();
+ for (size_t i = 0; i != pbns.size(); ++i) {
+ // cout << pbns_new[i].first << "," << pbns_new[i].second << std::endl;
+ BOOST_CHECK(fabs(pbns[i].first - pbns_new[i].first) <= epsilon);
+ BOOST_CHECK(fabs(pbns[i].second - pbns_new[i].second) <= epsilon);
+ }
+}
-
-
+BOOST_AUTO_TEST_CASE(check_k_n_n) {
+ Persistence_intervals p("data/file_with_diagram");
+ std::vector<double> knn = p.k_n_n(5);
+ std::vector<double> knn_template;
+ knn_template.push_back(1.04208);
+ knn_template.push_back(1.00344);
+ knn_template.push_back(0.979395);
+ knn_template.push_back(0.890643);
+ knn_template.push_back(0.874769);
+ knn_template.push_back(0.845787);
+ knn_template.push_back(0.819713);
+ knn_template.push_back(0.803984);
+ knn_template.push_back(0.799864);
+ knn_template.push_back(0.786945);
+
+ for (size_t i = 0; i != knn.size(); ++i) {
+ // cout << knn[i] << std::endl;
+ BOOST_CHECK(fabs(knn[i] - knn_template[i]) <= 0.000005);
+ }
+}
diff --git a/src/Persistence_representations/test/persistence_intervals_with_distances_test.cpp b/src/Persistence_representations/test/persistence_intervals_with_distances_test.cpp
index 703b5011..b936c41d 100644
--- a/src/Persistence_representations/test/persistence_intervals_with_distances_test.cpp
+++ b/src/Persistence_representations/test/persistence_intervals_with_distances_test.cpp
@@ -29,42 +29,33 @@
#include <iostream>
-
-
using namespace Gudhi;
using namespace Gudhi::Persistence_representations;
+BOOST_AUTO_TEST_CASE(check_bottleneck_distances_computation) {
+ Persistence_intervals_with_distances p("data/file_with_diagram");
+ Persistence_intervals_with_distances q("data/file_with_diagram_1");
-BOOST_AUTO_TEST_CASE(check_bottleneck_distances_computation)
-{
- Persistence_intervals_with_distances p( "data/file_with_diagram" );
- Persistence_intervals_with_distances q( "data/file_with_diagram_1" );
-
- double dist = p.distance( q );
-
- //std::cout << "dist : " << dist << std::endl;
-
- BOOST_CHECK( almost_equal(dist,0.389043) );
-}
+ double dist = p.distance(q);
+ // std::cout << "dist : " << dist << std::endl;
-BOOST_AUTO_TEST_CASE(check_default_parameters_in_distance)
-{
- Persistence_intervals_with_distances p( "data/file_with_diagram" );
- Persistence_intervals_with_distances q( "data/file_with_diagram_1" );
-
- double default_parameter_distance = p.distance( q );
- double max_parameter_distance = p.distance( q , std::numeric_limits< double >::max() );
- double inf_parameter_distance = p.distance( q , std::numeric_limits<double>::infinity() );
-
- //std::cout << "default_parameter_distance : " << default_parameter_distance << std::endl;
- //std::cout << "max_parameter_distance : " << max_parameter_distance << std::endl;
- //std::cout << "inf_parameter_distance : " << inf_parameter_distance << std::endl;
-
- BOOST_CHECK( default_parameter_distance == max_parameter_distance );
- BOOST_CHECK( inf_parameter_distance == max_parameter_distance );
- BOOST_CHECK( inf_parameter_distance == max_parameter_distance );
+ BOOST_CHECK(almost_equal(dist, 0.389043));
}
+BOOST_AUTO_TEST_CASE(check_default_parameters_in_distance) {
+ Persistence_intervals_with_distances p("data/file_with_diagram");
+ Persistence_intervals_with_distances q("data/file_with_diagram_1");
+ double default_parameter_distance = p.distance(q);
+ double max_parameter_distance = p.distance(q, std::numeric_limits<double>::max());
+ double inf_parameter_distance = p.distance(q, std::numeric_limits<double>::infinity());
+ // std::cout << "default_parameter_distance : " << default_parameter_distance << std::endl;
+ // std::cout << "max_parameter_distance : " << max_parameter_distance << std::endl;
+ // std::cout << "inf_parameter_distance : " << inf_parameter_distance << std::endl;
+
+ BOOST_CHECK(default_parameter_distance == max_parameter_distance);
+ BOOST_CHECK(inf_parameter_distance == max_parameter_distance);
+ BOOST_CHECK(inf_parameter_distance == max_parameter_distance);
+}
diff --git a/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp b/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp
index 865a8280..40d52415 100644
--- a/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp
+++ b/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp
@@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "Persistence_representations"
#include <boost/test/unit_test.hpp>
@@ -30,359 +28,317 @@
#include <iostream>
-
-
using namespace Gudhi;
using namespace Gudhi::Persistence_representations;
+BOOST_AUTO_TEST_CASE(check_construction_of_landscape) {
+ Persistence_landscape_on_grid l("data/file_with_diagram_1", 100, std::numeric_limits<unsigned short>::max());
+ 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");
-BOOST_AUTO_TEST_CASE(check_construction_of_landscape)
-{
- Persistence_landscape_on_grid l( "data/file_with_diagram_1" , 100 , std::numeric_limits<unsigned short>::max());
- 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" );
-
- BOOST_CHECK( l == g );
+ BOOST_CHECK(l == g);
}
-BOOST_AUTO_TEST_CASE(check_construction_of_landscape_using_only_ten_levels)
-{
- //TODO
- unsigned number = 10;
- Persistence_landscape_on_grid l( "data/file_with_diagram_1" , 100 , number );
- Persistence_landscape_on_grid g( "data/file_with_diagram_1" , 100 , std::numeric_limits<unsigned short>::max());
- //cut all the elements of order > 10 in g.
-
- for ( size_t level = 0 ; level != number ; ++level )
- {
- std::vector<double> v1 = l.vectorize(level);
- std::vector<double> v2 = g.vectorize(level);
- BOOST_CHECK( v1.size() == v2.size() );
- for ( size_t i = 0 ; i != v1.size() ; ++i )
- {
- BOOST_CHECK( v1[i] == v2[i] );
- }
- }
- }
-
-
-
-BOOST_AUTO_TEST_CASE(check_computations_of_integrals)
-{
- Persistence_landscape_on_grid p( "data/file_with_diagram_1" , 100 , std::numeric_limits<unsigned short>::max());
- double integral = p.compute_integral_of_landscape();
- //cerr << "integral : " << integral << endl;getchar();
- BOOST_CHECK( fabs( integral - 27.343 ) <= 0.00005 );
+BOOST_AUTO_TEST_CASE(check_construction_of_landscape_using_only_ten_levels) {
+ // TODO
+ unsigned number = 10;
+ Persistence_landscape_on_grid l("data/file_with_diagram_1", 100, number);
+ Persistence_landscape_on_grid g("data/file_with_diagram_1", 100, std::numeric_limits<unsigned short>::max());
+ // cut all the elements of order > 10 in g.
+
+ for (size_t level = 0; level != number; ++level) {
+ std::vector<double> v1 = l.vectorize(level);
+ std::vector<double> v2 = g.vectorize(level);
+ BOOST_CHECK(v1.size() == v2.size());
+ for (size_t i = 0; i != v1.size(); ++i) {
+ BOOST_CHECK(v1[i] == v2[i]);
+ }
+ }
}
-
-BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly)
-{
- Persistence_landscape_on_grid p( "data/file_with_diagram_1" , 100, std::numeric_limits<unsigned short>::max() );
-
- std::vector< double > integrals_fir_different_levels;
- //integrals_fir_different_levels.push_back();
- integrals_fir_different_levels.push_back(0.241168);
- integrals_fir_different_levels.push_back(0.239276);
- integrals_fir_different_levels.push_back(0.237882);
- integrals_fir_different_levels.push_back(0.235193);
- integrals_fir_different_levels.push_back(0.230115);
- integrals_fir_different_levels.push_back(0.227626);
- integrals_fir_different_levels.push_back(0.226132);
- integrals_fir_different_levels.push_back(0.223643);
- integrals_fir_different_levels.push_back(0.221651);
- integrals_fir_different_levels.push_back(0.220556);
- integrals_fir_different_levels.push_back(0.21727);
- integrals_fir_different_levels.push_back(0.215976);
- integrals_fir_different_levels.push_back(0.213685);
- integrals_fir_different_levels.push_back(0.211993);
- integrals_fir_different_levels.push_back(0.2102);
- integrals_fir_different_levels.push_back(0.208707);
- integrals_fir_different_levels.push_back(0.207014);
- integrals_fir_different_levels.push_back(0.205122);
- integrals_fir_different_levels.push_back(0.204226);
- integrals_fir_different_levels.push_back(0.202633);
-
-
- for ( size_t level = 0 ; level != integrals_fir_different_levels.size() ; ++level )
- {
- double integral = p.compute_integral_of_landscape( level );
- //cerr << integral << endl;
- BOOST_CHECK( fabs( integral - integrals_fir_different_levels[level] ) <= 0.00005 );
- }
-
+BOOST_AUTO_TEST_CASE(check_computations_of_integrals) {
+ Persistence_landscape_on_grid p("data/file_with_diagram_1", 100, std::numeric_limits<unsigned short>::max());
+ double integral = p.compute_integral_of_landscape();
+ // cerr << "integral : " << integral << endl;getchar();
+ BOOST_CHECK(fabs(integral - 27.343) <= 0.00005);
}
+BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly) {
+ Persistence_landscape_on_grid p("data/file_with_diagram_1", 100, std::numeric_limits<unsigned short>::max());
+
+ std::vector<double> integrals_fir_different_levels;
+ // integrals_fir_different_levels.push_back();
+ integrals_fir_different_levels.push_back(0.241168);
+ integrals_fir_different_levels.push_back(0.239276);
+ integrals_fir_different_levels.push_back(0.237882);
+ integrals_fir_different_levels.push_back(0.235193);
+ integrals_fir_different_levels.push_back(0.230115);
+ integrals_fir_different_levels.push_back(0.227626);
+ integrals_fir_different_levels.push_back(0.226132);
+ integrals_fir_different_levels.push_back(0.223643);
+ integrals_fir_different_levels.push_back(0.221651);
+ integrals_fir_different_levels.push_back(0.220556);
+ integrals_fir_different_levels.push_back(0.21727);
+ integrals_fir_different_levels.push_back(0.215976);
+ integrals_fir_different_levels.push_back(0.213685);
+ integrals_fir_different_levels.push_back(0.211993);
+ integrals_fir_different_levels.push_back(0.2102);
+ integrals_fir_different_levels.push_back(0.208707);
+ integrals_fir_different_levels.push_back(0.207014);
+ integrals_fir_different_levels.push_back(0.205122);
+ integrals_fir_different_levels.push_back(0.204226);
+ integrals_fir_different_levels.push_back(0.202633);
+
+ for (size_t level = 0; level != integrals_fir_different_levels.size(); ++level) {
+ double integral = p.compute_integral_of_landscape(level);
+ // cerr << integral << endl;
+ BOOST_CHECK(fabs(integral - integrals_fir_different_levels[level]) <= 0.00005);
+ }
+}
+BOOST_AUTO_TEST_CASE(check_computations_of_integrals_of_powers_of_landscape) {
+ Persistence_landscape_on_grid p("data/file_with_diagram_1", 100, std::numeric_limits<unsigned short>::max());
+
+ std::vector<double> integrals_fir_different_powers;
+ integrals_fir_different_powers.push_back(0.241168);
+ integrals_fir_different_powers.push_back(0.239276);
+ integrals_fir_different_powers.push_back(0.237882);
+ integrals_fir_different_powers.push_back(0.235193);
+ integrals_fir_different_powers.push_back(0.23011);
+
+ for (size_t power = 0; power != 5; ++power) {
+ double integral = p.compute_integral_of_landscape(power);
+ // cerr << integral << endl;
+ BOOST_CHECK(fabs(integral - integrals_fir_different_powers[power]) <= 0.00001);
+ }
+}
-BOOST_AUTO_TEST_CASE(check_computations_of_integrals_of_powers_of_landscape)
-{
- Persistence_landscape_on_grid p( "data/file_with_diagram_1" , 100, std::numeric_limits<unsigned short>::max() );
-
- std::vector<double> integrals_fir_different_powers;
- integrals_fir_different_powers.push_back( 0.241168);
- integrals_fir_different_powers.push_back( 0.239276);
- integrals_fir_different_powers.push_back( 0.237882);
- integrals_fir_different_powers.push_back( 0.235193);
- integrals_fir_different_powers.push_back( 0.23011);
-
- for ( size_t power = 0 ; power != 5 ; ++power )
- {
- double integral = p.compute_integral_of_landscape( power );
- //cerr << integral << endl;
- BOOST_CHECK( fabs( integral - integrals_fir_different_powers[power] ) <= 0.00001 );
- }
+BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points) {
+ Persistence_landscape_on_grid p("data/file_with_diagram_1", 100, std::numeric_limits<unsigned short>::max());
+
+ std::vector<double> results_level_0;
+ results_level_0.push_back(0.00997867);
+ results_level_0.push_back(0.0521921);
+ results_level_0.push_back(0.104312);
+ results_level_0.push_back(0.156432);
+ results_level_0.push_back(0.208552);
+ results_level_0.push_back(0.260672);
+ results_level_0.push_back(0.312792);
+ results_level_0.push_back(0.364912);
+ results_level_0.push_back(0.417032);
+ results_level_0.push_back(0.429237);
+
+ std::vector<double> results_level_10;
+ results_level_10.push_back(7.21433e-05);
+ results_level_10.push_back(0.0422135);
+ results_level_10.push_back(0.0943335);
+ results_level_10.push_back(0.146453);
+ results_level_10.push_back(0.198573);
+ results_level_10.push_back(0.240715);
+ results_level_10.push_back(0.272877);
+ results_level_10.push_back(0.324997);
+ results_level_10.push_back(0.359232);
+ results_level_10.push_back(0.379344);
+
+ double x = 0.0012321;
+ double dx = 0.05212;
+ for (size_t i = 0; i != 10; ++i) {
+ BOOST_CHECK(almost_equal(p.compute_value_at_a_given_point(0, x), results_level_0[i]));
+ BOOST_CHECK(almost_equal(p.compute_value_at_a_given_point(10, x), results_level_10[i]));
+ x += dx;
+ }
}
+BOOST_AUTO_TEST_CASE(check_computations_sum_differences_and_multiplications) {
+ Persistence_landscape_on_grid p("data/file_with_diagram_1", 100, std::numeric_limits<unsigned short>::max());
+ Persistence_landscape_on_grid second("data/file_with_diagram_1", 100, std::numeric_limits<unsigned short>::max());
-BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points)
-{
- Persistence_landscape_on_grid p( "data/file_with_diagram_1" , 100, std::numeric_limits<unsigned short>::max() );
-
- std::vector< double > results_level_0;
- results_level_0.push_back(0.00997867);
- results_level_0.push_back(0.0521921);
- results_level_0.push_back(0.104312);
- results_level_0.push_back(0.156432);
- results_level_0.push_back(0.208552);
- results_level_0.push_back(0.260672);
- results_level_0.push_back(0.312792);
- results_level_0.push_back(0.364912);
- results_level_0.push_back(0.417032);
- results_level_0.push_back(0.429237);
-
- std::vector< double > results_level_10;
- results_level_10.push_back(7.21433e-05);
- results_level_10.push_back(0.0422135);
- results_level_10.push_back(0.0943335);
- results_level_10.push_back(0.146453);
- results_level_10.push_back(0.198573);
- results_level_10.push_back(0.240715);
- results_level_10.push_back(0.272877);
- results_level_10.push_back(0.324997);
- results_level_10.push_back(0.359232);
- results_level_10.push_back(0.379344);
-
- double x = 0.0012321;
- double dx = 0.05212;
- for ( size_t i = 0 ; i != 10 ; ++i )
- {
- BOOST_CHECK( almost_equal( p.compute_value_at_a_given_point(0,x) , results_level_0[i] ) );
- BOOST_CHECK( almost_equal( p.compute_value_at_a_given_point(10,x) , results_level_10[i] ) );
- x += dx;
- }
-}
+ Persistence_landscape_on_grid sum = p + second;
+ Persistence_landscape_on_grid difference = p - second;
+ Persistence_landscape_on_grid multiply_by_scalar = 10 * p;
+ ;
+ Persistence_landscape_on_grid template_sum;
+ template_sum.load_landscape_from_file("data/sum_on_grid_test");
-BOOST_AUTO_TEST_CASE(check_computations_sum_differences_and_multiplications)
-{
- Persistence_landscape_on_grid p( "data/file_with_diagram_1" ,100 , std::numeric_limits<unsigned short>::max());
- Persistence_landscape_on_grid second("data/file_with_diagram_1" , 100, std::numeric_limits<unsigned short>::max() );
-
- Persistence_landscape_on_grid sum = p + second;
- Persistence_landscape_on_grid difference = p - second;
- Persistence_landscape_on_grid multiply_by_scalar = 10*p; ;
-
-
- Persistence_landscape_on_grid template_sum;
- template_sum.load_landscape_from_file( "data/sum_on_grid_test" );
-
- Persistence_landscape_on_grid template_difference;
- template_difference.load_landscape_from_file( "data/difference_on_grid_test" );
-
- Persistence_landscape_on_grid template_multiply_by_scalar;
- template_multiply_by_scalar.load_landscape_from_file( "data/multiply_by_scalar_on_grid_test" );
-
- BOOST_CHECK( sum == template_sum );
- BOOST_CHECK( difference == template_difference );
- BOOST_CHECK( multiply_by_scalar == template_multiply_by_scalar );
-}
+ Persistence_landscape_on_grid template_difference;
+ template_difference.load_landscape_from_file("data/difference_on_grid_test");
+ Persistence_landscape_on_grid template_multiply_by_scalar;
+ template_multiply_by_scalar.load_landscape_from_file("data/multiply_by_scalar_on_grid_test");
+ BOOST_CHECK(sum == template_sum);
+ BOOST_CHECK(difference == template_difference);
+ BOOST_CHECK(multiply_by_scalar == template_multiply_by_scalar);
+}
-BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms)
-{
- Persistence_landscape_on_grid p( "data/file_with_diagram_1" , 0. , 1. , 100 );
- Persistence_landscape_on_grid second("data/file_with_diagram_2" , 0. , 1. , 100 );
- Persistence_landscape_on_grid sum = p + second;
-
- //cerr << p.compute_maximum() << endl;
- //cerr << p.compute_norm_of_landscape(1) << endl;
- //cerr << p.compute_norm_of_landscape(2) << endl;
- //cerr << 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,std::numeric_limits<double>::max()) << endl;
-
- BOOST_CHECK( fabs( p.compute_maximum() - 0.46 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_norm_of_landscape(1) - 27.3373 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_norm_of_landscape(2) - 1.84143 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_norm_of_landscape(3) - 0.927067 ) <= 0.00001 );
- BOOST_CHECK( fabs( compute_distance_of_landscapes_on_grid(p,sum,1) - 16.8519 ) <= 0.00005 );
- BOOST_CHECK( fabs( compute_distance_of_landscapes_on_grid(p,sum,2) - 1.44542 ) <= 0.00001 );
- BOOST_CHECK( fabs(compute_distance_of_landscapes_on_grid(p,sum,std::numeric_limits<double>::max()) - 0.45 ) <= 0.00001 );
+BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms) {
+ Persistence_landscape_on_grid p("data/file_with_diagram_1", 0., 1., 100);
+ Persistence_landscape_on_grid second("data/file_with_diagram_2", 0., 1., 100);
+ Persistence_landscape_on_grid sum = p + second;
+
+ // cerr << p.compute_maximum() << endl;
+ // cerr << p.compute_norm_of_landscape(1) << endl;
+ // cerr << p.compute_norm_of_landscape(2) << endl;
+ // cerr << 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,std::numeric_limits<double>::max()) << endl;
+
+ BOOST_CHECK(fabs(p.compute_maximum() - 0.46) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_norm_of_landscape(1) - 27.3373) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_norm_of_landscape(2) - 1.84143) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_norm_of_landscape(3) - 0.927067) <= 0.00001);
+ BOOST_CHECK(fabs(compute_distance_of_landscapes_on_grid(p, sum, 1) - 16.8519) <= 0.00005);
+ BOOST_CHECK(fabs(compute_distance_of_landscapes_on_grid(p, sum, 2) - 1.44542) <= 0.00001);
+ BOOST_CHECK(fabs(compute_distance_of_landscapes_on_grid(p, sum, std::numeric_limits<double>::max()) - 0.45) <=
+ 0.00001);
}
-BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances )
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape_on_grid p( diag , 0. , 1. , 100 );
-
- std::vector< std::pair< double , double > > diag1 = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram_1" );
- Persistence_landscape_on_grid q( diag1 , 0. , 1. , 100 );
-
- double dist_numeric_limit_max = p.distance( q,std::numeric_limits<double>::max() );
- double dist_infinity = p.distance( q,std::numeric_limits<double>::infinity() );
-
- BOOST_CHECK( dist_numeric_limit_max == dist_infinity );
+BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape_on_grid p(diag, 0., 1., 100);
+
+ std::vector<std::pair<double, double> > diag1 =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram_1");
+ Persistence_landscape_on_grid q(diag1, 0., 1., 100);
+
+ double dist_numeric_limit_max = p.distance(q, std::numeric_limits<double>::max());
+ double dist_infinity = p.distance(q, std::numeric_limits<double>::infinity());
+
+ BOOST_CHECK(dist_numeric_limit_max == dist_infinity);
}
+BOOST_AUTO_TEST_CASE(check_computations_of_averages) {
+ Persistence_landscape_on_grid p("data/file_with_diagram", 0., 1., 100);
+ Persistence_landscape_on_grid q("data/file_with_diagram_1", 0., 1., 100);
+ Persistence_landscape_on_grid av;
+ av.compute_average({&p, &q});
+ Persistence_landscape_on_grid template_average;
+ template_average.load_landscape_from_file("data/average_on_a_grid");
+ BOOST_CHECK(template_average == av);
+}
+BOOST_AUTO_TEST_CASE(check_computations_of_distances) {
+ Persistence_landscape_on_grid p("data/file_with_diagram", 0., 1., 10000);
+ Persistence_landscape_on_grid q("data/file_with_diagram_1", 0., 1., 10000);
+ BOOST_CHECK(fabs(p.distance(q) - 25.5779) <= 0.00005);
+ BOOST_CHECK(fabs(p.distance(q, 2) - 2.04891) <= 0.00001);
+ BOOST_CHECK(fabs(p.distance(q, std::numeric_limits<double>::max()) - 0.359) <= 0.00001);
+}
-BOOST_AUTO_TEST_CASE(check_computations_of_averages)
-{
- Persistence_landscape_on_grid p( "data/file_with_diagram", 0.,1.,100 );
- Persistence_landscape_on_grid q( "data/file_with_diagram_1", 0.,1.,100 );
- Persistence_landscape_on_grid av;
- av.compute_average( {&p,&q} );
-
- Persistence_landscape_on_grid template_average;
- template_average.load_landscape_from_file( "data/average_on_a_grid" );
- BOOST_CHECK ( template_average == av );
+BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product) {
+ Persistence_landscape_on_grid p("data/file_with_diagram", 0., 1., 10000);
+ Persistence_landscape_on_grid q("data/file_with_diagram_1", 0., 1., 10000);
+ // std::cerr << p.compute_scalar_product( q ) << std::endl;
+ BOOST_CHECK(almost_equal(p.compute_scalar_product(q), 0.754367));
}
+// 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 );
+ */
-BOOST_AUTO_TEST_CASE(check_computations_of_distances)
+/*
+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 )
{
- Persistence_landscape_on_grid p( "data/file_with_diagram", 0.,1.,10000 );
- Persistence_landscape_on_grid q( "data/file_with_diagram_1", 0.,1.,10000 );
- BOOST_CHECK( fabs( p.distance( q )- 25.5779) <= 0.00005 );
- BOOST_CHECK( fabs( p.distance( q , 2) - 2.04891) <= 0.00001 );
- BOOST_CHECK( fabs( p.distance( q , std::numeric_limits<double>::max() )-0.359 ) <= 0.00001 );
+ double integral = p.compute_integral_of_landscape( level );
+ cerr << integral << endl;
}
-
+*/
-BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product)
+/*
+Persistence_landscape_on_grid p( "file_with_diagram_1" , 100 );
+for ( size_t power = 0 ; power != 5 ; ++power )
{
- Persistence_landscape_on_grid p( "data/file_with_diagram" , 0.,1.,10000);
- Persistence_landscape_on_grid q( "data/file_with_diagram_1", 0.,1.,10000 );
- //std::cerr << p.compute_scalar_product( q ) << std::endl;
- BOOST_CHECK( almost_equal( p.compute_scalar_product( q ) , 0.754367 ) );
+ 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;
+*/
-//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,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 );
-
- //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;
+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/Persistence_representations/test/persistence_lanscapes_test.cpp b/src/Persistence_representations/test/persistence_lanscapes_test.cpp
index c1e24b1c..2bdc6bdb 100644
--- a/src/Persistence_representations/test/persistence_lanscapes_test.cpp
+++ b/src/Persistence_representations/test/persistence_lanscapes_test.cpp
@@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "Persistence_representations"
#include <boost/test/unit_test.hpp>
@@ -31,354 +29,332 @@
#include <iostream>
#include <limits>
-
-
using namespace Gudhi;
using namespace Gudhi::Persistence_representations;
-
double epsilon = 0.0000005;
-
-
-
-BOOST_AUTO_TEST_CASE(check_construction_of_landscape)
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
- Persistence_landscape q;
- q.load_landscape_from_file( "data/file_with_landscape_from_file_with_diagram" );
- BOOST_CHECK( p == q );
+BOOST_AUTO_TEST_CASE(check_construction_of_landscape) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+ Persistence_landscape q;
+ q.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram");
+ BOOST_CHECK(p == q);
}
-
-BOOST_AUTO_TEST_CASE(check_construction_of_landscape_form_gudhi_style_file)
-{
- Persistence_landscape p( "data/persistence_file_with_four_entries_per_line" , 1 );
- //p.print_to_file("persistence_file_with_four_entries_per_line_landscape");
- Persistence_landscape q;
- q.load_landscape_from_file( "data/persistence_file_with_four_entries_per_line_landscape" );
- BOOST_CHECK( p == q );
+BOOST_AUTO_TEST_CASE(check_construction_of_landscape_form_gudhi_style_file) {
+ Persistence_landscape p("data/persistence_file_with_four_entries_per_line", 1);
+ // p.print_to_file("persistence_file_with_four_entries_per_line_landscape");
+ Persistence_landscape q;
+ q.load_landscape_from_file("data/persistence_file_with_four_entries_per_line_landscape");
+ BOOST_CHECK(p == q);
}
-
-BOOST_AUTO_TEST_CASE(check_computations_of_integrals)
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
- double integral = p.compute_integral_of_landscape();
- //cerr << integral << " " << 2.34992 << endl;
- BOOST_CHECK( fabs( integral - 2.34992 ) <= 0.00001 );
+BOOST_AUTO_TEST_CASE(check_computations_of_integrals) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+ double integral = p.compute_integral_of_landscape();
+ // cerr << integral << " " << 2.34992 << endl;
+ BOOST_CHECK(fabs(integral - 2.34992) <= 0.00001);
}
-
-BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly)
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
-
- std::vector< double > integrals_fir_different_levels;
- integrals_fir_different_levels.push_back( 0.216432 );
- integrals_fir_different_levels.push_back( 0.204763 );
- integrals_fir_different_levels.push_back( 0.188793 );
- integrals_fir_different_levels.push_back( 0.178856 );
- integrals_fir_different_levels.push_back( 0.163142 );
- integrals_fir_different_levels.push_back( 0.155015 );
- integrals_fir_different_levels.push_back( 0.143046 );
- integrals_fir_different_levels.push_back( 0.133765 );
- integrals_fir_different_levels.push_back( 0.123531 );
- integrals_fir_different_levels.push_back( 0.117393 );
- integrals_fir_different_levels.push_back( 0.111269 );
- integrals_fir_different_levels.push_back( 0.104283 );
- integrals_fir_different_levels.push_back( 0.0941308 );
- integrals_fir_different_levels.push_back( 0.0811208 );
- integrals_fir_different_levels.push_back( 0.0679001 );
- integrals_fir_different_levels.push_back( 0.0580801 );
- integrals_fir_different_levels.push_back( 0.0489647 );
- integrals_fir_different_levels.push_back( 0.0407936 );
- integrals_fir_different_levels.push_back( 0.0342599 );
- integrals_fir_different_levels.push_back( 0.02896 );
- integrals_fir_different_levels.push_back( 0.0239881 );
- integrals_fir_different_levels.push_back( 0.0171792 );
- integrals_fir_different_levels.push_back( 0.0071511 );
- integrals_fir_different_levels.push_back( 0.00462067 );
- integrals_fir_different_levels.push_back( 0.00229033 );
- integrals_fir_different_levels.push_back( 0.000195296 );
-
-
-
-
- for ( size_t level = 0 ; level != p.size() ; ++level )
- {
- double integral = p.compute_integral_of_a_level_of_a_landscape( level );
- BOOST_CHECK( fabs( integral - integrals_fir_different_levels[level] ) <= 0.00001 );
- }
-
+BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+
+ std::vector<double> integrals_fir_different_levels;
+ integrals_fir_different_levels.push_back(0.216432);
+ integrals_fir_different_levels.push_back(0.204763);
+ integrals_fir_different_levels.push_back(0.188793);
+ integrals_fir_different_levels.push_back(0.178856);
+ integrals_fir_different_levels.push_back(0.163142);
+ integrals_fir_different_levels.push_back(0.155015);
+ integrals_fir_different_levels.push_back(0.143046);
+ integrals_fir_different_levels.push_back(0.133765);
+ integrals_fir_different_levels.push_back(0.123531);
+ integrals_fir_different_levels.push_back(0.117393);
+ integrals_fir_different_levels.push_back(0.111269);
+ integrals_fir_different_levels.push_back(0.104283);
+ integrals_fir_different_levels.push_back(0.0941308);
+ integrals_fir_different_levels.push_back(0.0811208);
+ integrals_fir_different_levels.push_back(0.0679001);
+ integrals_fir_different_levels.push_back(0.0580801);
+ integrals_fir_different_levels.push_back(0.0489647);
+ integrals_fir_different_levels.push_back(0.0407936);
+ integrals_fir_different_levels.push_back(0.0342599);
+ integrals_fir_different_levels.push_back(0.02896);
+ integrals_fir_different_levels.push_back(0.0239881);
+ integrals_fir_different_levels.push_back(0.0171792);
+ integrals_fir_different_levels.push_back(0.0071511);
+ integrals_fir_different_levels.push_back(0.00462067);
+ integrals_fir_different_levels.push_back(0.00229033);
+ integrals_fir_different_levels.push_back(0.000195296);
+
+ for (size_t level = 0; level != p.size(); ++level) {
+ double integral = p.compute_integral_of_a_level_of_a_landscape(level);
+ BOOST_CHECK(fabs(integral - integrals_fir_different_levels[level]) <= 0.00001);
+ }
}
-BOOST_AUTO_TEST_CASE(check_computations_of_integrals_of_powers_of_landscape)
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
-
- std::vector<double> integrals_fir_different_powers;
- integrals_fir_different_powers.push_back( 17.1692 );
- integrals_fir_different_powers.push_back( 2.34992 );
- integrals_fir_different_powers.push_back( 0.49857 );
- integrals_fir_different_powers.push_back( 0.126405 );
- integrals_fir_different_powers.push_back( 0.0355235 );
-
- for ( size_t power = 0 ; power != 5 ; ++power )
- {
- double integral = p.compute_integral_of_landscape( (double)power );
- BOOST_CHECK( fabs( integral - integrals_fir_different_powers[power] ) <= 0.00005 );
- }
+BOOST_AUTO_TEST_CASE(check_computations_of_integrals_of_powers_of_landscape) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+
+ std::vector<double> integrals_fir_different_powers;
+ integrals_fir_different_powers.push_back(17.1692);
+ integrals_fir_different_powers.push_back(2.34992);
+ integrals_fir_different_powers.push_back(0.49857);
+ integrals_fir_different_powers.push_back(0.126405);
+ integrals_fir_different_powers.push_back(0.0355235);
+
+ for (size_t power = 0; power != 5; ++power) {
+ double integral = p.compute_integral_of_landscape((double)power);
+ BOOST_CHECK(fabs(integral - integrals_fir_different_powers[power]) <= 0.00005);
+ }
}
-BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points)
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
-
-
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(1,0.0) ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(1,0.1) - 0.0692324 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(1,0.2) - 0.163369 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(1,0.3) - 0.217115 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(2,0.0) ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(2,0.1) - 0.0633688 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(2,0.2) - 0.122361 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(2,0.3) - 0.195401 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(3,0.0) ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(3,0.1) - 0.0455386 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(3,0.2) - 0.0954012 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_value_at_a_given_point(3,0.3) - 0.185282 ) <= 0.00001 );
+BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(1, 0.0)) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(1, 0.1) - 0.0692324) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(1, 0.2) - 0.163369) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(1, 0.3) - 0.217115) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(2, 0.0)) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(2, 0.1) - 0.0633688) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(2, 0.2) - 0.122361) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(2, 0.3) - 0.195401) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(3, 0.0)) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(3, 0.1) - 0.0455386) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(3, 0.2) - 0.0954012) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_value_at_a_given_point(3, 0.3) - 0.185282) <= 0.00001);
}
+BOOST_AUTO_TEST_CASE(check_computations_sum_differences_and_multiplications) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+ Persistence_landscape second;
+ second.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram_1");
-BOOST_AUTO_TEST_CASE(check_computations_sum_differences_and_multiplications)
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
- Persistence_landscape second;
- second.load_landscape_from_file("data/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;
-
-
- Persistence_landscape template_sum;
- template_sum.load_landscape_from_file( "data/sum" );
-
- Persistence_landscape template_difference;
- template_difference.load_landscape_from_file( "data/difference" );
-
- Persistence_landscape template_multiply_by_scalar;
- template_multiply_by_scalar.load_landscape_from_file( "data/multiply_by_scalar" );
-
- BOOST_CHECK( sum == template_sum );
- BOOST_CHECK( difference == template_difference );
- BOOST_CHECK( multiply_by_scalar == template_multiply_by_scalar );
-}
-
+ Persistence_landscape sum = p + second;
+ Persistence_landscape difference = p - second;
+ Persistence_landscape multiply_by_scalar = 10 * p;
+ Persistence_landscape template_sum;
+ template_sum.load_landscape_from_file("data/sum");
-BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms)
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
- Persistence_landscape second;
- second.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram_1" );
- Persistence_landscape sum = p + second;
-
- BOOST_CHECK( fabs( p.compute_maximum() - 0.431313 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_norm_of_landscape(1) - 2.34992 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_norm_of_landscape(2) - 0.706095 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.compute_norm_of_landscape(3) - 0.501867 ) <= 0.00001 );
- BOOST_CHECK( fabs( compute_distance_of_landscapes(p,sum,1) - 27.9323 ) <= 0.00005 );
- BOOST_CHECK( fabs( compute_distance_of_landscapes(p,sum,2) - 2.35199 ) <= 0.00001 );
- BOOST_CHECK( fabs(compute_distance_of_landscapes( p , sum , std::numeric_limits<double>::max() ) - 0.464478 ) <= 0.00001 );
-}
+ Persistence_landscape template_difference;
+ template_difference.load_landscape_from_file("data/difference");
+ Persistence_landscape template_multiply_by_scalar;
+ template_multiply_by_scalar.load_landscape_from_file("data/multiply_by_scalar");
-BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances )
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
-
- std::vector< std::pair< double , double > > diag1 = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram_1" );
- Persistence_landscape q( diag1 );
-
- double dist_numeric_limit_max = p.distance( q,std::numeric_limits<double>::max() );
- double dist_infinity = p.distance( q,std::numeric_limits<double>::infinity() );
-
- BOOST_CHECK( dist_numeric_limit_max == dist_infinity );
+ BOOST_CHECK(sum == template_sum);
+ BOOST_CHECK(difference == template_difference);
+ BOOST_CHECK(multiply_by_scalar == template_multiply_by_scalar);
}
-BOOST_AUTO_TEST_CASE(check_computations_of_averages)
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
- std::vector< std::pair< double , double > > diag2 = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram_1" );
- Persistence_landscape q( diag2 );
- Persistence_landscape av;
- av.compute_average( {&p,&q} );
-
- Persistence_landscape template_average;
- template_average.load_landscape_from_file( "data/average" );
- BOOST_CHECK ( template_average == av );
+BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+ Persistence_landscape second;
+ second.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram_1");
+ Persistence_landscape sum = p + second;
+
+ BOOST_CHECK(fabs(p.compute_maximum() - 0.431313) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_norm_of_landscape(1) - 2.34992) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_norm_of_landscape(2) - 0.706095) <= 0.00001);
+ BOOST_CHECK(fabs(p.compute_norm_of_landscape(3) - 0.501867) <= 0.00001);
+ BOOST_CHECK(fabs(compute_distance_of_landscapes(p, sum, 1) - 27.9323) <= 0.00005);
+ BOOST_CHECK(fabs(compute_distance_of_landscapes(p, sum, 2) - 2.35199) <= 0.00001);
+ BOOST_CHECK(fabs(compute_distance_of_landscapes(p, sum, std::numeric_limits<double>::max()) - 0.464478) <= 0.00001);
}
+BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+ std::vector<std::pair<double, double> > diag1 =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram_1");
+ Persistence_landscape q(diag1);
+ double dist_numeric_limit_max = p.distance(q, std::numeric_limits<double>::max());
+ double dist_infinity = p.distance(q, std::numeric_limits<double>::infinity());
-BOOST_AUTO_TEST_CASE(check_computations_of_distances)
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
- std::vector< std::pair< double , double > > diag2 = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram_1" );
- Persistence_landscape q( diag2 );
- BOOST_CHECK( fabs( p.distance( q )- 25.5824) <= 0.00005 );
- BOOST_CHECK( fabs( p.distance( q , 2) - 2.12636 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.distance( q , std::numeric_limits<double>::max() )-0.359068 ) <= 0.00001 );
- std::cerr << "p.distance( q , std::numeric_limits<double>::max() ) : " << p.distance( q , std::numeric_limits<double>::max() ) << std::endl;
+ BOOST_CHECK(dist_numeric_limit_max == dist_infinity);
}
-
-
-BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product)
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Persistence_landscape p( diag );
- std::vector< std::pair< double , double > > diag2 = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram_1" );
- Persistence_landscape q( diag2 );
- BOOST_CHECK( fabs( p.compute_scalar_product( q ) - 0.754498 ) <= 0.00001 );
+
+BOOST_AUTO_TEST_CASE(check_computations_of_averages) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+ std::vector<std::pair<double, double> > diag2 =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram_1");
+ Persistence_landscape q(diag2);
+ Persistence_landscape av;
+ av.compute_average({&p, &q});
+
+ Persistence_landscape template_average;
+ template_average.load_landscape_from_file("data/average");
+ BOOST_CHECK(template_average == av);
}
+BOOST_AUTO_TEST_CASE(check_computations_of_distances) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+ std::vector<std::pair<double, double> > diag2 =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram_1");
+ Persistence_landscape q(diag2);
+ BOOST_CHECK(fabs(p.distance(q) - 25.5824) <= 0.00005);
+ BOOST_CHECK(fabs(p.distance(q, 2) - 2.12636) <= 0.00001);
+ BOOST_CHECK(fabs(p.distance(q, std::numeric_limits<double>::max()) - 0.359068) <= 0.00001);
+ std::cerr << "p.distance( q , std::numeric_limits<double>::max() ) : "
+ << p.distance(q, std::numeric_limits<double>::max()) << std::endl;
+}
+BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Persistence_landscape p(diag);
+ std::vector<std::pair<double, double> > diag2 =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram_1");
+ Persistence_landscape q(diag2);
+ 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.
+// 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;
- }
-*/
+ {
+ 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/Persistence_representations/test/read_persistence_from_file_test.cpp b/src/Persistence_representations/test/read_persistence_from_file_test.cpp
index 69493efb..924a67a1 100644
--- a/src/Persistence_representations/test/read_persistence_from_file_test.cpp
+++ b/src/Persistence_representations/test/read_persistence_from_file_test.cpp
@@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "Persistence_representations"
#include <boost/test/unit_test.hpp>
@@ -30,86 +28,71 @@
#include <iostream>
-
-
using namespace Gudhi;
using namespace Gudhi::Persistence_representations;
+BOOST_AUTO_TEST_CASE(test_read_file_with_four_elements_per_line) {
+ std::vector<std::pair<double, double> > what_we_should_get;
+ what_we_should_get.push_back(std::make_pair(0, 2));
+ what_we_should_get.push_back(std::make_pair(10, 1000));
+ what_we_should_get.push_back(std::make_pair(10, 90));
+ what_we_should_get.push_back(std::make_pair(4, 4));
+ std::vector<std::pair<double, double> > what_we_get = read_persistence_intervals_in_one_dimension_from_file(
+ "data/persistence_file_with_four_entries_per_line", 1, 1000);
+
+ // for ( size_t i = 0 ; i != what_we_get.size() ; ++i )
+ //{
+ // std::cerr << what_we_get[i].first << " , " << what_we_get[i].second << std::endl;
+ //}
+
+ BOOST_CHECK(what_we_should_get.size() == what_we_get.size());
+
+ for (size_t i = 0; i != what_we_get.size(); ++i) {
+ BOOST_CHECK(what_we_should_get[i] == what_we_get[i]);
+ }
+}
+BOOST_AUTO_TEST_CASE(test_read_file_with_three_elements_per_line) {
+ std::vector<std::pair<double, double> > what_we_should_get;
+ what_we_should_get.push_back(std::make_pair(4, 9999));
+ what_we_should_get.push_back(std::make_pair(0, 1));
+ what_we_should_get.push_back(std::make_pair(1, 9999));
+ what_we_should_get.push_back(std::make_pair(10, 90));
+ what_we_should_get.push_back(std::make_pair(4, 4));
-
-
-BOOST_AUTO_TEST_CASE(test_read_file_with_four_elements_per_line)
-{
- std::vector< std::pair< double,double > > what_we_should_get;
- what_we_should_get.push_back( std::make_pair( 0 , 2 ) );
- what_we_should_get.push_back( std::make_pair( 10 , 1000 ) );
- what_we_should_get.push_back( std::make_pair( 10 , 90 ) );
- what_we_should_get.push_back( std::make_pair( 4 , 4 ) );
- std::vector<std::pair<double,double> > what_we_get = read_persistence_intervals_in_one_dimension_from_file("data/persistence_file_with_four_entries_per_line" , 1 , 1000 );
-
-
- //for ( size_t i = 0 ; i != what_we_get.size() ; ++i )
- //{
- // std::cerr << what_we_get[i].first << " , " << what_we_get[i].second << std::endl;
- //}
-
- BOOST_CHECK( what_we_should_get.size() == what_we_get.size() );
-
- for ( size_t i = 0 ; i != what_we_get.size() ; ++i )
- {
- BOOST_CHECK( what_we_should_get[i] == what_we_get[i] );
- }
-}
+ std::vector<std::pair<double, double> > what_we_get = read_persistence_intervals_in_one_dimension_from_file(
+ "data/persistence_file_with_three_entries_per_line", 1, 9999);
+ // for ( size_t i = 0 ; i != what_we_get.size() ; ++i )
+ //{
+ // std::cerr << what_we_get[i].first << " , " << what_we_get[i].second << std::endl;
+ //}
-BOOST_AUTO_TEST_CASE(test_read_file_with_three_elements_per_line)
-{
- std::vector< std::pair< double,double > > what_we_should_get;
- what_we_should_get.push_back( std::make_pair( 4 , 9999 ) );
- what_we_should_get.push_back( std::make_pair( 0 , 1 ) );
- what_we_should_get.push_back( std::make_pair( 1 , 9999 ) );
- what_we_should_get.push_back( std::make_pair( 10 , 90 ) );
- what_we_should_get.push_back( std::make_pair( 4 , 4 ) );
-
- std::vector<std::pair<double,double> > what_we_get = read_persistence_intervals_in_one_dimension_from_file("data/persistence_file_with_three_entries_per_line" , 1 , 9999 );
-
-
- //for ( size_t i = 0 ; i != what_we_get.size() ; ++i )
- //{
- // std::cerr << what_we_get[i].first << " , " << what_we_get[i].second << std::endl;
- //}
-
- BOOST_CHECK( what_we_should_get.size() == what_we_get.size() );
-
- for ( size_t i = 0 ; i != what_we_get.size() ; ++i )
- {
- BOOST_CHECK( what_we_should_get[i] == what_we_get[i] );
- }
+ BOOST_CHECK(what_we_should_get.size() == what_we_get.size());
+
+ for (size_t i = 0; i != what_we_get.size(); ++i) {
+ BOOST_CHECK(what_we_should_get[i] == what_we_get[i]);
+ }
}
+BOOST_AUTO_TEST_CASE(test_read_file_with_two_elements_per_line) {
+ std::vector<std::pair<double, double> > what_we_should_get;
+ what_we_should_get.push_back(std::make_pair(4, 10));
+ what_we_should_get.push_back(std::make_pair(4, 9999));
+ what_we_should_get.push_back(std::make_pair(0, 1));
+ what_we_should_get.push_back(std::make_pair(1, 4));
-BOOST_AUTO_TEST_CASE(test_read_file_with_two_elements_per_line)
-{
- std::vector< std::pair< double,double > > what_we_should_get;
- what_we_should_get.push_back( std::make_pair( 4 , 10 ) );
- what_we_should_get.push_back( std::make_pair( 4 , 9999 ) );
- what_we_should_get.push_back( std::make_pair( 0 , 1 ) );
- what_we_should_get.push_back( std::make_pair( 1 , 4 ) );
-
- std::vector<std::pair<double,double> > what_we_get = read_persistence_intervals_in_one_dimension_from_file("data/persistence_file_with_two_entries_per_line" , 1 , 9999 );
-
-
- //for ( size_t i = 0 ; i != what_we_get.size() ; ++i )
- //{
- // std::cerr << what_we_get[i].first << " , " << what_we_get[i].second << std::endl;
- //}
-
- BOOST_CHECK( what_we_should_get.size() == what_we_get.size() );
-
- for ( size_t i = 0 ; i != what_we_get.size() ; ++i )
- {
- BOOST_CHECK( what_we_should_get[i] == what_we_get[i] );
- }
-}
+ std::vector<std::pair<double, double> > what_we_get =
+ read_persistence_intervals_in_one_dimension_from_file("data/persistence_file_with_two_entries_per_line", 1, 9999);
+
+ // for ( size_t i = 0 ; i != what_we_get.size() ; ++i )
+ //{
+ // std::cerr << what_we_get[i].first << " , " << what_we_get[i].second << std::endl;
+ //}
+ BOOST_CHECK(what_we_should_get.size() == what_we_get.size());
+
+ for (size_t i = 0; i != what_we_get.size(); ++i) {
+ BOOST_CHECK(what_we_should_get[i] == what_we_get[i]);
+ }
+}
diff --git a/src/Persistence_representations/test/vector_representation_test.cpp b/src/Persistence_representations/test/vector_representation_test.cpp
index 5e185445..d541d3e1 100644
--- a/src/Persistence_representations/test/vector_representation_test.cpp
+++ b/src/Persistence_representations/test/vector_representation_test.cpp
@@ -20,7 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#include <gudhi/Persistence_vectors.h>
#include <gudhi/common_persistence_representations.h>
#include <iostream>
@@ -33,381 +32,351 @@
#include <cmath>
#include <iomanip>
-
using namespace Gudhi;
using namespace Gudhi::Persistence_representations;
+BOOST_AUTO_TEST_CASE(check_read_write_to_files) {
+ std::vector<std::pair<double, double> > intervals;
+ intervals.push_back(std::make_pair(2, 3));
+ intervals.push_back(std::make_pair(4, 7));
+ intervals.push_back(std::make_pair(9, 10));
+ intervals.push_back(std::make_pair(3, 11));
+ Vector_distances_in_diagram<Euclidean_distance> p(intervals, -1);
+ p.write_to_file("test_vector_representation_write_read");
+ Vector_distances_in_diagram<Euclidean_distance> q;
+ q.load_from_file("test_vector_representation_write_read");
-
-
-
-
-BOOST_AUTO_TEST_CASE(check_read_write_to_files)
-{
- std::vector< std::pair<double,double> > intervals;
- intervals.push_back( std::make_pair(2,3) );
- intervals.push_back( std::make_pair(4,7) );
- intervals.push_back( std::make_pair(9,10) );
- intervals.push_back( std::make_pair(3,11) );
- Vector_distances_in_diagram< Euclidean_distance > p( intervals , -1 );
- p.write_to_file( "test_vector_representation_write_read" );
-
- Vector_distances_in_diagram< Euclidean_distance > q;
- q.load_from_file( "test_vector_representation_write_read" );
-
- BOOST_CHECK( p == q );
-
+ BOOST_CHECK(p == q);
}
+BOOST_AUTO_TEST_CASE(check_sortev_vector_distances_template) {
+ Vector_distances_in_diagram<Euclidean_distance> p("data/file_with_diagram", 100);
+ std::vector<double> sortev_vector_distances_template;
+
+ sortev_vector_distances_template.push_back(0.609968);
+ sortev_vector_distances_template.push_back(0.566317);
+ sortev_vector_distances_template.push_back(0.538858);
+ sortev_vector_distances_template.push_back(0.534927);
+ sortev_vector_distances_template.push_back(0.515741);
+ sortev_vector_distances_template.push_back(0.507828);
+ sortev_vector_distances_template.push_back(0.500911);
+ sortev_vector_distances_template.push_back(0.496986);
+ sortev_vector_distances_template.push_back(0.495306);
+ sortev_vector_distances_template.push_back(0.439945);
+ sortev_vector_distances_template.push_back(0.424097);
+ sortev_vector_distances_template.push_back(0.413891);
+ sortev_vector_distances_template.push_back(0.413891);
+ sortev_vector_distances_template.push_back(0.413891);
+ sortev_vector_distances_template.push_back(0.412621);
+ sortev_vector_distances_template.push_back(0.410613);
+ sortev_vector_distances_template.push_back(0.407853);
+ sortev_vector_distances_template.push_back(0.407853);
+ sortev_vector_distances_template.push_back(0.402306);
+ sortev_vector_distances_template.push_back(0.401937);
+ sortev_vector_distances_template.push_back(0.377605);
+ sortev_vector_distances_template.push_back(0.363859);
+ sortev_vector_distances_template.push_back(0.357765);
+ sortev_vector_distances_template.push_back(0.357765);
+ sortev_vector_distances_template.push_back(0.357765);
+ sortev_vector_distances_template.push_back(0.357765);
+ sortev_vector_distances_template.push_back(0.357765);
+ sortev_vector_distances_template.push_back(0.353401);
+ sortev_vector_distances_template.push_back(0.348004);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.345124);
+ sortev_vector_distances_template.push_back(0.34469);
+ sortev_vector_distances_template.push_back(0.339466);
+ sortev_vector_distances_template.push_back(0.33935);
+ sortev_vector_distances_template.push_back(0.32834);
+ sortev_vector_distances_template.push_back(0.327276);
+ sortev_vector_distances_template.push_back(0.318626);
+ sortev_vector_distances_template.push_back(0.318082);
+ sortev_vector_distances_template.push_back(0.30603);
+ sortev_vector_distances_template.push_back(0.30525);
+ sortev_vector_distances_template.push_back(0.297308);
+ sortev_vector_distances_template.push_back(0.296333);
+ sortev_vector_distances_template.push_back(0.296333);
+ sortev_vector_distances_template.push_back(0.296333);
+ sortev_vector_distances_template.push_back(0.296333);
+ sortev_vector_distances_template.push_back(0.293372);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.292666);
+ sortev_vector_distances_template.push_back(0.29029);
+ sortev_vector_distances_template.push_back(0.290218);
+ sortev_vector_distances_template.push_back(0.289782);
+ sortev_vector_distances_template.push_back(0.288128);
+ sortev_vector_distances_template.push_back(0.286416);
+ sortev_vector_distances_template.push_back(0.285969);
+ sortev_vector_distances_template.push_back(0.282046);
+ sortev_vector_distances_template.push_back(0.28154);
+ sortev_vector_distances_template.push_back(0.281085);
+ sortev_vector_distances_template.push_back(0.280227);
+ sortev_vector_distances_template.push_back(0.279273);
+ sortev_vector_distances_template.push_back(0.278936);
+ sortev_vector_distances_template.push_back(0.278706);
+ sortev_vector_distances_template.push_back(0.278507);
+ sortev_vector_distances_template.push_back(0.278097);
+ sortev_vector_distances_template.push_back(0.276293);
+ sortev_vector_distances_template.push_back(0.276293);
+ sortev_vector_distances_template.push_back(0.276293);
+ sortev_vector_distances_template.push_back(0.276293);
+ sortev_vector_distances_template.push_back(0.276293);
+ sortev_vector_distances_template.push_back(0.276293);
+ sortev_vector_distances_template.push_back(0.276293);
+ sortev_vector_distances_template.push_back(0.276293);
+ sortev_vector_distances_template.push_back(0.276293);
+ sortev_vector_distances_template.push_back(0.276169);
+ sortev_vector_distances_template.push_back(0.270563);
+ sortev_vector_distances_template.push_back(0.264009);
+
+ size_t proj_no = p.number_of_vectorize_functions();
+ std::vector<double> aa = p.vectorize(proj_no);
+
+ for (size_t i = 0; i != aa.size(); ++i) {
+ BOOST_CHECK(almost_equal(sortev_vector_distances_template[i], aa[i]));
+ }
+}
-BOOST_AUTO_TEST_CASE(check_sortev_vector_distances_template)
-{
- Vector_distances_in_diagram< Euclidean_distance > p( "data/file_with_diagram" , 100 );
- std::vector< double > sortev_vector_distances_template;
-
- sortev_vector_distances_template.push_back( 0.609968 );
- sortev_vector_distances_template.push_back( 0.566317 );
- sortev_vector_distances_template.push_back( 0.538858 );
- sortev_vector_distances_template.push_back( 0.534927 );
- sortev_vector_distances_template.push_back( 0.515741 );
- sortev_vector_distances_template.push_back( 0.507828 );
- sortev_vector_distances_template.push_back( 0.500911 );
- sortev_vector_distances_template.push_back( 0.496986 );
- sortev_vector_distances_template.push_back( 0.495306 );
- sortev_vector_distances_template.push_back( 0.439945 );
- sortev_vector_distances_template.push_back( 0.424097 );
- sortev_vector_distances_template.push_back( 0.413891 );
- sortev_vector_distances_template.push_back( 0.413891 );
- sortev_vector_distances_template.push_back( 0.413891 );
- sortev_vector_distances_template.push_back( 0.412621 );
- sortev_vector_distances_template.push_back( 0.410613 );
- sortev_vector_distances_template.push_back( 0.407853 );
- sortev_vector_distances_template.push_back( 0.407853 );
- sortev_vector_distances_template.push_back( 0.402306 );
- sortev_vector_distances_template.push_back( 0.401937 );
- sortev_vector_distances_template.push_back( 0.377605 );
- sortev_vector_distances_template.push_back( 0.363859 );
- sortev_vector_distances_template.push_back( 0.357765 );
- sortev_vector_distances_template.push_back( 0.357765 );
- sortev_vector_distances_template.push_back( 0.357765 );
- sortev_vector_distances_template.push_back( 0.357765 );
- sortev_vector_distances_template.push_back( 0.357765 );
- sortev_vector_distances_template.push_back( 0.353401 );
- sortev_vector_distances_template.push_back( 0.348004 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.345124 );
- sortev_vector_distances_template.push_back( 0.34469 );
- sortev_vector_distances_template.push_back( 0.339466 );
- sortev_vector_distances_template.push_back( 0.33935 );
- sortev_vector_distances_template.push_back( 0.32834 );
- sortev_vector_distances_template.push_back( 0.327276 );
- sortev_vector_distances_template.push_back( 0.318626 );
- sortev_vector_distances_template.push_back( 0.318082 );
- sortev_vector_distances_template.push_back( 0.30603 );
- sortev_vector_distances_template.push_back( 0.30525 );
- sortev_vector_distances_template.push_back( 0.297308 );
- sortev_vector_distances_template.push_back( 0.296333 );
- sortev_vector_distances_template.push_back( 0.296333 );
- sortev_vector_distances_template.push_back( 0.296333 );
- sortev_vector_distances_template.push_back( 0.296333 );
- sortev_vector_distances_template.push_back( 0.293372 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.292666 );
- sortev_vector_distances_template.push_back( 0.29029 );
- sortev_vector_distances_template.push_back( 0.290218 );
- sortev_vector_distances_template.push_back( 0.289782 );
- sortev_vector_distances_template.push_back( 0.288128 );
- sortev_vector_distances_template.push_back( 0.286416 );
- sortev_vector_distances_template.push_back( 0.285969 );
- sortev_vector_distances_template.push_back( 0.282046 );
- sortev_vector_distances_template.push_back( 0.28154 );
- sortev_vector_distances_template.push_back( 0.281085 );
- sortev_vector_distances_template.push_back( 0.280227 );
- sortev_vector_distances_template.push_back( 0.279273 );
- sortev_vector_distances_template.push_back( 0.278936 );
- sortev_vector_distances_template.push_back( 0.278706 );
- sortev_vector_distances_template.push_back( 0.278507 );
- sortev_vector_distances_template.push_back( 0.278097 );
- sortev_vector_distances_template.push_back( 0.276293 );
- sortev_vector_distances_template.push_back( 0.276293 );
- sortev_vector_distances_template.push_back( 0.276293 );
- sortev_vector_distances_template.push_back( 0.276293 );
- sortev_vector_distances_template.push_back( 0.276293 );
- sortev_vector_distances_template.push_back( 0.276293 );
- sortev_vector_distances_template.push_back( 0.276293 );
- sortev_vector_distances_template.push_back( 0.276293 );
- sortev_vector_distances_template.push_back( 0.276293 );
- sortev_vector_distances_template.push_back( 0.276169 );
- sortev_vector_distances_template.push_back( 0.270563 );
- sortev_vector_distances_template.push_back( 0.264009 );
-
-
-
- size_t proj_no = p.number_of_vectorize_functions();
- std::vector< double > aa = p.vectorize(proj_no);
-
- for ( size_t i = 0 ; i != aa.size() ; ++i )
- {
- BOOST_CHECK( almost_equal( sortev_vector_distances_template[i] , aa[i] ) );
- }
-}
-
-
-
-
-BOOST_AUTO_TEST_CASE(check_projections_to_R)
-{
- Vector_distances_in_diagram< Euclidean_distance > p( "data/file_with_diagram" , 100 );
- std::vector< double > proj;
- proj.push_back( 0 );
- proj.push_back( 0.6099679993 );
- proj.push_back( 1.176284775 );
- proj.push_back( 1.715142954 );
- proj.push_back( 2.25006986 );
- proj.push_back( 2.765810506 );
- proj.push_back( 3.273638431 );
- proj.push_back( 3.774549309 );
- proj.push_back( 4.271535042 );
- proj.push_back( 4.766840875 );
- proj.push_back( 5.206786149 );
- proj.push_back( 5.63088295 );
- proj.push_back( 6.04477433 );
- proj.push_back( 6.45866571 );
- proj.push_back( 6.87255709 );
- proj.push_back( 7.285177939 );
- proj.push_back( 7.695791381 );
- proj.push_back( 8.103643945 );
- proj.push_back( 8.511496508 );
- proj.push_back( 8.913802775 );
- proj.push_back( 9.315740229 );
- proj.push_back( 9.693344927 );
- proj.push_back( 10.0572035 );
- proj.push_back( 10.41496899 );
- proj.push_back( 10.77273448 );
- proj.push_back( 11.13049996 );
- proj.push_back( 11.48826545 );
- proj.push_back( 11.84603094 );
- proj.push_back( 12.19943233 );
- proj.push_back( 12.5474364 );
- proj.push_back( 12.89256042 );
- proj.push_back( 13.23768444 );
- proj.push_back( 13.58280846 );
- proj.push_back( 13.92793248 );
- proj.push_back( 14.2730565 );
- proj.push_back( 14.61818051 );
- proj.push_back( 14.96330453 );
- proj.push_back( 15.30842855 );
- proj.push_back( 15.65355257 );
- proj.push_back( 15.99867659 );
- proj.push_back( 16.34380061 );
- proj.push_back( 16.68892462 );
- proj.push_back( 17.03404864 );
- proj.push_back( 17.37917266 );
- proj.push_back( 17.7238622 );
- proj.push_back( 18.06332781 );
- proj.push_back( 18.40267754 );
- proj.push_back( 18.73101759 );
- proj.push_back( 19.05829313 );
- proj.push_back( 19.3769189 );
- proj.push_back( 19.69500045 );
- proj.push_back( 20.0010306 );
- proj.push_back( 20.30628026 );
- proj.push_back( 20.60358868 );
- proj.push_back( 20.89992192 );
- proj.push_back( 21.19625516 );
- proj.push_back( 21.4925884 );
- proj.push_back( 21.78892164 );
- proj.push_back( 22.08229394 );
- proj.push_back( 22.37495987 );
- proj.push_back( 22.66762581 );
- proj.push_back( 22.96029174 );
- proj.push_back( 23.25295768 );
- proj.push_back( 23.54562361 );
- proj.push_back( 23.83828955 );
- proj.push_back( 24.13095549 );
- proj.push_back( 24.42362142 );
- proj.push_back( 24.71628736 );
- proj.push_back( 25.00895329 );
- proj.push_back( 25.30161923 );
- proj.push_back( 25.59428516 );
- proj.push_back( 25.8869511 );
- proj.push_back( 26.17961703 );
- proj.push_back( 26.47228297 );
- proj.push_back( 26.76257262 );
- proj.push_back( 27.05279049 );
- proj.push_back( 27.34257265 );
- proj.push_back( 27.63070097 );
- proj.push_back( 27.91711687 );
- proj.push_back( 28.20308566 );
- proj.push_back( 28.48513176 );
- proj.push_back( 28.76667161 );
- proj.push_back( 29.04775635 );
- proj.push_back( 29.32798359 );
- proj.push_back( 29.60725702 );
- proj.push_back( 29.88619335 );
- proj.push_back( 30.16489915 );
- proj.push_back( 30.44340655 );
- proj.push_back( 30.72150329 );
- proj.push_back( 30.99779604 );
- proj.push_back( 31.27408878 );
- proj.push_back( 31.55038153 );
- proj.push_back( 31.82667427 );
- proj.push_back( 32.10296702 );
- proj.push_back( 32.37925976 );
- proj.push_back( 32.6555525 );
- proj.push_back( 32.93184525 );
- proj.push_back( 33.20813799 );
- proj.push_back( 33.48430662 );
- proj.push_back( 33.7548692 );
-
- for ( size_t proj_no = 0 ; proj_no != p.number_of_projections_to_R() ; ++proj_no )
- {
- //cout << std::setprecision(10) << p.project_to_R(proj_no) << endl;
- BOOST_CHECK( almost_equal( p.project_to_R(proj_no) , proj[proj_no] ) );
- }
+BOOST_AUTO_TEST_CASE(check_projections_to_R) {
+ Vector_distances_in_diagram<Euclidean_distance> p("data/file_with_diagram", 100);
+ std::vector<double> proj;
+ proj.push_back(0);
+ proj.push_back(0.6099679993);
+ proj.push_back(1.176284775);
+ proj.push_back(1.715142954);
+ proj.push_back(2.25006986);
+ proj.push_back(2.765810506);
+ proj.push_back(3.273638431);
+ proj.push_back(3.774549309);
+ proj.push_back(4.271535042);
+ proj.push_back(4.766840875);
+ proj.push_back(5.206786149);
+ proj.push_back(5.63088295);
+ proj.push_back(6.04477433);
+ proj.push_back(6.45866571);
+ proj.push_back(6.87255709);
+ proj.push_back(7.285177939);
+ proj.push_back(7.695791381);
+ proj.push_back(8.103643945);
+ proj.push_back(8.511496508);
+ proj.push_back(8.913802775);
+ proj.push_back(9.315740229);
+ proj.push_back(9.693344927);
+ proj.push_back(10.0572035);
+ proj.push_back(10.41496899);
+ proj.push_back(10.77273448);
+ proj.push_back(11.13049996);
+ proj.push_back(11.48826545);
+ proj.push_back(11.84603094);
+ proj.push_back(12.19943233);
+ proj.push_back(12.5474364);
+ proj.push_back(12.89256042);
+ proj.push_back(13.23768444);
+ proj.push_back(13.58280846);
+ proj.push_back(13.92793248);
+ proj.push_back(14.2730565);
+ proj.push_back(14.61818051);
+ proj.push_back(14.96330453);
+ proj.push_back(15.30842855);
+ proj.push_back(15.65355257);
+ proj.push_back(15.99867659);
+ proj.push_back(16.34380061);
+ proj.push_back(16.68892462);
+ proj.push_back(17.03404864);
+ proj.push_back(17.37917266);
+ proj.push_back(17.7238622);
+ proj.push_back(18.06332781);
+ proj.push_back(18.40267754);
+ proj.push_back(18.73101759);
+ proj.push_back(19.05829313);
+ proj.push_back(19.3769189);
+ proj.push_back(19.69500045);
+ proj.push_back(20.0010306);
+ proj.push_back(20.30628026);
+ proj.push_back(20.60358868);
+ proj.push_back(20.89992192);
+ proj.push_back(21.19625516);
+ proj.push_back(21.4925884);
+ proj.push_back(21.78892164);
+ proj.push_back(22.08229394);
+ proj.push_back(22.37495987);
+ proj.push_back(22.66762581);
+ proj.push_back(22.96029174);
+ proj.push_back(23.25295768);
+ proj.push_back(23.54562361);
+ proj.push_back(23.83828955);
+ proj.push_back(24.13095549);
+ proj.push_back(24.42362142);
+ proj.push_back(24.71628736);
+ proj.push_back(25.00895329);
+ proj.push_back(25.30161923);
+ proj.push_back(25.59428516);
+ proj.push_back(25.8869511);
+ proj.push_back(26.17961703);
+ proj.push_back(26.47228297);
+ proj.push_back(26.76257262);
+ proj.push_back(27.05279049);
+ proj.push_back(27.34257265);
+ proj.push_back(27.63070097);
+ proj.push_back(27.91711687);
+ proj.push_back(28.20308566);
+ proj.push_back(28.48513176);
+ proj.push_back(28.76667161);
+ proj.push_back(29.04775635);
+ proj.push_back(29.32798359);
+ proj.push_back(29.60725702);
+ proj.push_back(29.88619335);
+ proj.push_back(30.16489915);
+ proj.push_back(30.44340655);
+ proj.push_back(30.72150329);
+ proj.push_back(30.99779604);
+ proj.push_back(31.27408878);
+ proj.push_back(31.55038153);
+ proj.push_back(31.82667427);
+ proj.push_back(32.10296702);
+ proj.push_back(32.37925976);
+ proj.push_back(32.6555525);
+ proj.push_back(32.93184525);
+ proj.push_back(33.20813799);
+ proj.push_back(33.48430662);
+ proj.push_back(33.7548692);
+
+ for (size_t proj_no = 0; proj_no != p.number_of_projections_to_R(); ++proj_no) {
+ // cout << std::setprecision(10) << p.project_to_R(proj_no) << endl;
+ BOOST_CHECK(almost_equal(p.project_to_R(proj_no), proj[proj_no]));
+ }
}
+BOOST_AUTO_TEST_CASE(check_distance_computations) {
+ Vector_distances_in_diagram<Euclidean_distance> p("data/file_with_diagram", 100);
+ Vector_distances_in_diagram<Euclidean_distance> p_prime("data/file_with_diagram", 10);
+ std::vector<std::pair<double, double> > intervals(10);
+ intervals[0] = std::pair<double, double>(1, 2);
+ intervals[1] = std::pair<double, double>(3, 4);
+ intervals[2] = std::pair<double, double>(5, 6);
+ intervals[3] = std::pair<double, double>(7, 8);
+ intervals[4] = std::pair<double, double>(9, 10);
+ intervals[5] = std::pair<double, double>(11, 12);
+ intervals[6] = std::pair<double, double>(13, 14);
+ intervals[7] = std::pair<double, double>(15, 16);
+ intervals[8] = std::pair<double, double>(17, 18);
+ intervals[9] = std::pair<double, double>(19, 20);
+ Vector_distances_in_diagram<Euclidean_distance> p_bis(intervals, 10);
+ // cerr << "p_prime.distance( (Abs_Topological_data_with_distances*)(&p_bis) , 1 ) : " << p_prime.distance(
+ // (Abs_Topological_data_with_distances*)(&p_bis) , 1 ) << endl;
+ BOOST_CHECK(almost_equal(p_prime.distance(p_bis, 1), 1.86428));
+}
+BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances) {
+ std::vector<std::pair<double, double> > diag =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
+ Vector_distances_in_diagram<Euclidean_distance> p(diag, 100);
+ std::vector<std::pair<double, double> > diag1 =
+ read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram_1");
+ Vector_distances_in_diagram<Euclidean_distance> q(diag1, 100);
+ double dist_numeric_limit_max = p.distance(q, std::numeric_limits<double>::max());
+ double dist_infinity = p.distance(q, std::numeric_limits<double>::infinity());
-BOOST_AUTO_TEST_CASE(check_distance_computations)
-{
- Vector_distances_in_diagram< Euclidean_distance > p( "data/file_with_diagram" , 100 );
- Vector_distances_in_diagram< Euclidean_distance > p_prime( "data/file_with_diagram" , 10 );
- std::vector< std::pair<double,double> > intervals(10);
- intervals[0] = std::pair<double,double>( 1,2 );
- intervals[1] = std::pair<double,double>( 3,4 );
- intervals[2] = std::pair<double,double>( 5,6 );
- intervals[3] = std::pair<double,double>( 7,8 );
- intervals[4] = std::pair<double,double>( 9,10 );
- intervals[5] = std::pair<double,double>( 11,12 );
- intervals[6] = std::pair<double,double>( 13,14 );
- intervals[7] = std::pair<double,double>( 15,16 );
- intervals[8] = std::pair<double,double>( 17,18 );
- intervals[9] = std::pair<double,double>( 19,20 );
- Vector_distances_in_diagram< Euclidean_distance > p_bis( intervals , 10 );
- //cerr << "p_prime.distance( (Abs_Topological_data_with_distances*)(&p_bis) , 1 ) : " << p_prime.distance( (Abs_Topological_data_with_distances*)(&p_bis) , 1 ) << endl;
- BOOST_CHECK( almost_equal ( p_prime.distance( p_bis , 1 ) , 1.86428 ) );
+ BOOST_CHECK(dist_numeric_limit_max == dist_infinity);
}
-BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances )
-{
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram" );
- Vector_distances_in_diagram< Euclidean_distance > p( diag , 100 );
-
- std::vector< std::pair< double , double > > diag1 = read_persistence_intervals_in_one_dimension_from_file( "data/file_with_diagram_1" );
- Vector_distances_in_diagram< Euclidean_distance > q( diag1 , 100 );
-
- double dist_numeric_limit_max = p.distance( q,std::numeric_limits<double>::max() );
- double dist_infinity = p.distance( q,std::numeric_limits<double>::infinity() );
-
- BOOST_CHECK( dist_numeric_limit_max == dist_infinity );
-}
+BOOST_AUTO_TEST_CASE(check_compute_average) {
+ Vector_distances_in_diagram<Euclidean_distance> p("data/file_with_diagram", 100);
+ // compute average
+ std::vector<std::pair<double, double> > i1(3);
+ i1[0] = std::pair<double, double>(1, 2);
+ i1[1] = std::pair<double, double>(3, 8);
+ i1[2] = std::pair<double, double>(1, 6);
+ std::vector<std::pair<double, double> > i2(3);
+ i2[0] = std::pair<double, double>(2, 9);
+ i2[1] = std::pair<double, double>(2, 15);
+ i2[2] = std::pair<double, double>(6, 17);
+ Vector_distances_in_diagram<Euclidean_distance> A(i1, -1);
+ Vector_distances_in_diagram<Euclidean_distance> B(i1, -1);
-BOOST_AUTO_TEST_CASE(check_compute_average)
-{
- Vector_distances_in_diagram< Euclidean_distance > p( "data/file_with_diagram" , 100 );
- //compute average
- std::vector< std::pair<double,double> > i1(3);
- i1[0] = std::pair<double,double>( 1,2 );
- i1[1] = std::pair<double,double>( 3,8 );
- i1[2] = std::pair<double,double>( 1,6 );
-
- std::vector< std::pair<double,double> > i2(3);
- i2[0] = std::pair<double,double>( 2,9 );
- i2[1] = std::pair<double,double>( 2,15);
- i2[2] = std::pair<double,double>( 6,17 );
-
- Vector_distances_in_diagram< Euclidean_distance > A( i1 , -1 );
- Vector_distances_in_diagram< Euclidean_distance > B( i1 , -1 );
+ Vector_distances_in_diagram<Euclidean_distance> average;
+ average.compute_average({&A, &B});
- Vector_distances_in_diagram< Euclidean_distance > average;
- average.compute_average( {&A,&B} );
-
- Vector_distances_in_diagram< Euclidean_distance > template_average;
- template_average.load_from_file( "data/average_of_persistence_vectors" );
-
- BOOST_CHECK( template_average == average );
-
-}
+ Vector_distances_in_diagram<Euclidean_distance> template_average;
+ template_average.load_from_file("data/average_of_persistence_vectors");
+ BOOST_CHECK(template_average == average);
+}
-
-BOOST_AUTO_TEST_CASE(check_arythmetic_operations)
-{
- std::vector< std::pair<double,double> > i1(3);
- i1[0] = std::pair<double,double>( 1,2 );
- i1[1] = std::pair<double,double>( 3,8 );
- i1[2] = std::pair<double,double>( 1,6 );
-
- std::vector< std::pair<double,double> > i2(3);
- i2[0] = std::pair<double,double>( 2,9 );
- i2[1] = std::pair<double,double>( 2,15);
- i2[2] = std::pair<double,double>( 6,17 );
-
- Vector_distances_in_diagram< Euclidean_distance > A( i1 , -1 );
- Vector_distances_in_diagram< Euclidean_distance > B( i1 , -1 );
-
- Vector_distances_in_diagram< Euclidean_distance > sum = A+B;
- Vector_distances_in_diagram< Euclidean_distance > difference = A-B;
-
- BOOST_CHECK( almost_equal( sum.vector_in_position(0) , 7.07107) );
- BOOST_CHECK( almost_equal( sum.vector_in_position(1) , 7.07107) );
- BOOST_CHECK( almost_equal( sum.vector_in_position(2) , 5.65685) );
- BOOST_CHECK( almost_equal( sum.vector_in_position(3) , 1.41421) );
- BOOST_CHECK( almost_equal( sum.vector_in_position(4) , 1.41421) );
- BOOST_CHECK( almost_equal( sum.vector_in_position(5) , 1.41421) );
-
- BOOST_CHECK( almost_equal( difference.vector_in_position(0) , 0) );
- BOOST_CHECK( almost_equal( difference.vector_in_position(1) , 0) );
- BOOST_CHECK( almost_equal( difference.vector_in_position(2) , 0) );
- BOOST_CHECK( almost_equal( difference.vector_in_position(3) , 0) );
- BOOST_CHECK( almost_equal( difference.vector_in_position(4) , 0) );
- BOOST_CHECK( almost_equal( difference.vector_in_position(5) , 0) );
-
- Vector_distances_in_diagram< Euclidean_distance > prod = 2.*A;
- BOOST_CHECK( almost_equal( prod.vector_in_position(0) , 7.07107) );
- BOOST_CHECK( almost_equal( prod.vector_in_position(1) , 7.07107) );
- BOOST_CHECK( almost_equal( prod.vector_in_position(2) , 5.65685) );
- BOOST_CHECK( almost_equal( prod.vector_in_position(3) , 1.41421) );
- BOOST_CHECK( almost_equal( prod.vector_in_position(4) , 1.41421) );
- BOOST_CHECK( almost_equal( prod.vector_in_position(5) , 1.41421) );
-
- Vector_distances_in_diagram< Euclidean_distance > prod1 = A*2;
- BOOST_CHECK( almost_equal( prod1.vector_in_position(0) , 7.07107) );
- BOOST_CHECK( almost_equal( prod1.vector_in_position(1) , 7.07107) );
- BOOST_CHECK( almost_equal( prod1.vector_in_position(2) , 5.65685) );
- BOOST_CHECK( almost_equal( prod1.vector_in_position(3) , 1.41421) );
- BOOST_CHECK( almost_equal( prod1.vector_in_position(4) , 1.41421) );
- BOOST_CHECK( almost_equal( prod1.vector_in_position(5) , 1.41421) );
-
+BOOST_AUTO_TEST_CASE(check_arythmetic_operations) {
+ std::vector<std::pair<double, double> > i1(3);
+ i1[0] = std::pair<double, double>(1, 2);
+ i1[1] = std::pair<double, double>(3, 8);
+ i1[2] = std::pair<double, double>(1, 6);
+
+ std::vector<std::pair<double, double> > i2(3);
+ i2[0] = std::pair<double, double>(2, 9);
+ i2[1] = std::pair<double, double>(2, 15);
+ i2[2] = std::pair<double, double>(6, 17);
+
+ Vector_distances_in_diagram<Euclidean_distance> A(i1, -1);
+ Vector_distances_in_diagram<Euclidean_distance> B(i1, -1);
+
+ Vector_distances_in_diagram<Euclidean_distance> sum = A + B;
+ Vector_distances_in_diagram<Euclidean_distance> difference = A - B;
+
+ BOOST_CHECK(almost_equal(sum.vector_in_position(0), 7.07107));
+ BOOST_CHECK(almost_equal(sum.vector_in_position(1), 7.07107));
+ BOOST_CHECK(almost_equal(sum.vector_in_position(2), 5.65685));
+ BOOST_CHECK(almost_equal(sum.vector_in_position(3), 1.41421));
+ BOOST_CHECK(almost_equal(sum.vector_in_position(4), 1.41421));
+ BOOST_CHECK(almost_equal(sum.vector_in_position(5), 1.41421));
+
+ BOOST_CHECK(almost_equal(difference.vector_in_position(0), 0));
+ BOOST_CHECK(almost_equal(difference.vector_in_position(1), 0));
+ BOOST_CHECK(almost_equal(difference.vector_in_position(2), 0));
+ BOOST_CHECK(almost_equal(difference.vector_in_position(3), 0));
+ BOOST_CHECK(almost_equal(difference.vector_in_position(4), 0));
+ BOOST_CHECK(almost_equal(difference.vector_in_position(5), 0));
+
+ Vector_distances_in_diagram<Euclidean_distance> prod = 2. * A;
+ BOOST_CHECK(almost_equal(prod.vector_in_position(0), 7.07107));
+ BOOST_CHECK(almost_equal(prod.vector_in_position(1), 7.07107));
+ BOOST_CHECK(almost_equal(prod.vector_in_position(2), 5.65685));
+ BOOST_CHECK(almost_equal(prod.vector_in_position(3), 1.41421));
+ BOOST_CHECK(almost_equal(prod.vector_in_position(4), 1.41421));
+ BOOST_CHECK(almost_equal(prod.vector_in_position(5), 1.41421));
+
+ Vector_distances_in_diagram<Euclidean_distance> prod1 = A * 2;
+ BOOST_CHECK(almost_equal(prod1.vector_in_position(0), 7.07107));
+ BOOST_CHECK(almost_equal(prod1.vector_in_position(1), 7.07107));
+ BOOST_CHECK(almost_equal(prod1.vector_in_position(2), 5.65685));
+ BOOST_CHECK(almost_equal(prod1.vector_in_position(3), 1.41421));
+ BOOST_CHECK(almost_equal(prod1.vector_in_position(4), 1.41421));
+ BOOST_CHECK(almost_equal(prod1.vector_in_position(5), 1.41421));
}