diff options
Diffstat (limited to 'src/Gudhi_stat/include')
15 files changed, 435 insertions, 319 deletions
diff --git a/src/Gudhi_stat/include/gudhi/Hausdorff_distances.h b/src/Gudhi_stat/include/gudhi/Hausdorff_distances.h index de39ad7d..39de764e 100644 --- a/src/Gudhi_stat/include/gudhi/Hausdorff_distances.h +++ b/src/Gudhi_stat/include/gudhi/Hausdorff_distances.h @@ -29,6 +29,11 @@ #include <cstdlib> #include <iostream> +namespace Gudhi +{ +namespace Gudhi_stat +{ + /** * This file contains various implementations of Hausrodff distances between collections of points. It contains various implementations that can be used for specific case. @@ -138,5 +143,7 @@ public: }; +}//namespace Gudhi_stat +}//namespace Gudhi #endif diff --git a/src/Gudhi_stat/include/gudhi/bootstrap.h b/src/Gudhi_stat/include/gudhi/bootstrap.h index ca40f9c7..83edb2e1 100644 --- a/src/Gudhi_stat/include/gudhi/bootstrap.h +++ b/src/Gudhi_stat/include/gudhi/bootstrap.h @@ -23,11 +23,6 @@ #ifndef BOOTSTRAP_H #define BOOTSTRAP_H -//concretizations -#include <gudhi/concretizations/Vector_distances_in_diagram.h> -#include <gudhi/concretizations/Persistence_landscape.h> -#include <gudhi/concretizations/Persistence_landscape_on_grid.h> -#include <gudhi/concretizations/Persistence_heat_maps.h> #ifdef GUDHI_USE_TBB #include <tbb/parallel_sort.h> @@ -39,6 +34,11 @@ #include <random> #include <ctime> +namespace Gudhi +{ +namespace Gudhi_stat +{ + /** * This is a generic function to perform bootstrap. * In this function we assume that there is a class to compute characteristic of collection of points (PointCloudCharacteristics) and that it stores coordinates of all points. It allows to compute the characteristic @@ -140,4 +140,9 @@ double bootstrap( size_t number_of_points , CharacteristicFunction f , DistanceB }//bootstrap + + +}//namespace Gudhi_stat +}//namespace Gudhi + #endif diff --git a/src/Gudhi_stat/include/gudhi/common.h b/src/Gudhi_stat/include/gudhi/common.h index d573a92a..916b4499 100644 --- a/src/Gudhi_stat/include/gudhi/common.h +++ b/src/Gudhi_stat/include/gudhi/common.h @@ -20,9 +20,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#pragma once +#ifndef HAUSDORFF_DISTANCES_H +#define HAUSDORFF_DISTANCES_H //this file contain an implementation of some common procedures used in Gudhi_stat. + + + //double epsi = std::numeric_limits<double>::epsilon(); double epsi = 0.000005; diff --git a/src/Gudhi_stat/include/gudhi/common_gudhi_stat.h b/src/Gudhi_stat/include/gudhi/common_gudhi_stat.h new file mode 100644 index 00000000..1767b1be --- /dev/null +++ b/src/Gudhi_stat/include/gudhi/common_gudhi_stat.h @@ -0,0 +1,160 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Pawel Dlotko + * + * Copyright (C) 2015 INRIA (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef common_gudhi_stat_H +#define common_gudhi_stat_H + + +namespace Gudhi +{ +namespace Gudhi_stat +{ + //this file contain an implementation of some common procedures used in Gudhi_stat. + + //double epsi = std::numeric_limits<double>::epsilon(); +double epsi = 0.000005; + + +double plus_( double a,double b ){return a+b;} +double minus_( double a,double b ){return a-b;} + + + +/** + * A procedure used to compare doubles. Typically gien two doubles A and B, comparing A == B is not good idea. In this case, we use the procedure almostEqual with the epsi defined at + * the top of the file. Setting up the epsi give the user a tolerance on what should be consider equal. +**/ +inline bool almost_equal( double a , double b ) +{ + if ( fabs(a-b) < epsi ) + return true; + return false; +} + + + + +//landscapes +/** + * Extra functions needed in construction of barcodes. +**/ +double minus_length( std::pair<double,double> a ) +{ + return a.first-a.second; +} +double birth_plus_deaths( std::pair<double,double> a ) +{ + return a.first+a.second; +} + + +//landscapes +/** + * Given two points in R^2, the procedure compute the parameters A and B of the line y = Ax + B that crosses those two points. +**/ +std::pair<double,double> compute_parameters_of_a_line( std::pair<double,double> p1 , std::pair<double,double> p2 ) +{ + double a = (p2.second-p1.second)/( p2.first - p1.first ); + double b = p1.second - a*p1.first; + return std::make_pair(a,b); +} + +//landscapes +/** + * This procedure given two points which lies on the opposide sides of x axis, compute x for which the line connecting those two points crosses x axis. +**/ +double find_zero_of_a_line_segment_between_those_two_points ( std::pair<double,double> p1, std::pair<double,double> p2 ) +{ + if ( p1.first == p2.first )return p1.first; + if ( p1.second*p2.second > 0 ) + { + std::ostringstream errMessage; + errMessage <<"In function find_zero_of_a_line_segment_between_those_two_points the agguments are: (" << p1.first << "," << p1.second << ") and (" << p2.first << "," << p2.second << "). There is no zero in line between those two points. Program terminated."; + std::string errMessageStr = errMessage.str(); + const char* err = errMessageStr.c_str(); + throw(err); + } + //we assume here, that x \in [ p1.first, p2.first ] and p1 and p2 are points between which we will put the line segment + double a = (p2.second - p1.second)/(p2.first - p1.first); + double b = p1.second - a*p1.first; + //cerr << "Line crossing points : (" << p1.first << "," << p1.second << ") oraz (" << p2.first << "," << p2.second << ") : \n"; + //cerr << "a : " << a << " , b : " << b << " , x : " << x << endl; + return -b/a; +} + + + +//landscapes +/** + * Lexicographical ordering of points . +**/ +bool compare_points_sorting( std::pair<double,double> f, std::pair<double,double> s ) +{ + if ( f.first < s.first ) + { + return true; + } + else + {//f.first >= s.first + if ( f.first > s.first ) + { + return false; + } + else + {//f.first == s.first + if ( f.second > s.second ) + { + return true; + } + else + { + return false; + } + } + } +} + + +//landscapes +/** + * This procedure takes two points in R^2 and a double value x. It conputes the line pasing through those two points and return the value of that linear function at x. +**/ +double function_value ( std::pair<double,double> p1, std::pair<double,double> p2 , double x ) +{ + //we assume here, that x \in [ p1.first, p2.first ] and p1 and p2 are points between which we will put the line segment + double a = (p2.second - p1.second)/(p2.first - p1.first); + double b = p1.second - a*p1.first; + return (a*x+b); +} + +//landscapes on a grid +struct greater_landscapes_on_grid +{ + template<class T> + bool operator()(T const &a, T const &b) const { return a > b; } +}; + + +}//namespace Gudhi_stat +}//namespace Gudhi + +#endif diff --git a/src/Gudhi_stat/include/gudhi/concretizations/PSSK.h b/src/Gudhi_stat/include/gudhi/concretizations/PSSK.h index e61711f4..89da2a2d 100644 --- a/src/Gudhi_stat/include/gudhi/concretizations/PSSK.h +++ b/src/Gudhi_stat/include/gudhi/concretizations/PSSK.h @@ -95,9 +95,9 @@ void PSSK::construct( const std::vector< std::pair<double,double> >& intervals_ if ( dbg ) { - cerr << "min_ : " << min_ << endl; - cerr << "max_ : " << max_ << endl; - cerr << "number_of_pixels : " << number_of_pixels << endl; + std::cerr << "min_ : " << min_ << std::endl; + std::cerr << "max_ : " << max_ << std::endl; + std::cerr << "number_of_pixels : " << number_of_pixels << std::endl; getchar(); } @@ -115,7 +115,7 @@ void PSSK::construct( const std::vector< std::pair<double,double> >& intervals_ } this->heat_map = heat_map_; - if (dbg)cerr << "Done creating of the heat map, now we will fill in the structure \n"; + if (dbg)std::cerr << "Done creating of the heat map, now we will fill in the structure \n"; for ( size_t pt_nr = 0 ; pt_nr != intervals_.size() ; ++pt_nr ) { @@ -125,9 +125,9 @@ void PSSK::construct( const std::vector< std::pair<double,double> >& intervals_ if ( dbg ) { - std::cerr << "point : " << intervals_[pt_nr].first << " , " << intervals_[pt_nr].second << endl; - std::cerr << "x_grid : " << x_grid << endl; - std::cerr << "y_grid : " << y_grid << endl; + std::cerr << "point : " << intervals_[pt_nr].first << " , " << intervals_[pt_nr].second << std::endl; + std::cerr << "x_grid : " << x_grid << std::endl; + std::cerr << "y_grid : " << y_grid << std::endl; } //x_grid and y_grid gives a center of the kernel. We want to have its lower left cordner. To get this, we need to shift x_grid and y_grid by a grid diameter. @@ -138,8 +138,8 @@ void PSSK::construct( const std::vector< std::pair<double,double> >& intervals_ if ( dbg ) { std::cerr << "After shift : \n";; - std::cerr << "x_grid : " << x_grid << endl; - std::cerr << "y_grid : " << y_grid << endl; + std::cerr << "x_grid : " << x_grid << std::endl; + std::cerr << "y_grid : " << y_grid << std::endl; std::cerr << "filter.size() : " << filter.size() << std::endl; getchar(); } diff --git a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_heat_maps.h b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_heat_maps.h index 83583a57..22df8d8e 100644 --- a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_heat_maps.h +++ b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_heat_maps.h @@ -33,12 +33,11 @@ #include <algorithm> //gudhi include -#include <gudhi/concretizations/read_persitence_from_file.h> +#include <gudhi/read_persitence_from_file.h> #include <gudhi/common_gudhi_stat.h> -using namespace std; namespace Gudhi { @@ -71,8 +70,8 @@ std::vector< std::vector<double> > create_Gaussian_filter( size_t pixel_radius , if ( dbg ) { std::cerr << "Kernel initalize \n"; - cerr << "pixel_radius : " << pixel_radius << endl; - std::cerr << "kernel.size() : " << kernel.size() << endl; + std::cerr << "pixel_radius : " << pixel_radius << std::endl; + std::cerr << "kernel.size() : " << kernel.size() << std::endl; getchar(); } @@ -277,12 +276,12 @@ public: /** * Return minimal range value of persistent image. **/ - inline double gimme_min()const{return this->min_;} + inline double give_me_min()const{return this->min_;} /** * Return maximal range value of persistent image. **/ - inline double gimme_max()const{return this->max_;} + inline double give_me_max()const{return this->max_;} /** @@ -329,8 +328,9 @@ public: void plot( const char* filename )const; - //implementation of arythmetic operations: - + /** + * Binary (arythmetic) operation on two Persistence_heat_maps. + **/ friend Persistence_heat_maps operation_on_pair_of_heat_maps( const Persistence_heat_maps& first , const Persistence_heat_maps& second , double (*opertion)( double,double ) ) { //first check if the heat maps are compatible @@ -356,6 +356,10 @@ public: return result; }//operation_on_pair_of_heat_maps + + /** + * Multiplication of Persistence_heat_maps by scalar (so that all values of the heat map gets multiplied by that scalar). + **/ Persistence_heat_maps multiply_by_scalar( double scalar )const { Persistence_heat_maps result; @@ -376,42 +380,42 @@ public: } /** - * This function computes a sum of two objects of a type Vector_distances_in_diagram. + * This function computes a sum of two objects of a type Persistence_heat_maps. **/ friend Persistence_heat_maps operator+( const Persistence_heat_maps& first , const Persistence_heat_maps& second ) { return operation_on_pair_of_heat_maps( first , second , plus_ ); } /** - * This function computes a difference of two objects of a type Vector_distances_in_diagram. + * This function computes a difference of two objects of a type Persistence_heat_maps. **/ friend Persistence_heat_maps operator-( const Persistence_heat_maps& first , const Persistence_heat_maps& second ) { return operation_on_pair_of_heat_maps( first , second , minus_ ); } /** - * This function computes a product of an object of a type Vector_distances_in_diagram with real number. + * This function computes a product of an object of a type Persistence_heat_maps with real number. **/ friend Persistence_heat_maps operator*( double scalar , const Persistence_heat_maps& A ) { return A.multiply_by_scalar( scalar ); } /** - * This function computes a product of an object of a type Vector_distances_in_diagram with real number. + * This function computes a product of an object of a type Persistence_heat_maps with real number. **/ friend Persistence_heat_maps operator*( const Persistence_heat_maps& A , double scalar ) { return A.multiply_by_scalar( scalar ); } /** - * This function computes a product of an object of a type Vector_distances_in_diagram with real number. + * This function computes a product of an object of a type Persistence_heat_maps with real number. **/ Persistence_heat_maps operator*( double scalar ) { return this->multiply_by_scalar( scalar ); } /** - * += operator for Vector_distances_in_diagram. + * += operator for Persistence_heat_maps. **/ Persistence_heat_maps operator += ( const Persistence_heat_maps& rhs ) { @@ -419,7 +423,7 @@ public: return *this; } /** - * -= operator for Vector_distances_in_diagram. + * -= operator for Persistence_heat_maps. **/ Persistence_heat_maps operator -= ( const Persistence_heat_maps& rhs ) { @@ -427,7 +431,7 @@ public: return *this; } /** - * *= operator for Vector_distances_in_diagram. + * *= operator for Persistence_heat_maps. **/ Persistence_heat_maps operator *= ( double x ) { @@ -435,7 +439,7 @@ public: return *this; } /** - * /= operator for Vector_distances_in_diagram. + * /= operator for Persistence_heat_maps. **/ Persistence_heat_maps operator /= ( double x ) { @@ -475,6 +479,7 @@ public: * A function to compute distance between persistence heat maps. * The parameter of this function is a const reference to an object of a class Persistence_heat_maps. * This function is required in Topological_data_with_distances concept. + * For max norm distance, set power to std::numeric_limits<double>::max() **/ double distance( const Persistence_heat_maps& second_ , double power = 1)const; @@ -497,7 +502,7 @@ public: /** * The x-range of the persistence heat map. **/ - std::pair< double , double > gimme_x_range()const + std::pair< double , double > give_me_x_range()const { return std::make_pair( this->min_ , this->max_ ); } @@ -505,9 +510,9 @@ public: /** * The y-range of the persistence heat map. **/ - std::pair< double , double > gimme_y_range()const + std::pair< double , double > give_me_y_range()const { - return this->gimme_x_range(); + return this->give_me_x_range(); } @@ -571,9 +576,9 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct( const std::vector< s if ( dbg ) { - cerr << "min_ : " << min_ << endl; - cerr << "max_ : " << max_ << endl; - cerr << "number_of_pixels : " << number_of_pixels << endl; + std::cerr << "min_ : " << min_ << std::endl; + std::cerr << "max_ : " << max_ << std::endl; + std::cerr << "number_of_pixels : " << number_of_pixels << std::endl; getchar(); } @@ -589,7 +594,7 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct( const std::vector< s } this->heat_map = heat_map_; - if (dbg)cerr << "Done creating of the heat map, now we will fill in the structure \n"; + if (dbg)std::cerr << "Done creating of the heat map, now we will fill in the structure \n"; for ( size_t pt_nr = 0 ; pt_nr != intervals_.size() ; ++pt_nr ) { @@ -599,9 +604,9 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct( const std::vector< s if ( dbg ) { - std::cerr << "point : " << intervals_[pt_nr].first << " , " << intervals_[pt_nr].second << endl; - std::cerr << "x_grid : " << x_grid << endl; - std::cerr << "y_grid : " << y_grid << endl; + std::cerr << "point : " << intervals_[pt_nr].first << " , " << intervals_[pt_nr].second << std::endl; + std::cerr << "x_grid : " << x_grid << std::endl; + std::cerr << "y_grid : " << y_grid << std::endl; } //x_grid and y_grid gives a center of the kernel. We want to have its lower left cordner. To get this, we need to shift x_grid and y_grid by a grid diameter. @@ -612,8 +617,8 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct( const std::vector< s if ( dbg ) { std::cerr << "After shift : \n";; - std::cerr << "x_grid : " << x_grid << endl; - std::cerr << "y_grid : " << y_grid << endl; + std::cerr << "x_grid : " << x_grid << std::endl; + std::cerr << "y_grid : " << y_grid << std::endl; } double scaling_value = this->f(intervals_[pt_nr]); @@ -782,7 +787,7 @@ void Persistence_heat_maps<Scalling_of_kernels>::compute_percentage_of_active( c template <typename Scalling_of_kernels> void Persistence_heat_maps<Scalling_of_kernels>::plot( const char* filename )const { - ofstream out; + std::ofstream out; std::stringstream ss; ss << filename << "_GnuplotScript"; @@ -794,7 +799,7 @@ void Persistence_heat_maps<Scalling_of_kernels>::plot( const char* filename )con { out << this->heat_map[i][j] << " "; } - out << endl; + out << std::endl; } out.close(); std::cout << "Gnuplot script have been created. Open gnuplot and type load \'" << ss.str().c_str() << "\' to see the picture." << std::endl; @@ -805,7 +810,7 @@ template <typename Scalling_of_kernels> void Persistence_heat_maps<Scalling_of_kernels>::print_to_file( const char* filename )const { - ofstream out; + std::ofstream out; out.open( filename ); //First we store this->min_ and this->max_ values: @@ -816,7 +821,7 @@ void Persistence_heat_maps<Scalling_of_kernels>::print_to_file( const char* file { out << this->heat_map[i][j] << " "; } - out << endl; + out << std::endl; } out.close(); } @@ -826,13 +831,13 @@ void Persistence_heat_maps<Scalling_of_kernels>::load_from_file( const char* fil { bool dbg = false; - ifstream in; + std::ifstream in; in.open( filename ); //checking if the file exist / if it was open. if ( !( access( filename, F_OK ) != -1 ) ) { - cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; + std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; } @@ -918,11 +923,28 @@ double Persistence_heat_maps<Scalling_of_kernels>::distance( const Persistence_h //if we are here, we know that the two persistence iomages are defined on the same domain, so we can start computing their distances: double distance = 0; - for ( size_t i = 0 ; i != this->heat_map.size() ; ++i ) + if ( power != std::numeric_limits<double>::max() ) { - for ( size_t j = 0 ; j != this->heat_map[i].size() ; ++j ) + for ( size_t i = 0 ; i != this->heat_map.size() ; ++i ) + { + for ( size_t j = 0 ; j != this->heat_map[i].size() ; ++j ) + { + distance += pow( fabs(this->heat_map[i][j] - second.heat_map[i][j]) , power ); + } + } + } + else + { + //in this case, we compute max norm distance + for ( size_t i = 0 ; i != this->heat_map.size() ; ++i ) { - distance += pow( abs(this->heat_map[i][j] - second.heat_map[i][j]) , power ); + for ( size_t j = 0 ; j != this->heat_map[i].size() ; ++j ) + { + if ( distance < fabs(this->heat_map[i][j] - second.heat_map[i][j]) ) + { + distance = fabs(this->heat_map[i][j] - second.heat_map[i][j]); + } + } } } return distance; diff --git a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_intervals.h b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_intervals.h index b917de69..3bd98835 100644 --- a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_intervals.h +++ b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_intervals.h @@ -24,7 +24,7 @@ #define Persistence_intervals_H_
//gudhi include
-#include <gudhi/concretizations/read_persitence_from_file.h>
+#include <gudhi/read_persitence_from_file.h>
//standard include
#include <limits>
@@ -66,7 +66,7 @@ public: /**
* This procedure returns x-range of a given persistence diagram.
**/
- std::pair< double , double > gimme_x_range()const
+ std::pair< double , double > give_me_x_range()const
{
double min_ = std::numeric_limits<int>::max();
double max_ = -std::numeric_limits<int>::max();
@@ -81,7 +81,7 @@ public: /**
* This procedure returns y-range of a given persistence diagram.
**/
- std::pair< double , double > gimme_y_range()const
+ std::pair< double , double > give_me_y_range()const
{
double min_ = std::numeric_limits<int>::max();
double max_ = -std::numeric_limits<int>::max();
@@ -478,7 +478,7 @@ std::vector< double > Persistence_intervals::characteristic_function_of_diagram( beginIt = number_of_bins*(this->intervals[i].first-x_min)/(x_max - x_min);
}
- size_t endIt;
+ size_t endIt = 0;
if ( this->intervals[i].second < x_min )endIt = 0;
if ( this->intervals[i].second >= x_max )endIt = result.size();
if ( ( this->intervals[i].second > x_min ) && ( this->intervals[i].second < x_max ) )
diff --git a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape.h b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape.h index fd6837c0..bd41e1bd 100644 --- a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape.h +++ b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape.h @@ -36,9 +36,8 @@ //gudhi include -#include <gudhi/concretizations/read_persitence_from_file.h> +#include <gudhi/read_persitence_from_file.h> #include <gudhi/common_gudhi_stat.h> -using namespace std; @@ -76,16 +75,6 @@ public: Persistence_landscape( const std::vector< std::pair< double , double > >& p ); /** - * Assignement operator. - **/ - Persistence_landscape& operator=( const Persistence_landscape& org ); - - /** - * Copy constructor. - **/ - Persistence_landscape(const Persistence_landscape&); - - /** * Constructor that reads persistence intervals from file and creates persistence landscape. The format of the input file is the following: in each line we put birth-death pair. Last line is assumed * to be empty. Even if the points within a line are not ordered, they will be ordered while the input is read. **/ @@ -141,7 +130,7 @@ public: /** - * A function that compute sum of two landscapes. + *\private A function that compute sum of two landscapes. **/ friend Persistence_landscape add_two_landscapes ( const Persistence_landscape& land1 , const Persistence_landscape& land2 ) { @@ -149,7 +138,7 @@ public: } /** - * A function that compute difference of two landscapes. + *\private A function that compute difference of two landscapes. **/ friend Persistence_landscape subtract_two_landscapes ( const Persistence_landscape& land1 , const Persistence_landscape& land2 ) { @@ -189,7 +178,7 @@ public: } /** - * Operator +=. The second parameter is persistnece landwscape. + * Operator +=. The second parameter is persistence landscape. **/ Persistence_landscape operator += ( const Persistence_landscape& rhs ) { @@ -198,7 +187,7 @@ public: } /** - * Operator -=. The second parameter is persistnece landwscape. + * Operator -=. The second parameter is a persistence landscape. **/ Persistence_landscape operator -= ( const Persistence_landscape& rhs ) { @@ -282,13 +271,13 @@ public: double compute_norm_of_landscape( double i ) { Persistence_landscape l; - if ( i != -1 ) + if ( i != std::numeric_limits< double >::max() ) { - return compute_discance_of_landscapes(*this,l,i); + return compute_distance_of_landscapes(*this,l,i); } else { - return compute_max_norm_discance_of_landscapes(*this,l); + return compute_max_norm_distance_of_landscapes(*this,l); } } @@ -300,14 +289,14 @@ public: /** * Computations of L^{\infty} distance between two landscapes. **/ - friend double compute_max_norm_discance_of_landscapes( const Persistence_landscape& first, const Persistence_landscape& second ); - //friend double compute_max_norm_discance_of_landscapes( const Persistence_landscape& first, const Persistence_landscape& second , unsigned& nrOfLand , double&x , double& y1, double& y2 ); + friend double compute_max_norm_distance_of_landscapes( const Persistence_landscape& first, const Persistence_landscape& second ); + //friend double compute_max_norm_distance_of_landscapes( const Persistence_landscape& first, const Persistence_landscape& second , unsigned& nrOfLand , double&x , double& y1, double& y2 ); /** * Computations of L^{p} distance between two landscapes. p is the parameter of the procedure. **/ - friend double compute_discance_of_landscapes( const Persistence_landscape& first, const Persistence_landscape& second , int p ); + friend double compute_distance_of_landscapes( const Persistence_landscape& first, const Persistence_landscape& second , double p ); @@ -411,12 +400,12 @@ public: while ( nextLevelMerge.size() != 1 ) { - if ( dbg ){cerr << "nextLevelMerge.size() : " << nextLevelMerge.size() << endl;} + if ( dbg ){std::cerr << "nextLevelMerge.size() : " << nextLevelMerge.size() << std::endl;} std::vector< Persistence_landscape* > nextNextLevelMerge; nextNextLevelMerge.reserve( to_average.size() ); for ( size_t i = 0 ; i < nextLevelMerge.size() ; i=i+2 ) { - if ( dbg ){cerr << "i : " << i << endl;} + if ( dbg ){std::cerr << "i : " << i << std::endl;} Persistence_landscape* l = new Persistence_landscape; if ( i+1 != nextLevelMerge.size() ) { @@ -428,7 +417,7 @@ public: } nextNextLevelMerge.push_back( l ); } - if ( dbg ){cerr << "After this iteration \n";getchar();} + if ( dbg ){std::cerr << "After this iteration \n";getchar();} if ( !is_this_first_level ) { @@ -450,16 +439,17 @@ public: * A function to compute distance between persistence landscape. * The parameter of this functionis a Persistence_landscape. * This function is required in Topological_data_with_distances concept. + * For max norm distance, set power to std::numeric_limits<double>::max() **/ double distance( const Persistence_landscape& second , double power = 1 )const { - if ( power != -1 ) + if ( power != std::numeric_limits<double>::max() ) { - return compute_discance_of_landscapes( *this , second , power ); + return compute_distance_of_landscapes( *this , second , power ); } else { - return compute_max_norm_discance_of_landscapes( *this , second ); + return compute_max_norm_distance_of_landscapes( *this , second ); } } @@ -480,7 +470,7 @@ public: * This procedure returns x-range of a given level persistence landscape. If a default value is used, the x-range * of 0th level landscape is given (and this range contains the ranges of all other landscapes). **/ - std::pair< double , double > gimme_x_range( size_t level = 0 )const + std::pair< double , double > give_me_x_range( size_t level = 0 )const { std::pair< double , double > result; if ( level < this->land.size() ) @@ -498,7 +488,7 @@ public: * This procedure returns y-range of a given level persistence landscape. If a default value is used, the y-range * of 0th level landscape is given (and this range contains the ranges of all other landscapes). **/ - std::pair< double , double > gimme_y_range( size_t level = 0 )const + std::pair< double , double > give_me_y_range( size_t level = 0 )const { std::pair< double , double > result; if ( level < this->land.size() ) @@ -561,17 +551,7 @@ protected: }; -Persistence_landscape::Persistence_landscape(const Persistence_landscape& oryginal) -{ - //std::cerr << "Running copy constructor \n"; - std::vector< std::vector< std::pair<double,double> > > land( oryginal.land.size() ); - for ( size_t i = 0 ; i != oryginal.land.size() ; ++i ) - { - land[i].insert( land[i].end() , oryginal.land[i].begin() , oryginal.land[i].end() ); - } - this->land = land; - this->set_up_numbers_of_functions_for_vectorization_and_projections_to_reals(); -} + @@ -615,7 +595,7 @@ bool Persistence_landscape::operator == ( const Persistence_landscape& rhs )con { if ( !( almost_equal(this->land[level][i].first , rhs.land[level][i].first) && almost_equal(this->land[level][i].second , rhs.land[level][i].second) ) ) { - //cerr<< this->land[level][i].first << " , " << rhs.land[level][i].first << " and " << this->land[level][i].second << " , " << rhs.land[level][i].second << endl; + //std::cerr<< this->land[level][i].first << " , " << rhs.land[level][i].first << " and " << this->land[level][i].second << " , " << rhs.land[level][i].second << std::endl; if (operatorEqualDbg)std::cerr << "this->land[level][i] : " << this->land[level][i].first << " " << this->land[level][i].second << "\n"; if (operatorEqualDbg)std::cerr << "rhs.land[level][i] : " << rhs.land[level][i].first << " " << rhs.land[level][i].second << "\n"; if (operatorEqualDbg)std::cerr << "3\n"; @@ -627,17 +607,6 @@ bool Persistence_landscape::operator == ( const Persistence_landscape& rhs )con } -Persistence_landscape& Persistence_landscape::operator=( const Persistence_landscape& oryginal ) -{ - std::vector< std::vector< std::pair<double,double> > > land( oryginal.land.size() ); - for ( size_t i = 0 ; i != oryginal.land.size() ; ++i ) - { - land[i].insert( land[i].end() , oryginal.land[i].begin() , oryginal.land[i].end() ); - } - this->land = land; - return *this; -} - Persistence_landscape::Persistence_landscape( const std::vector< std::pair< double , double > > & p ) @@ -650,7 +619,7 @@ Persistence_landscape::Persistence_landscape( const std::vector< std::pair< doub void Persistence_landscape::construct_persistence_landscape_from_barcode( const std::vector< std::pair< double , double > > & p ) { bool dbg = false; - if ( dbg ){cerr << "Persistence_landscape::Persistence_landscape( const std::vector< std::pair< double , double > >& p )" << endl;} + if ( dbg ){std::cerr << "Persistence_landscape::Persistence_landscape( const std::vector< std::pair< double , double > >& p )" << std::endl;} //this is a general algorithm to construct persistence landscapes. std::vector< std::pair<double,double> > bars; @@ -889,7 +858,7 @@ double Persistence_landscape::compute_value_at_a_given_point( unsigned level , d if ( compute_value_at_a_given_pointDbg ) { - std::cerr << "Tutaj \n"; + std::cerr << "Here \n"; std::cerr << "x : " << x << "\n"; std::cerr << "this->land[level][coordBegin].first : " << this->land[level][coordBegin].first << "\n"; std::cerr << "this->land[level][coordEnd].first : " << this->land[level][coordEnd].first << "\n"; @@ -1074,7 +1043,7 @@ void Persistence_landscape::load_landscape_from_file( const char* filename ) in.open( filename ); if ( !( access( filename, F_OK ) != -1 ) ) { - cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; + std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; } @@ -1326,7 +1295,7 @@ double compute_maximal_distance_non_symmetric( const Persistence_landscape& pl1, -double compute_discance_of_landscapes( const Persistence_landscape& first, const Persistence_landscape& second , int p ) +double compute_distance_of_landscapes( const Persistence_landscape& first, const Persistence_landscape& second , double p ) { bool dbg = false; //This is what we want to compute: (\int_{- \infty}^{+\infty}| first-second |^p)^(1/p). We will do it one step at a time: @@ -1337,9 +1306,9 @@ double compute_discance_of_landscapes( const Persistence_landscape& first, const //| first-second |: lan = lan.abs(); - if ( dbg ){cerr << "Abs of difference ; " << lan << endl;getchar();} + if ( dbg ){std::cerr << "Abs of difference ; " << lan << std::endl;getchar();} - if ( p != -1 ) + if ( p != std::numeric_limits<double>::max() ) { //\int_{- \infty}^{+\infty}| first-second |^p double result; @@ -1358,13 +1327,13 @@ double compute_discance_of_landscapes( const Persistence_landscape& first, const } else { - //p == -1 - if ( dbg )std::cerr << "Power = -1, compute maximum \n"; + //p == infty + if ( dbg )std::cerr << "Power = infty, compute maximum \n"; return lan.compute_maximum(); } } -double compute_max_norm_discance_of_landscapes( const Persistence_landscape& first, const Persistence_landscape& second ) +double compute_max_norm_distance_of_landscapes( const Persistence_landscape& first, const Persistence_landscape& second ) { return std::max( compute_maximal_distance_non_symmetric(first,second) , compute_maximal_distance_non_symmetric(second,first) ); } @@ -1385,7 +1354,7 @@ double compute_inner_product( const Persistence_landscape& l1 , const Persistenc for ( size_t level = 0 ; level != std::min( l1.size() , l2.size() ) ; ++level ) { - if ( dbg ){cerr << "Computing inner product for a level : " << level << endl;getchar();} + if ( dbg ){std::cerr << "Computing inner product for a level : " << level << std::endl;getchar();} if ( l1.land[level].size() * l2.land[level].size() == 0 )continue; //endpoints of the interval on which we will compute the inner product of two locally linear functions: @@ -1437,12 +1406,12 @@ double compute_inner_product( const Persistence_landscape& l1 , const Persistenc if ( dbg ) { - cerr << "[l1.land[level][l1It].first,l1.land[level][l1It+1].first] : " << l1.land[level][l1It].first << " , " << l1.land[level][l1It+1].first << endl; - cerr << "[l2.land[level][l2It].first,l2.land[level][l2It+1].first] : " << l2.land[level][l2It].first << " , " << l2.land[level][l2It+1].first << endl; - cerr << "a : " << a << ", b : " << b << " , c: " << c << ", d : " << d << endl; - cerr << "x1 : " << x1 << " , x2 : " << x2 << endl; - cerr << "contributionFromThisPart : " << contributionFromThisPart << endl; - cerr << "result : " << result << endl; + std::cerr << "[l1.land[level][l1It].first,l1.land[level][l1It+1].first] : " << l1.land[level][l1It].first << " , " << l1.land[level][l1It+1].first << std::endl; + std::cerr << "[l2.land[level][l2It].first,l2.land[level][l2It+1].first] : " << l2.land[level][l2It].first << " , " << l2.land[level][l2It+1].first << std::endl; + std::cerr << "a : " << a << ", b : " << b << " , c: " << c << ", d : " << d << std::endl; + std::cerr << "x1 : " << x1 << " , x2 : " << x2 << std::endl; + std::cerr << "contributionFromThisPart : " << contributionFromThisPart << std::endl; + std::cerr << "result : " << result << std::endl; getchar(); } @@ -1458,11 +1427,11 @@ double compute_inner_product( const Persistence_landscape& l1 , const Persistenc { //in this case, we increment both: ++l2It; - if ( dbg ){cerr << "Incrementing both \n";} + if ( dbg ){std::cerr << "Incrementing both \n";} } else { - if ( dbg ){cerr << "Incrementing first \n";} + if ( dbg ){std::cerr << "Incrementing first \n";} } ++l1It; } @@ -1470,7 +1439,7 @@ double compute_inner_product( const Persistence_landscape& l1 , const Persistenc { //in this case we increment l2It ++l2It; - if ( dbg ){cerr << "Incrementing second \n";} + if ( dbg ){std::cerr << "Incrementing second \n";} } //Now, we shift x1 and x2: x1 = x2; @@ -1493,7 +1462,7 @@ double compute_inner_product( const Persistence_landscape& l1 , const Persistenc void Persistence_landscape::plot( const char* filename, double xRangeBegin , double xRangeEnd , double yRangeBegin , double yRangeEnd , int from , int to ) { //this program create a gnuplot script file that allows to plot persistence diagram. - ofstream out; + std::ofstream out; std::ostringstream nameSS; nameSS << filename << "_GnuplotScript"; @@ -1502,8 +1471,8 @@ void Persistence_landscape::plot( const char* filename, double xRangeBegin , do if ( (xRangeBegin != -1) || (xRangeEnd != -1) || (yRangeBegin != -1) || (yRangeEnd != -1) ) { - out << "set xrange [" << xRangeBegin << " : " << xRangeEnd << "]" << endl; - out << "set yrange [" << yRangeBegin << " : " << yRangeEnd << "]" << endl; + out << "set xrange [" << xRangeBegin << " : " << xRangeEnd << "]" << std::endl; + out << "set yrange [" << yRangeBegin << " : " << yRangeEnd << "]" << std::endl; } if ( from == -1 ){from = 0;} @@ -1518,18 +1487,18 @@ void Persistence_landscape::plot( const char* filename, double xRangeBegin , do { out << ", \\"; } - out << endl; + out << std::endl; } for ( size_t lambda= std::min((size_t)from,this->land.size()) ; lambda != std::min((size_t)to,this->land.size()) ; ++lambda ) { for ( size_t i = 1 ; i != this->land[lambda].size()-1 ; ++i ) { - out << this->land[lambda][i].first << " " << this->land[lambda][i].second << endl; + out << this->land[lambda][i].first << " " << this->land[lambda][i].second << std::endl; } - out << "EOF" << endl; + out << "EOF" << std::endl; } - cout << "Gnuplot script to visualize persistence diagram written to the file: " << nameStr << ". Type load '" << nameStr << "' in gnuplot to visualize." << endl; + std::cout << "Gnuplot script to visualize persistence diagram written to the file: " << nameStr << ". Type load '" << nameStr << "' in gnuplot to visualize." << std::endl; } diff --git a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape_on_grid.h b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape_on_grid.h index 6ac4deca..be60f858 100644 --- a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape_on_grid.h +++ b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape_on_grid.h @@ -1,7 +1,7 @@ /* This file is part of the Gudhi Library. The Gudhi library * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. - * + *h * Author(s): Pawel Dlotko * * Copyright (C) 2015 INRIA (France) @@ -37,14 +37,11 @@ //gudhi include -#include <gudhi/concretizations/read_persitence_from_file.h> +#include <gudhi/read_persitence_from_file.h> #include <gudhi/common_gudhi_stat.h> -using namespace std; - - namespace Gudhi { namespace Gudhi_stat @@ -68,17 +65,7 @@ public: * Constructor that takes as an input a vector of birth-death pairs. **/ Persistence_landscape_on_grid( const std::vector< std::pair< double , double > >& p , double grid_min_ , double grid_max_ , size_t number_of_points_ ); - - /** - * Assignement operator. - **/ - Persistence_landscape_on_grid& operator=( const Persistence_landscape_on_grid& org ); - - /** - * Copy constructor. - **/ - Persistence_landscape_on_grid(const Persistence_landscape_on_grid&); - + /** * Constructor that reads persistence intervals from file and creates persistence landscape. The format of the input file is the following: in each line we put birth-death pair. Last line is assumed * to be empty. Even if the points within a line are not ordered, they will be ordered while the input is read. The additional parameters of this procedure are: ranges of grid, resoltion of a grid @@ -133,9 +120,9 @@ public: if ( dbg ) { - cerr << "this->grid_max : " << this->grid_max << endl; - cerr << "this->grid_min : " << this->grid_min << endl; - cerr << "this->values_of_landscapes.size() : " << this->values_of_landscapes.size() << endl; + std::cerr << "this->grid_max : " << this->grid_max << std::endl; + std::cerr << "this->grid_min : " << this->grid_min << std::endl; + std::cerr << "this->values_of_landscapes.size() : " << this->values_of_landscapes.size() << std::endl; getchar(); } @@ -150,12 +137,12 @@ public: if ( dbg ) { - cerr << "this->values_of_landscapes[i].size() : " << this->values_of_landscapes[i].size() << " , level : " << level << endl; - if ( this->values_of_landscapes[i].size() > level )cerr << "this->values_of_landscapes[i][level] : " << this->values_of_landscapes[i][level] << endl; - cerr << "previous_y : " << previous_y << endl; - cerr << "current_y : " << current_y << endl; - cerr << "dx : " << dx << endl; - cerr << "0.5*dx*( previous_y + current_y ); " << 0.5*dx*( previous_y + current_y ) << endl; + std::cerr << "this->values_of_landscapes[i].size() : " << this->values_of_landscapes[i].size() << " , level : " << level << std::endl; + if ( this->values_of_landscapes[i].size() > level )std::cerr << "this->values_of_landscapes[i][level] : " << this->values_of_landscapes[i][level] << std::endl; + std::cerr << "previous_y : " << previous_y << std::endl; + std::cerr << "current_y : " << current_y << std::endl; + std::cerr << "dx : " << dx << std::endl; + std::cerr << "0.5*dx*( previous_y + current_y ); " << 0.5*dx*( previous_y + current_y ) << std::endl; } result += 0.5*dx*( previous_y + current_y ); @@ -194,10 +181,10 @@ public: if ( dbg ) { - cerr << "dx : " << dx << endl; - cerr << "previous_x : " << previous_x << endl; - cerr << "previous_y : " << previous_y << endl; - cerr << "power : " << p << endl; + std::cerr << "dx : " << dx << std::endl; + std::cerr << "previous_x : " << previous_x << std::endl; + std::cerr << "previous_y : " << previous_y << std::endl; + std::cerr << "power : " << p << std::endl; getchar(); } @@ -207,7 +194,7 @@ public: double current_y = 0; if ( this->values_of_landscapes[i].size() > level )current_y = this->values_of_landscapes[i][level]; - if ( dbg )cerr << "current_y : " << current_y << endl; + if ( dbg )std::cerr << "current_y : " << current_y << std::endl; if ( current_y == previous_y )continue; @@ -217,7 +204,7 @@ public: if ( dbg ) { - cerr << "A line passing through points : (" << previous_x << "," << previous_y << ") and (" << current_x << "," << current_y << ") is : " << a << "x+" << b << endl; + std::cerr << "A line passing through points : (" << previous_x << "," << previous_y << ") and (" << current_x << "," << current_y << ") is : " << a << "x+" << b << std::endl; } //In this interval, the landscape has a form f(x) = ax+b. We want to compute integral of (ax+b)^p = 1/a * (ax+b)^{p+1}/(p+1) @@ -233,14 +220,14 @@ public: result += value_to_add; if ( dbg ) { - cerr << "Increasing result by : " << value_to_add << endl; - cerr << "restult : " << result << endl; + std::cerr << "Increasing result by : " << value_to_add << std::endl; + std::cerr << "restult : " << result << std::endl; getchar(); } previous_x = current_x; previous_y = current_y; } - if ( dbg )cerr << "The total result is : " << result << endl; + if ( dbg )std::cerr << "The total result is : " << result << std::endl; return result; } @@ -259,7 +246,7 @@ public: { out << land.values_of_landscapes[i][j] << " "; } - out << endl; + out << std::endl; x += dx; } return out; @@ -282,9 +269,9 @@ public: if ( dbg ) { std::cerr << "This is a procedure compute_value_at_a_given_point \n"; - std::cerr << "level : " << level << endl; - std::cerr << "x : " << x << endl; - std::cerr << "psoition : " << position << endl; + std::cerr << "level : " << level << std::endl; + std::cerr << "x : " << x << std::endl; + std::cerr << "psoition : " << position << std::endl; } //check if we are not exacly in the grid point: if ( almost_equal( position*dx+ this->grid_min , x) ) @@ -430,17 +417,17 @@ public: bool dbg = true; if ( ! this->values_of_landscapes.size() == rhs.values_of_landscapes.size() ) { - if (dbg) cerr << "values_of_landscapes of incompatable sizes\n"; + if (dbg) std::cerr << "values_of_landscapes of incompatable sizes\n"; return false; } if ( !almost_equal( this->grid_min , rhs.grid_min ) ) { - if (dbg) cerr << "grid_min not equal\n"; + if (dbg) std::cerr << "grid_min not equal\n"; return false; } if ( !almost_equal(this->grid_max,rhs.grid_max ) ) { - if (dbg) cerr << "grid_max not equal\n"; + if (dbg) std::cerr << "grid_max not equal\n"; return false; } for ( size_t i = 0 ; i != this->values_of_landscapes.size() ; ++i ) @@ -451,8 +438,8 @@ public: { if (dbg) { - cerr << "Problem in the position : " << i << " of values_of_landscapes. \n"; - cerr << this->values_of_landscapes[i][aa] << " " << rhs.values_of_landscapes[i][aa] << endl; + std::cerr << "Problem in the position : " << i << " of values_of_landscapes. \n"; + std::cerr << this->values_of_landscapes[i][aa] << " " << rhs.values_of_landscapes[i][aa] << std::endl; } return false; } @@ -515,7 +502,7 @@ public: * This procedure returns x-range of a given level persistence landscape. If a default value is used, the x-range * of 0th level landscape is given (and this range contains the ranges of all other landscapes). **/ - std::pair< double , double > gimme_x_range( size_t level = 0 )const + std::pair< double , double > give_me_x_range( size_t level = 0 )const { return std::make_pair( this->grid_min , this->grid_max ); //std::pair< double , double > result; @@ -546,7 +533,7 @@ public: * This procedure returns y-range of a persistence landscape. If a default value is used, the y-range * of 0th level landscape is given (and this range contains the ranges of all other landscapes). **/ - std::pair< double , double > gimme_y_range( size_t level = 0 )const + std::pair< double , double > give_me_y_range( size_t level = 0 )const { return this->compute_minimum_maximum(); //std::pair< double , double > result; @@ -582,13 +569,13 @@ public: std::vector< std::pair< double , double > > p; Persistence_landscape_on_grid l(p,this->grid_min,this->grid_max,this->values_of_landscapes.size()-1); - if ( i != -1 ) + if ( i != std::numeric_limits<double>::max() ) { - return compute_discance_of_landscapes_on_grid(*this,l,i); + return compute_distance_of_landscapes_on_grid(*this,l,i); } else { - return compute_max_norm_discance_of_landscapes(*this,l); + return compute_max_norm_distance_of_landscapes(*this,l); } } @@ -600,8 +587,8 @@ public: /** * Computations of L^{\infty} distance between two landscapes. **/ - friend double compute_max_norm_discance_of_landscapes( const Persistence_landscape_on_grid& first, const Persistence_landscape_on_grid& second ); - //friend double compute_max_norm_discance_of_landscapes( const Persistence_landscape_on_grid& first, const Persistence_landscape_on_grid& second , unsigned& nrOfLand , double&x , double& y1, double& y2 ); + friend double compute_max_norm_distance_of_landscapes( const Persistence_landscape_on_grid& first, const Persistence_landscape_on_grid& second ); + //friend double compute_max_norm_distance_of_landscapes( const Persistence_landscape_on_grid& first, const Persistence_landscape_on_grid& second , unsigned& nrOfLand , double&x , double& y1, double& y2 ); @@ -611,8 +598,7 @@ public: * them. In this case, a general PL-function with negative value can appear as a result. Then in order to compute distance, we need to take its absolute value. This is the purpose of this procedure. **/ void abs() - { - //Be careful here. We assume that the functions are either entirely positive or negative. They do not change signs. That is why I can implemnt abs in the way presented below: + { for ( size_t i = 0 ; i != this->values_of_landscapes.size() ; ++i ) { for ( size_t j = 0 ; j != this->values_of_landscapes[i].size() ; ++j ) @@ -748,15 +734,15 @@ public: /** * Computations of L^{p} distance between two landscapes on a grid. p is the parameter of the procedure. **/ - friend double compute_discance_of_landscapes_on_grid( const Persistence_landscape_on_grid& first, const Persistence_landscape_on_grid& second , int p ) + friend double compute_distance_of_landscapes_on_grid( const Persistence_landscape_on_grid& first, const Persistence_landscape_on_grid& second , double p ) { bool dbg = false; //This is what we want to compute: (\int_{- \infty}^{+\infty}| first-second |^p)^(1/p). We will do it one step at a time: if ( dbg ) { - cerr << "first : " << first << endl; - cerr << "second : " << second << endl; + std::cerr << "first : " << first << std::endl; + std::cerr << "second : " << second << std::endl; getchar(); } @@ -765,7 +751,7 @@ public: if ( dbg ) { - cerr << "Difference : " << lan << endl; + std::cerr << "Difference : " << lan << std::endl; } //| first-second |: @@ -773,30 +759,30 @@ public: if ( dbg ) { - cerr << "Abs : " << lan << endl; + std::cerr << "Abs : " << lan << std::endl; } - if ( p != -1 ) + if ( p != std::numeric_limits< double >::max() ) { //\int_{- \infty}^{+\infty}| first-second |^p double result; if ( p != 1 ) { - if (dbg){cerr << "p : " << p << endl; getchar();} + if (dbg){std::cerr << "p : " << p << std::endl; getchar();} result = lan.compute_integral_of_landscape( (double)p ); - if (dbg){cerr << "integral : " << result << endl;getchar();} + if (dbg){std::cerr << "integral : " << result << std::endl;getchar();} } else { result = lan.compute_integral_of_landscape(); - if (dbg){cerr << "integral, wihtout power : " << result << endl;getchar();} + if (dbg){std::cerr << "integral, wihtout power : " << result << std::endl;getchar();} } //(\int_{- \infty}^{+\infty}| first-second |^p)^(1/p) return pow( result , 1/(double)p ); } else { - //p == -1 + //p == infty return lan.compute_maximum(); } } @@ -898,44 +884,44 @@ public: //now we need to check if the grids in all objects of to_average are the same: for ( size_t i = 0 ; i != to_average.size() ; ++i ) { - if ( !check_if_defined_on_the_same_domain(*((Persistence_landscape_on_grid*)(to_average[0])),*((Persistence_landscape_on_grid*)(to_average[i]))) )throw "Two grids are not compatible"; + if ( !check_if_defined_on_the_same_domain(*(to_average[0]),*(to_average[i])) )throw "Two grids are not compatible"; } - this->values_of_landscapes = std::vector< std::vector<double> >( ((Persistence_landscape_on_grid*)(to_average[0]))->values_of_landscapes.size() ); - this->grid_min = ((Persistence_landscape_on_grid*)(to_average[0]))->grid_min; - this->grid_max = ((Persistence_landscape_on_grid*)(to_average[0]))->grid_max; + this->values_of_landscapes = std::vector< std::vector<double> >( (to_average[0])->values_of_landscapes.size() ); + this->grid_min = (to_average[0])->grid_min; + this->grid_max = (to_average[0])->grid_max; if ( dbg ) { - cerr << "Computations of average. The data from the current landscape have been cleared. We are ready to do the computations. \n"; + std::cerr << "Computations of average. The data from the current landscape have been cleared. We are ready to do the computations. \n"; } //for every point in the grid: - for ( size_t grid_point = 0 ; grid_point != ((Persistence_landscape_on_grid*)(to_average[0]))->values_of_landscapes.size() ; ++grid_point ) + for ( size_t grid_point = 0 ; grid_point != (to_average[0])->values_of_landscapes.size() ; ++grid_point ) { //set up a vector of the correct size: size_t maximal_size_of_vector = 0; for ( size_t land_no = 0 ; land_no != to_average.size() ; ++land_no ) { - if ( ((Persistence_landscape_on_grid*)(to_average[land_no]))->values_of_landscapes[grid_point].size() > maximal_size_of_vector ) - maximal_size_of_vector = ((Persistence_landscape_on_grid*)(to_average[land_no]))->values_of_landscapes[grid_point].size(); + if ( (to_average[land_no])->values_of_landscapes[grid_point].size() > maximal_size_of_vector ) + maximal_size_of_vector = (to_average[land_no])->values_of_landscapes[grid_point].size(); } this->values_of_landscapes[grid_point] = std::vector<double>( maximal_size_of_vector ); if ( dbg ) { - cerr << "We are considering the point : " << grid_point << " of the grid. In this point, there are at most : " << maximal_size_of_vector << " nonzero landscape functions \n"; + std::cerr << "We are considering the point : " << grid_point << " of the grid. In this point, there are at most : " << maximal_size_of_vector << " nonzero landscape functions \n"; } //and compute an arythmetic average: for ( size_t land_no = 0 ; land_no != to_average.size() ; ++land_no ) { //summing: - for ( size_t i = 0 ; i != ((Persistence_landscape_on_grid*)(to_average[land_no]))->values_of_landscapes[grid_point].size() ; ++i ) + for ( size_t i = 0 ; i != (to_average[land_no])->values_of_landscapes[grid_point].size() ; ++i ) { //compute the average in a smarter way. - this->values_of_landscapes[grid_point][i] += ((Persistence_landscape_on_grid*)(to_average[land_no]))->values_of_landscapes[grid_point][i]; + this->values_of_landscapes[grid_point][i] += (to_average[land_no])->values_of_landscapes[grid_point][i]; } } //normalizing: @@ -951,16 +937,17 @@ public: * A function to compute distance between persistence landscape on a grid. * The parameter of this functionis a Persistence_landscape_on_grid. * This function is required in Topological_data_with_distances concept. + * For max norm distance, set power to std::numeric_limits<double>::max() **/ double distance( const Persistence_landscape_on_grid& second , double power = 1 )const { - if ( power != -1 ) + if ( power != std::numeric_limits<double>::max() ) { - return compute_discance_of_landscapes_on_grid( *this , second , power ); + return compute_distance_of_landscapes_on_grid( *this , second , power ); } else { - return compute_max_norm_discance_of_landscapes( *this , second ); + return compute_max_norm_distance_of_landscapes( *this , second ); } } @@ -1008,7 +995,7 @@ public: **/ void plot( const char* filename , size_t from_ , size_t to_ )const { - this->plot( filename , from_ , to_ ); + this->plot( filename , -1 , -1 , -1 , -1 , from_ , to_ ); } /** @@ -1042,12 +1029,12 @@ void Persistence_landscape_on_grid::set_up_values_of_landscapes( const std::vect bool dbg = false; if ( dbg ) { - std::cerr << "Here is the procedure : set_up_values_of_landscapes. The parameters are : grid_min_ : " << grid_min_ << ", grid_max_ : " << grid_max_ << ", number_of_points_ : " << number_of_points_ << endl; + std::cerr << "Here is the procedure : set_up_values_of_landscapes. The parameters are : grid_min_ : " << grid_min_ << ", grid_max_ : " << grid_max_ << ", number_of_points_ : " << number_of_points_ << std::endl; //getchar(); std::cerr << "Here are the intervals at our disposal : \n"; for ( size_t i = 0 ; i != p.size() ; ++i ) { - std::cerr << p[i].first << " , " << p[i].second << endl; + std::cerr << p[i].first << " , " << p[i].second << std::endl; } } @@ -1075,7 +1062,7 @@ void Persistence_landscape_on_grid::set_up_values_of_landscapes( const std::vect if ( dbg ) { - cerr << "Considering an interval : " << p[int_no].first << "," << p[int_no].second << endl; + std::cerr << "Considering an interval : " << p[int_no].first << "," << p[int_no].second << std::endl; std::cerr << "grid_interval_begin : " << grid_interval_begin << std::endl; std::cerr << "grid_interval_end : " << grid_interval_end << std::endl; @@ -1118,20 +1105,6 @@ Persistence_landscape_on_grid::Persistence_landscape_on_grid( const std::vector< this->set_up_values_of_landscapes( p , grid_min_ , grid_max_ , number_of_points_ ); }//Persistence_landscape_on_grid -Persistence_landscape_on_grid& Persistence_landscape_on_grid::operator=( const Persistence_landscape_on_grid& org ) -{ - this->grid_min = org.grid_min; - this->grid_max = org.grid_max; - this->values_of_landscapes = org.values_of_landscapes; - return (*this); -}//operator= - -Persistence_landscape_on_grid::Persistence_landscape_on_grid(const Persistence_landscape_on_grid& org) -{ - this->grid_min = org.grid_min; - this->grid_max = org.grid_max; - this->values_of_landscapes = org.values_of_landscapes; -}//copy constructor Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filename , double grid_min_, double grid_max_ , size_t number_of_points_ , size_t dimension ) { @@ -1165,7 +1138,7 @@ void Persistence_landscape_on_grid::load_landscape_from_file( const char* filena //check if the file exist. if ( !( access( filename, F_OK ) != -1 ) ) { - cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; + std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; } std::ifstream in; @@ -1183,7 +1156,7 @@ void Persistence_landscape_on_grid::load_landscape_from_file( const char* filena //read a line of a file and convert it to a vector. std::vector< double > vv; std::getline(in, line); - //cerr << "Reading line : " << line << endl;getchar(); + //std::cerr << "Reading line : " << line << std::endl;getchar(); std::istringstream stream(line); while (stream >> number) { @@ -1219,7 +1192,7 @@ void Persistence_landscape_on_grid::print_to_file( const char* filename )const void Persistence_landscape_on_grid::plot( const char* filename, double min_x , double max_x , double min_y , double max_y, size_t from_ , size_t to_ )const { //this program create a gnuplot script file that allows to plot persistence diagram. - ofstream out; + std::ofstream out; std::ostringstream nameSS; nameSS << filename << "_GnuplotScript"; @@ -1229,13 +1202,13 @@ void Persistence_landscape_on_grid::plot( const char* filename, double min_x , d if ( min_x == max_x ) { std::pair<double,double> min_max = compute_minimum_maximum(); - out << "set xrange [" << this->grid_min << " : " << this->grid_max << "]" << endl; - out << "set yrange [" << min_max.first << " : " << min_max.second << "]" << endl; + out << "set xrange [" << this->grid_min << " : " << this->grid_max << "]" << std::endl; + out << "set yrange [" << min_max.first << " : " << min_max.second << "]" << std::endl; } else { - out << "set xrange [" << min_x << " : " << max_x << "]" << endl; - out << "set yrange [" << min_y << " : " << max_y << "]" << endl; + out << "set xrange [" << min_x << " : " << max_x << "]" << std::endl; + out << "set yrange [" << min_y << " : " << max_y << "]" << std::endl; } size_t number_of_nonzero_levels = this->number_of_nonzero_levels(); @@ -1273,7 +1246,7 @@ void Persistence_landscape_on_grid::plot( const char* filename, double min_x , d { out << ", \\"; } - out << endl; + out << std::endl; } for ( size_t lambda = from ; lambda != to ; ++lambda ) @@ -1286,12 +1259,12 @@ void Persistence_landscape_on_grid::plot( const char* filename, double min_x , d { value = this->values_of_landscapes[i][lambda]; } - out << point << " " << value << endl; + out << point << " " << value << std::endl; point += dx; } - out << "EOF" << endl; + out << "EOF" << std::endl; } - cout << "Gnuplot script to visualize persistence diagram written to the file: " << nameStr << ". Type load '" << nameStr << "' in gnuplot to visualize." << endl; + std::cout << "Gnuplot script to visualize persistence diagram written to the file: " << nameStr << ". Type load '" << nameStr << "' in gnuplot to visualize." << std::endl; } template < typename T > @@ -1342,7 +1315,7 @@ Persistence_landscape_on_grid Persistence_landscape_on_grid::multiply_lanscape_b return result; } -double compute_max_norm_discance_of_landscapes( const Persistence_landscape_on_grid& first, const Persistence_landscape_on_grid& second ) +double compute_max_norm_distance_of_landscapes( const Persistence_landscape_on_grid& first, const Persistence_landscape_on_grid& second ) { double result = 0; diff --git a/src/Gudhi_stat/include/gudhi/concretizations/Vector_distances_in_diagram.h b/src/Gudhi_stat/include/gudhi/concretizations/Vector_distances_in_diagram.h index 11e4b163..dc1df0c6 100644 --- a/src/Gudhi_stat/include/gudhi/concretizations/Vector_distances_in_diagram.h +++ b/src/Gudhi_stat/include/gudhi/concretizations/Vector_distances_in_diagram.h @@ -31,10 +31,9 @@ #include <limits> //gudhi include -#include <gudhi/concretizations/read_persitence_from_file.h> +#include <gudhi/read_persitence_from_file.h> #include <gudhi/common_gudhi_stat.h> -using namespace std; namespace Gudhi { @@ -104,22 +103,12 @@ public: **/ Vector_distances_in_diagram( const char* filename , size_t where_to_cut ); - /** - * Assignement operator. - **/ - Vector_distances_in_diagram<F>& operator =( const Vector_distances_in_diagram& org ); - - - /** - * Copy constructor. - **/ - Vector_distances_in_diagram( const Vector_distances_in_diagram& org ); /** * Writing to a stream. **/ template <typename K> - friend ostream& operator << ( ostream& out , const Vector_distances_in_diagram<K>& d ) + friend std::ostream& operator << ( std::ostream& out , const Vector_distances_in_diagram<K>& d ) { for ( size_t i = 0 ; i != std::min( d.sorted_vector_of_distances.size() , d.where_to_cut) ; ++i ) { @@ -213,6 +202,7 @@ public: /** * Compute a distance of two persistent vectors. This function is required in Topological_data_with_distances concept. + * For max norm distance, set power to std::numeric_limits<double>::max() **/ double distance( const Vector_distances_in_diagram& second , double power = 1)const; @@ -255,7 +245,7 @@ public: { std::stringstream gnuplot_script; gnuplot_script << filename << "_GnuplotScript"; - ofstream out; + std::ofstream out; out.open( gnuplot_script.str().c_str() ); out << "set style data histogram" << std::endl; out << "set style histogram cluster gap 1" << std::endl; @@ -265,7 +255,7 @@ public: { out << this->sorted_vector_of_distances[i] << std::endl; } - out << endl; + out <<std::endl; out.close(); std::cout << "To vizualize, open gnuplot and type: load \'" << gnuplot_script.str().c_str() << "\'" << std::endl; } @@ -273,7 +263,7 @@ public: /** * The x-range of the persistence vector. **/ - std::pair< double , double > gimme_x_range()const + std::pair< double , double > give_me_x_range()const { return std::make_pair( 0 , this->sorted_vector_of_distances.size() ); } @@ -281,7 +271,7 @@ public: /** * The y-range of the persistence vector. **/ - std::pair< double , double > gimme_y_range()const + std::pair< double , double > give_me_y_range()const { if ( this->sorted_vector_of_distances.size() == 0 )return std::make_pair(0,0); return std::make_pair( this->sorted_vector_of_distances[0] , 0); @@ -441,28 +431,6 @@ Vector_distances_in_diagram<F>::Vector_distances_in_diagram( const std::vector< } template <typename F> -Vector_distances_in_diagram<F>::Vector_distances_in_diagram( const Vector_distances_in_diagram<F>& org ) -{ - std::vector< std::pair< double,double > > inter( org.intervals ); - this->intervals = inter; - std::vector< double > sorted_vector_of_distances( org.sorted_vector_of_distances ); - this->sorted_vector_of_distances = sorted_vector_of_distances; - set_up_numbers_of_functions_for_vectorization_and_projections_to_reals(); -} - - -template <typename F> -Vector_distances_in_diagram<F>& Vector_distances_in_diagram<F>::operator =( const Vector_distances_in_diagram& org ) -{ - std::vector< std::pair< double , double > > inter( org.intervals ); - this->intervals = inter; - std::vector< double > sorted_vector_of_distances( org.sorted_vector_of_distances ); - this->sorted_vector_of_distances = sorted_vector_of_distances; - return *this; -} - - -template <typename F> Vector_distances_in_diagram<F>::Vector_distances_in_diagram( const char* filename , size_t where_to_cut ):where_to_cut(where_to_cut) { //standard file with barcode @@ -483,10 +451,10 @@ void Vector_distances_in_diagram<F>::compute_sorted_vector_of_distances_via_heap bool dbg = false; if ( dbg ) { - cerr << "Here are the intervals : \n"; + std::cerr << "Here are the intervals : \n"; for ( size_t i = 0 ; i != this->intervals.size() ; ++i ) { - cerr << this->intervals[i].first << " , " << this->intervals[i].second << endl; + std::cerr << this->intervals[i].first << " , " << this->intervals[i].second <<std::endl; } } where_to_cut = std::min(where_to_cut , (size_t)(0.5 * this->intervals.size() * ( this->intervals.size() - 1 ) + this->intervals.size())); @@ -510,14 +478,14 @@ void Vector_distances_in_diagram<F>::compute_sorted_vector_of_distances_via_heap if ( dbg ) { - cerr << "Value : " << value << endl; - cerr << "heap.front() : " << heap.front() << endl; + std::cerr << "Value : " << value <<std::endl; + std::cerr << "heap.front() : " << heap.front() <<std::endl; getchar(); } if ( -value < heap.front() ) { - if ( dbg ){cerr << "Replacing : " << heap.front() << " with : " << -value << endl;getchar();} + if ( dbg ){std::cerr << "Replacing : " << heap.front() << " with : " << -value <<std::endl;getchar();} //remove the first element from the heap std::pop_heap (heap.begin(),heap.end()); //heap.pop_back(); @@ -535,7 +503,7 @@ void Vector_distances_in_diagram<F>::compute_sorted_vector_of_distances_via_heap double value = f( this->intervals[i] , std::make_pair( 0.5*(this->intervals[i].first+this->intervals[i].second) , 0.5*(this->intervals[i].first+this->intervals[i].second) ) ); if ( -value < heap.front() ) { - //cerr << "Replacing : " << heap.front() << " with : " << -value << endl;getchar(); + //std::cerr << "Replacing : " << heap.front() << " with : " << -value <<std::endl;getchar(); //remove the first element from the heap std::pop_heap (heap.begin(),heap.end()); //heap.pop_back(); @@ -567,7 +535,7 @@ void Vector_distances_in_diagram<F>::compute_sorted_vector_of_distances_via_heap { std::cout << heap[i] << " "; } - std::cout << endl; + std::cout <<std::endl; } this->sorted_vector_of_distances = heap; @@ -681,16 +649,24 @@ double Vector_distances_in_diagram<F>::distance( const Vector_distances_in_diagr { if ( dbg ) { - cerr << "|" << this->sorted_vector_of_distances[i] << " - " << second_.sorted_vector_of_distances[i] << " | : " << fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ) << endl; + std::cerr << "|" << this->sorted_vector_of_distances[i] << " - " << second_.sorted_vector_of_distances[i] << " | : " << fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ) <<std::endl; } result += fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ); } else { - result += std::pow( fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ) , power ); + if ( power != std::numeric_limits<double>::max() ) + { + result += std::pow( fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ) , power ); + } + else + { + //nax morm + if ( result < fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ) )result = fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ); + } if ( dbg ) { - cerr << "| " << this->sorted_vector_of_distances[i] << " - " << second_.sorted_vector_of_distances[i] << " : " << fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ) << endl; + std::cerr << "| " << this->sorted_vector_of_distances[i] << " - " << second_.sorted_vector_of_distances[i] << " : " << fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ) <<std::endl; } } } @@ -756,7 +732,7 @@ void Vector_distances_in_diagram<F>::load_from_file( const char* filename ) //check if the file exist. if ( !( access( filename, F_OK ) != -1 ) ) { - cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; + std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; } std::ifstream in; diff --git a/src/Gudhi_stat/include/gudhi/fill_in_missing_data.h b/src/Gudhi_stat/include/gudhi/fill_in_missing_data.h index eb948438..d6ae6fe1 100644 --- a/src/Gudhi_stat/include/gudhi/fill_in_missing_data.h +++ b/src/Gudhi_stat/include/gudhi/fill_in_missing_data.h @@ -23,6 +23,11 @@ #ifndef FILL_IN_MISSING_DATA_H #define FILL_IN_MISSING_DATA_H +namespace Gudhi +{ +namespace Gudhi_stat +{ + /** * Quite often in biological sciences we are facing a problem of missing data. We may have for instance a number of sequences of observations made in between times A and B in a discrete * collection of times A = t1, t2,...,tn = B. But quite typically some of the observations may be missing. Then quite often it is hard to estimate the values in the missing times. @@ -133,4 +138,7 @@ void fill_in_missing_data( std::vector< Representation_of_topology* >& data , st } }//fill_in_missing_data +}//namespace Gudhi_stat +}//namespace Gudhi + #endif diff --git a/src/Gudhi_stat/include/gudhi/multiplicative_bootstrap.h b/src/Gudhi_stat/include/gudhi/multiplicative_bootstrap.h index daac8f2a..627923fe 100644 --- a/src/Gudhi_stat/include/gudhi/multiplicative_bootstrap.h +++ b/src/Gudhi_stat/include/gudhi/multiplicative_bootstrap.h @@ -39,6 +39,11 @@ #include <random> #include <ctime> +namespace Gudhi +{ +namespace Gudhi_stat +{ + template < typename TopologicalObject > class difference_of_objects { @@ -138,6 +143,9 @@ double multiplicative_bootstrap( const std::vector< TopologicalObject* >& topolo return result; -}//bootstrap +}//multiplicative_bootstrap + +}//namespace Gudhi_stat +}//namespace Gudhi #endif diff --git a/src/Gudhi_stat/include/gudhi/permutation_test.h b/src/Gudhi_stat/include/gudhi/permutation_test.h index 7f8f7552..fa31c3c0 100644 --- a/src/Gudhi_stat/include/gudhi/permutation_test.h +++ b/src/Gudhi_stat/include/gudhi/permutation_test.h @@ -29,7 +29,7 @@ #include <iostream> #include <cstdlib> #include <algorithm> -#include <gudhi/concretizations/read_persitence_from_file.h> +#include <gudhi/read_persitence_from_file.h> using namespace std; diff --git a/src/Gudhi_stat/include/gudhi/concretizations/read_persitence_from_file.h b/src/Gudhi_stat/include/gudhi/read_persitence_from_file.h index e16c1f20..e16c1f20 100644 --- a/src/Gudhi_stat/include/gudhi/concretizations/read_persitence_from_file.h +++ b/src/Gudhi_stat/include/gudhi/read_persitence_from_file.h diff --git a/src/Gudhi_stat/include/gudhi/topological_process.h b/src/Gudhi_stat/include/gudhi/topological_process.h index e7bd46de..0cd8670a 100644 --- a/src/Gudhi_stat/include/gudhi/topological_process.h +++ b/src/Gudhi_stat/include/gudhi/topological_process.h @@ -218,22 +218,6 @@ public: delete this->data[i]; } } - Topological_process( const Topological_process& org ) - { - this->data = std::vector< Representation* >( org.data.size() ); - for ( size_t i = 0 ; i != org.data.size() ; ++i ) - { - this->data[i] = new Representation( *org.data[i] ); - } - } - Topological_process& operator = ( const Topological_process& rhs ) - { - for ( size_t i = 0 ; i != rhs.data.size() ; ++i ) - { - this->data[i] = new Representation( *rhs.data[i] ); - } - return *this; - } Topological_process( const std::vector< Representation* >& data_ ):data(data_){} double distance( const Topological_process& second , double exponent = 1 ) @@ -281,26 +265,26 @@ public: } } - std::pair< double , double > gimme_x_range()const + std::pair< double , double > give_me_x_range()const { double min_x = std::numeric_limits< double >::max(); double max_x = -std::numeric_limits< double >::max(); for ( size_t i = 0 ; i != this->data.size() ; ++i ) { - std::pair< double , double > xrange = this->data[i]->gimme_x_range(); + std::pair< double , double > xrange = this->data[i]->give_me_x_range(); if ( min_x > xrange.first )min_x = xrange.first; if ( max_x < xrange.second )max_x = xrange.second; } return std::make_pair( min_x , max_x ); } - std::pair< double , double > gimme_y_range()const + std::pair< double , double > give_me_y_range()const { double min_y = std::numeric_limits< double >::max(); double max_y = -std::numeric_limits< double >::max(); for ( size_t i = 0 ; i != this->data.size() ; ++i ) { - std::pair< double , double > yrange = this->data[i]->gimme_y_range(); + std::pair< double , double > yrange = this->data[i]->give_me_y_range(); if ( min_y > yrange.first )min_y = yrange.first; if ( max_y < yrange.second )max_y = yrange.second; } @@ -313,11 +297,11 @@ public: bool are_the_data_aligned()const { if ( this->data.size() == 0 )return true;//empty collection is aligned - std::pair< double , double > x_range = this->data[0]->gimme_x_range(); - std::pair< double , double > y_range = this->data[0]->gimme_y_range(); + std::pair< double , double > x_range = this->data[0]->give_me_x_range(); + std::pair< double , double > y_range = this->data[0]->give_me_y_range(); for ( size_t i = 1 ; i != this->data.size() ; ++i ) { - if ( (x_range != this->data[i]->gimme_x_range()) || (y_range != this->data[i]->gimme_y_range()) ) + if ( (x_range != this->data[i]->give_me_x_range()) || (y_range != this->data[i]->give_me_y_range()) ) { return false; } @@ -358,7 +342,7 @@ public: std::stringstream gif_gnuplot_script_file_name; gif_gnuplot_script_file_name << filename << "_gif_gnuplot_script"; - ofstream out; + std::ofstream out; out.open( gif_gnuplot_script_file_name.str().c_str() ); out << "set terminal gif animate delay " << delay << std::endl; out << "set output '" << gif_file_name.str() << "'" << std::endl; @@ -378,7 +362,7 @@ public: }//plot - std::vector< Representation* > gimme_data(){return this->data;} + std::vector< Representation* > give_me_data(){return this->data;} private: std::vector< Representation* > data; }; |