summaryrefslogtreecommitdiff
path: root/src/Persistence_representations/test/persistence_lanscapes_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Persistence_representations/test/persistence_lanscapes_test.cpp')
-rw-r--r--src/Persistence_representations/test/persistence_lanscapes_test.cpp610
1 files changed, 293 insertions, 317 deletions
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;
+ }
+*/