Gudhi::Persistence_representations::Persistence_landscape_on_grid Class Reference

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
 

Friends

std::ostream & operator<< (std::ostream &out, const Persistence_landscape_on_grid &land)
 
Persistence_landscape_on_grid add_two_landscapes (const Persistence_landscape_on_grid &land1, const Persistence_landscape_on_grid &land2)
 
Persistence_landscape_on_grid subtract_two_landscapes (const Persistence_landscape_on_grid &land1, const Persistence_landscape_on_grid &land2)
 
Persistence_landscape_on_grid operator+ (const Persistence_landscape_on_grid &first, const Persistence_landscape_on_grid &second)
 
Persistence_landscape_on_grid operator- (const Persistence_landscape_on_grid &first, const Persistence_landscape_on_grid &second)
 
Persistence_landscape_on_grid operator* (const Persistence_landscape_on_grid &first, double con)
 
Persistence_landscape_on_grid operator* (double con, const Persistence_landscape_on_grid &first)
 
double compute_max_norm_distance_of_landscapes (const Persistence_landscape_on_grid &first, const Persistence_landscape_on_grid &second)
 
double compute_inner_product (const Persistence_landscape_on_grid &l1, const Persistence_landscape_on_grid &l2)
 
double compute_inner_product (const Persistence_landscape_on_grid &l1, const Persistence_landscape_on_grid &l2, size_t level)
 
double compute_distance_of_landscapes_on_grid (const Persistence_landscape_on_grid &first, const Persistence_landscape_on_grid &second, double p)
 

Detailed Description

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.

Examples:
Persistence_representations/persistence_landscape_on_grid.cpp, Persistence_representations/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp, Persistence_representations/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp, Persistence_representations/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp, Persistence_representations/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp, and Persistence_representations/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp.

Constructor & Destructor Documentation

◆ Persistence_landscape_on_grid() [1/7]

Gudhi::Persistence_representations::Persistence_landscape_on_grid::Persistence_landscape_on_grid ( )
inline

Default constructor.

◆ Persistence_landscape_on_grid() [2/7]

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.

◆ Persistence_landscape_on_grid() [3/7]

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.

◆ Persistence_landscape_on_grid() [4/7]

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).

◆ Persistence_landscape_on_grid() [5/7]

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).

◆ Persistence_landscape_on_grid() [6/7]

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.

◆ Persistence_landscape_on_grid() [7/7]

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.

Member Function Documentation

◆ abs()

void Gudhi::Persistence_representations::Persistence_landscape_on_grid::abs ( )
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.

◆ compute_average()

void Gudhi::Persistence_representations::Persistence_landscape_on_grid::compute_average ( const std::vector< Persistence_landscape_on_grid *> &  to_average)
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.

Examples:
Persistence_representations/persistence_landscape_on_grid.cpp, and Persistence_representations/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp.

◆ compute_integral_of_landscape() [1/4]

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::compute_integral_of_landscape ( ) const
inline

This function compute integral of the landscape (defined formally as sum of integrals on R of all landscape functions)

Examples:
Persistence_representations/persistence_landscape_on_grid.cpp.

◆ compute_integral_of_landscape() [2/4]

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::compute_integral_of_landscape ( size_t  level) const
inline

This function compute integral of the 'level'-level of a landscape.

◆ compute_integral_of_landscape() [3/4]

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::compute_integral_of_landscape ( double  p) const
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)

◆ compute_integral_of_landscape() [4/4]

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::compute_integral_of_landscape ( double  p,
size_t  level 
) const
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)

◆ compute_maximum()

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::compute_maximum ( ) const
inline

Computations of maximum (y) value of landscape.

Examples:
Persistence_representations/persistence_landscape_on_grid.cpp.

◆ compute_minimum_maximum()

std::pair<double, double> Gudhi::Persistence_representations::Persistence_landscape_on_grid::compute_minimum_maximum ( ) const
inline

Computations of minimum and maximum value of landscape.

◆ compute_norm_of_landscape()

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::compute_norm_of_landscape ( double  i) const
inline

Computations of a \(L^i\) norm of landscape, where i is the input parameter.

Examples:
Persistence_representations/persistence_landscape_on_grid.cpp.

◆ compute_scalar_product()

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::compute_scalar_product ( const Persistence_landscape_on_grid second)
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.

Examples:
Persistence_representations/persistence_landscape_on_grid.cpp.

◆ compute_value_at_a_given_point()

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::compute_value_at_a_given_point ( unsigned  level,
double  x 
) const
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.

◆ distance()

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::distance ( const Persistence_landscape_on_grid second,
double  power = 1 
) const
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()

Examples:
Persistence_representations/persistence_landscape_on_grid.cpp.

◆ find_max()

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::find_max ( unsigned  lambda) const
inline

Compute maximal value of lambda-level landscape.

◆ get_x_range()

std::pair<double, double> Gudhi::Persistence_representations::Persistence_landscape_on_grid::get_x_range ( size_t  level = 0) const
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).

◆ get_y_range()

std::pair<double, double> Gudhi::Persistence_representations::Persistence_landscape_on_grid::get_y_range ( size_t  level = 0) const
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).

◆ load_landscape_from_file()

void Gudhi::Persistence_representations::Persistence_landscape_on_grid::load_landscape_from_file ( const char *  filename)

◆ number_of_nonzero_levels()

size_t Gudhi::Persistence_representations::Persistence_landscape_on_grid::number_of_nonzero_levels ( ) const
inline

This function computes maximal lambda for which lambda-level landscape is nonzero.

◆ number_of_projections_to_R()

