A class implementing persistence landscapes by approximating them on a collection of grid points. More...
Public Member Functions | |
Persistence_landscape_on_grid () | |
Persistence_landscape_on_grid (const std::vector< std::pair< double, double > > &p, double grid_min_, double grid_max_, size_t number_of_points_) | |
Persistence_landscape_on_grid (const std::vector< std::pair< double, double > > &p, double grid_min_, double grid_max_, size_t number_of_points_, unsigned number_of_levels_of_landscape) | |
Persistence_landscape_on_grid (const char *filename, double grid_min_, double grid_max_, size_t number_of_points_, unsigned number_of_levels_of_landscape, uint16_t dimension_=std::numeric_limits< uint16_t >::max()) | |
Persistence_landscape_on_grid (const char *filename, double grid_min_, double grid_max_, size_t number_of_points_, uint16_t dimension_=std::numeric_limits< uint16_t >::max()) | |
Persistence_landscape_on_grid (const char *filename, size_t number_of_points, unsigned number_of_levels_of_landscape, uint16_t dimension=std::numeric_limits< uint16_t >::max()) | |
Persistence_landscape_on_grid (const char *filename, size_t number_of_points, uint16_t dimension=std::numeric_limits< uint16_t >::max()) | |
void | load_landscape_from_file (const char *filename) |
void | print_to_file (const char *filename) const |
double | compute_integral_of_landscape () const |
double | compute_integral_of_landscape (size_t level) const |
double | compute_integral_of_landscape (double p) const |
double | compute_integral_of_landscape (double p, size_t level) const |
double | compute_value_at_a_given_point (unsigned level, double x) const |
Persistence_landscape_on_grid | operator+= (const Persistence_landscape_on_grid &rhs) |
Persistence_landscape_on_grid | operator-= (const Persistence_landscape_on_grid &rhs) |
Persistence_landscape_on_grid | operator*= (double x) |
Persistence_landscape_on_grid | operator/= (double x) |
bool | operator== (const Persistence_landscape_on_grid &rhs) const |
bool | operator!= (const Persistence_landscape_on_grid &rhs) const |
double | compute_maximum () const |
std::pair< double, double > | compute_minimum_maximum () const |
std::pair< double, double > | get_x_range (size_t level=0) const |
std::pair< double, double > | get_y_range (size_t level=0) const |
size_t | number_of_nonzero_levels () const |
double | compute_norm_of_landscape (double i) const |
double | operator() (unsigned level, double x) const |
void | abs () |
size_t | size () const |
double | find_max (unsigned lambda) const |
double | project_to_R (int number_of_function) const |
size_t | number_of_projections_to_R () const |
std::vector< double > | vectorize (int number_of_function) const |
size_t | number_of_vectorize_functions () const |
void | compute_average (const std::vector< Persistence_landscape_on_grid * > &to_average) |
double | distance (const Persistence_landscape_on_grid &second, double power=1) const |
double | compute_scalar_product (const Persistence_landscape_on_grid &second) |
std::vector< std::vector< double > > | output_for_visualization () const |
void | plot (const char *filename, size_t from_, size_t to_) const |
void | plot (const char *filename, double min_x=std::numeric_limits< double >::max(), double max_x=std::numeric_limits< double >::max(), double min_y=std::numeric_limits< double >::max(), double max_y=std::numeric_limits< double >::max(), size_t from_=std::numeric_limits< size_t >::max(), size_t to_=std::numeric_limits< size_t >::max()) const |
A class implementing persistence landscapes by approximating them on a collection of grid points.
Persistence landscapes on grid allows vectorization, computations of distances, computations of projections to Real, computations of averages and scalar products. Therefore they implement suitable interfaces. It implements the following concepts: Vectorized_topological_data, Topological_data_with_distances, Real_valued_topological_data, Topological_data_with_averages, Topological_data_with_scalar_product
Note that at the moment, due to rounding errors during the construction of persistence landscapes on a grid, elements which are different by 0.000005 are considered the same. If the scale in your persistence diagrams is comparable to this value, please rescale them before use this code.
|
inline |
Default constructor.
Gudhi::Persistence_representations::Persistence_landscape_on_grid::Persistence_landscape_on_grid | ( | const std::vector< std::pair< double, double > > & | p, |
double | grid_min_, | ||
double | grid_max_, | ||
size_t | number_of_points_ | ||
) |
Constructor that takes as an input a vector of birth-death pairs.
Gudhi::Persistence_representations::Persistence_landscape_on_grid::Persistence_landscape_on_grid | ( | const std::vector< std::pair< double, double > > & | p, |
double | grid_min_, | ||
double | grid_max_, | ||
size_t | number_of_points_, | ||
unsigned | number_of_levels_of_landscape | ||
) |
Constructor that takes as an input a vector of birth-death pairs, parameters of the grid and number of
landscape function to be created.
Gudhi::Persistence_representations::Persistence_landscape_on_grid::Persistence_landscape_on_grid | ( | const char * | filename, |
double | grid_min_, | ||
double | grid_max_, | ||
size_t | number_of_points_, | ||
unsigned | number_of_levels_of_landscape, | ||
uint16_t | dimension_ = std::numeric_limits<uint16_t>::max() |
||
) |
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, resolution of a grid number of landscape functions to be created and the dimension of intervals that are need to be read from a file (in case of Gudhi format files).
Gudhi::Persistence_representations::Persistence_landscape_on_grid::Persistence_landscape_on_grid | ( | const char * | filename, |
double | grid_min_, | ||
double | grid_max_, | ||
size_t | number_of_points_, | ||
uint16_t | dimension_ = std::numeric_limits<uint16_t>::max() |
||
) |
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, resolution of a grid and the dimension of intervals that are need to be read from a file (in case of Gudhi format files).
Gudhi::Persistence_representations::Persistence_landscape_on_grid::Persistence_landscape_on_grid | ( | const char * | filename, |
size_t | number_of_points, | ||
unsigned | number_of_levels_of_landscape, | ||
uint16_t | dimension = std::numeric_limits<uint16_t>::max() |
||
) |
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 parameter is the resolution of a grid and the number of landscape functions to be created. The remaining parameters are calculated based on data.
Gudhi::Persistence_representations::Persistence_landscape_on_grid::Persistence_landscape_on_grid | ( | const char * | filename, |
size_t | number_of_points, | ||
uint16_t | dimension = std::numeric_limits<uint16_t>::max() |
||
) |
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 parameter is the resolution of a grid. The last parameter is the dimension of a persistence to read from the file. If your file contains only persistence pair in a single dimension, please set it up to std::numeric_limits<unsigned>::max(). The remaining parameters are calculated based on data.
|
inline |
Function to compute absolute value of a PL function. The representation of persistence landscapes allow to store general PL-function. When computing distance between two landscapes, we compute difference between 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.
|
inline |
A function to compute averaged persistence landscape on a grid, based on vector of persistence landscapes on grid. This function is required by Topological_data_with_averages concept.
|
inline |
This function compute integral of the landscape (defined formally as sum of integrals on R of all landscape functions)
|
inline |
This function compute integral of the landscape p-th power of a landscape (defined formally as sum of integrals on R of p-th powers of all landscape functions)
|
inline |
This function compute integral of the landscape p-th power of a level of a landscape (defined formally as sum
of integrals on R of p-th powers of all landscape functions)
|
inline |
This function compute integral of the 'level'-level of a landscape.
|
inline |
Computations of maximum (y) value of landscape.
|
inline |
Computations of minimum and maximum value of landscape.
|
inline |
Computations of a \(L^i\) norm of landscape, where i is the input parameter.
|
inline |
A function to compute scalar product of persistence landscape on a grid. The parameter of this function is a Persistence_landscape_on_grid. This function is required in Topological_data_with_scalar_product concept.
|
inline |
A function that computes the value of a landscape at a given point. The parameters of the function are: unsigned level and double x. The procedure will compute the value of the level-landscape at the point x.
|
inline |
A function to compute distance between persistence landscape on a grid. The parameter of this function is 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()
|
inline |
Compute maximal value of lambda-level landscape.
|
inline |
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).
|
inline |
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).
void Gudhi::Persistence_representations::Persistence_landscape_on_grid::load_landscape_from_file | ( | const char * | filename | ) |
This procedure loads a landscape from file. It erase all the data that was previously stored in this landscape.
|
inline |
This function computes maximal lambda for which lambda-level landscape is nonzero.
|
inline |
The function gives the number of possible projections to R. This function is required by the Real_valued_topological_data concept.
|
inline |
This function return the number of functions that allows vectorization of persistence landscape. It is required in a concept Vectorized_topological_data.
|
inline |
An operator to compare two persistence landscapes.
|
inline |
An operator to compute the value of a landscape in the level 'level' at the argument 'x'.
|
inline |
Operator *=. The second parameter is a real number by which the y values of all landscape functions are multiplied. The x-values remain unchanged.
|
inline |
Operator +=. The second parameter is persistence landscape.
|
inline |
Operator -=. The second parameter is persistence landscape.
|
inline |
Operator /=. The second parameter is a real number.
|
inline |
An operator to compare two persistence landscapes.
|
inline |
A function that returns values of landscapes. It can be used for visualization
void Gudhi::Persistence_representations::Persistence_landscape_on_grid::plot | ( | const char * | filename, |
double | min_x = std::numeric_limits<double>::max() , |
||
double | max_x = std::numeric_limits<double>::max() , |
||
double | min_y = std::numeric_limits<double>::max() , |
||
double | max_y = std::numeric_limits<double>::max() , |
||
size_t | from_ = std::numeric_limits<size_t>::max() , |
||
size_t | to_ = std::numeric_limits<size_t>::max() |
||
) | const |
function used to create a gnuplot script for visualization of landscapes. Over here we can restrict also x and y range of the landscape.
|
inline |
function used to create a gnuplot script for visualization of landscapes. Over here we need to specify which landscapes do we want to plot. In addition, the user may specify the range (min and max) where landscape is plot. The default values for min and max are std::numeric_limits<double>::max(). If the procedure detect those values, it will determine the range so that the whole landscape is supported there. If at least one min or max value is different from std::numeric_limits<double>::max(), then the values provided by the user will be used.
void Gudhi::Persistence_representations::Persistence_landscape_on_grid::print_to_file | ( | const char * | filename | ) | const |
The procedure stores a landscape to a file. The file can be later used by a procedure load_landscape_from_file.
|
inline |
The number of projections to R is defined to the number of nonzero landscape functions. I-th projection is an integral of i-th landscape function over whole R. This function is required by the Real_valued_topological_data concept. At the moment this function is not tested, since it is quite likely to be changed in the future. Given this, when using it, keep in mind that it will be most likely changed in the next versions.
|
inline |
Computes the number of landscape functions.
|
inline |
This function produce a vector of doubles based on a landscape. It is required in a concept Vectorized_topological_data
|
friend |
A function that compute sum of two landscapes.
|
friend |
Computations of \(L^{p}\) distance between two landscapes on a grid. p is the parameter of the procedure. FIXME: Note that, due to the grid representation, the method below may give non–accurate results in case when the landscape P and Q the difference of which we want to compute are intersecting. This is a consequence of a general way they are computed. In the future, an integral of absolute value of a difference of P and Q will be given as a separated function to fix that inaccuracy.
|
friend |
Function to compute inner (scalar) product of two landscapes.
|
friend |
Function to compute inner (scalar) product of given levels of two landscapes.
|
friend |
Computations of \(L^{\infty}\) distance between two landscapes.
|
friend |
An operator * that allows multiplication of a landscape by a real number.
|
friend |
An operator * that allows multiplication of a landscape by a real number (order of parameters swapped).
|
friend |
An operator +, that compute sum of two landscapes.
|
friend |
An operator -, that compute difference of two landscapes.
|
friend |
Writing landscape into a stream. A i-th level landscape starts with a string "lambda_i". Then the discontinuity points of the landscapes follows. Shall those points be joined with lines, we will obtain the i-th landscape function.
|
friend |
A function that compute difference of two landscapes.