size_t Gudhi::Persistence_representations::Persistence_landscape_on_grid::number_of_projections_to_R ( ) const
inline

The function gives the number of possible projections to R. This function is required by the Real_valued_topological_data concept.

◆ number_of_vectorize_functions()

size_t Gudhi::Persistence_representations::Persistence_landscape_on_grid::number_of_vectorize_functions ( ) const
inline

This function return the number of functions that allows vectorization of persistence landscape. It is required in a concept Vectorized_topological_data.

◆ operator!=()

bool Gudhi::Persistence_representations::Persistence_landscape_on_grid::operator!= ( const Persistence_landscape_on_grid rhs) const
inline

An operator to compare two persistence landscapes.

◆ operator()()

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::operator() ( unsigned  level,
double  x 
) const
inline

An operator to compute the value of a landscape in the level 'level' at the argument 'x'.

◆ operator*=()

Persistence_landscape_on_grid Gudhi::Persistence_representations::Persistence_landscape_on_grid::operator*= ( double  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.

◆ operator+=()

Persistence_landscape_on_grid Gudhi::Persistence_representations::Persistence_landscape_on_grid::operator+= ( const Persistence_landscape_on_grid rhs)
inline

Operator +=. The second parameter is persistence landscape.

◆ operator-=()

Persistence_landscape_on_grid Gudhi::Persistence_representations::Persistence_landscape_on_grid::operator-= ( const Persistence_landscape_on_grid rhs)
inline

Operator -=. The second parameter is persistence landscape.

◆ operator/=()

Persistence_landscape_on_grid Gudhi::Persistence_representations::Persistence_landscape_on_grid::operator/= ( double  x)
inline

Operator /=. The second parameter is a real number.

◆ operator==()

bool Gudhi::Persistence_representations::Persistence_landscape_on_grid::operator== ( const Persistence_landscape_on_grid rhs) const
inline

An operator to compare two persistence landscapes.

◆ output_for_visualization()

std::vector<std::vector<double> > Gudhi::Persistence_representations::Persistence_landscape_on_grid::output_for_visualization ( ) const
inline

A function that returns values of landscapes. It can be used for visualization

◆ plot() [1/2]

void Gudhi::Persistence_representations::Persistence_landscape_on_grid::plot ( const char *  filename,
size_t  from_,
size_t  to_ 
) const
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.

Examples:
Persistence_representations/persistence_landscape_on_grid.cpp, and Persistence_representations/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp.

◆ plot() [2/2]

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.

◆ print_to_file()

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.

Examples:
Persistence_representations/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp, and Persistence_representations/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp.

◆ project_to_R()

double Gudhi::Persistence_representations::Persistence_landscape_on_grid::project_to_R ( int  number_of_function) const
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.

◆ size()

size_t Gudhi::Persistence_representations::Persistence_landscape_on_grid::size ( ) const
inline

Computes the number of landscape functions.

◆ vectorize()

std::vector<double> Gudhi::Persistence_representations::Persistence_landscape_on_grid::vectorize ( int  number_of_function) const
inline

This function produce a vector of doubles based on a landscape. It is required in a concept Vectorized_topological_data

Friends And Related Function Documentation

◆ add_two_landscapes

Persistence_landscape_on_grid add_two_landscapes ( const Persistence_landscape_on_grid land1,
const Persistence_landscape_on_grid land2 
)
friend

A function that compute sum of two landscapes.

◆ compute_distance_of_landscapes_on_grid

double compute_distance_of_landscapes_on_grid ( const Persistence_landscape_on_grid first,
const Persistence_landscape_on_grid second,
double  p 
)
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.

◆ compute_inner_product [1/2]

double compute_inner_product ( const Persistence_landscape_on_grid l1,
const Persistence_landscape_on_grid l2 
)
friend

Function to compute inner (scalar) product of two landscapes.

◆ compute_inner_product [2/2]

double compute_inner_product ( const Persistence_landscape_on_grid l1,
const Persistence_landscape_on_grid l2,
size_t  level 
)
friend

Function to compute inner (scalar) product of given levels of two landscapes.

◆ compute_max_norm_distance_of_landscapes

double compute_max_norm_distance_of_landscapes ( const Persistence_landscape_on_grid first,
const Persistence_landscape_on_grid second 
)
friend

Computations of \(L^{\infty}\) distance between two landscapes.

◆ operator* [1/2]

Persistence_landscape_on_grid operator* ( const Persistence_landscape_on_grid first,
double  con 
)
friend

An operator * that allows multiplication of a landscape by a real number.

◆ operator* [2/2]

Persistence_landscape_on_grid operator* ( double  con,
const Persistence_landscape_on_grid first 
)
friend

An operator * that allows multiplication of a landscape by a real number (order of parameters swapped).

◆ operator+

Persistence_landscape_on_grid operator+ ( const Persistence_landscape_on_grid first,
const Persistence_landscape_on_grid second 
)
friend

An operator +, that compute sum of two landscapes.

◆ operator-

Persistence_landscape_on_grid operator- ( const Persistence_landscape_on_grid first,
const Persistence_landscape_on_grid second 
)
friend

An operator -, that compute difference of two landscapes.

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const Persistence_landscape_on_grid land 
)
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.

◆ subtract_two_landscapes

Persistence_landscape_on_grid subtract_two_landscapes ( const Persistence_landscape_on_grid land1,
const Persistence_landscape_on_grid land2 
)
friend

A function that compute difference of two landscapes.


The documentation for this class was generated from the following file:
GUDHI  Version 3.1.1  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Fri Feb 7 2020 16:35:36 for GUDHI by Doxygen 1.8.13