diff options
author | pdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-08-23 07:12:38 +0000 |
---|---|---|
committer | pdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-08-23 07:12:38 +0000 |
commit | 11fde86ff4cc696c44567b6692aed4adb9c0e4d4 (patch) | |
tree | 7a458fe52f4a4d7ce9fea894a22e23f84ea5656f | |
parent | d7797ccdc896a06977155b16df327eb6c379907a (diff) |
Ading the interface files.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration@2620 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 7f495bb2f41e18481661d1b73865a42c2cdcb5d0
-rw-r--r-- | src/cython/include/PSSK_interface.h | 63 | ||||
-rw-r--r-- | src/cython/include/Persistence_heat_maps_interface.h | 156 | ||||
-rw-r--r-- | src/cython/include/Persistence_intervals_interface.h (renamed from src/cython/include/persistence_representations_intervals.h) | 1 | ||||
-rw-r--r-- | src/cython/include/Persistence_intervals_with_distances_interface.h | 43 | ||||
-rw-r--r-- | src/cython/include/Persistence_landscape_interface.h | 167 | ||||
-rw-r--r-- | src/cython/include/Persistence_landscape_on_grid_interface.h | 187 | ||||
-rw-r--r-- | src/cython/include/Persistence_vectors_interface.h | 121 |
7 files changed, 737 insertions, 1 deletions
diff --git a/src/cython/include/PSSK_interface.h b/src/cython/include/PSSK_interface.h new file mode 100644 index 00000000..3b2d336a --- /dev/null +++ b/src/cython/include/PSSK_interface.h @@ -0,0 +1,63 @@ +/* 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) 2017 Swansea University + * + * 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 PSSK_INTERFACE_H_ +#define PSSK_INTERFACE__H_ + + +#include <gudhi/PSSK.h> + + +namespace Gudhi { +namespace Persistence_representations { + +/** +* This is a version of a representation presented in https://arxiv.org/abs/1412.6821 +* In that paper the authors are using the representation just to compute kernel. Over here, we extend the usability by +*far. +* Note that the version presented here is not exact, since we are discretizing the kernel. +* The only difference with respect to the original class is the method of creation. We have full (square) image, and for +*every point (p,q), we add a kernel at (p,q) and the negative kernel +* at (q,p) +**/ + +class PSSK_interface : public PSSK { + public: + PSSK_interface(){} + + PSSK_interface(const std::vector<std::pair<double, double> >& interval, + std::vector<std::vector<double> > filter = create_Gaussian_filter(5, 1), size_t number_of_pixels = 1000, + double min_ = -1, double max_ = -1) + : + PSSK(interval,filter,number_of_pixels,min_,max_){} + + PSSK_interface(const char* filename, std::vector<std::vector<double> > filter = create_Gaussian_filter(5, 1), + size_t number_of_pixels = 1000, double min_ = -1, double max_ = -1, + unsigned dimension = std::numeric_limits<unsigned>::max()) + :PSSK(filename,filter,number_of_pixels,min_,max_,dimension){} + +}; + +} // namespace Persistence_representations +} // namespace Gudhi + +#endif // PSSK_INTERFACE__H_ diff --git a/src/cython/include/Persistence_heat_maps_interface.h b/src/cython/include/Persistence_heat_maps_interface.h new file mode 100644 index 00000000..fe565313 --- /dev/null +++ b/src/cython/include/Persistence_heat_maps_interface.h @@ -0,0 +1,156 @@ +/* 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) 2016 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 PERSISTENCE_HEAT_MAPS_INTERFACE_H_ +#define PERSISTENCE_HEAT_MAPS_INTERFACE_H_ + +// gudhi include +#include <gudhi/read_persistence_from_file.h> +#include <gudhi/common_persistence_representations.h> + +// standard include +#include <vector> +#include <sstream> +#include <iostream> +#include <cmath> +#include <limits> +#include <algorithm> +#include <utility> +#include <string> +#include <functional> + +namespace Gudhi { +namespace Persistence_representations { + +class Persistence_heat_maps_interface : public Persistence_heat_maps { + public: + + Persistence_heat_maps_interface():Persistence_heat_maps(){} + + + Persistence_heat_maps_interface(const std::vector<std::pair<double, double> >& interval, + std::vector<std::vector<double> > filter = create_Gaussian_filter(5, 1), + bool erase_below_diagonal = false, size_t number_of_pixels = 1000, + double min_ = std::numeric_limits<double>::max(), + double max_ = std::numeric_limits<double>::max()): + Persistence_heat_maps(interval,filter,erase_below_diagonal,number_of_pixels,min_max_){} + + + Persistence_heat_maps_interface(const char* filename, std::vector<std::vector<double> > filter = create_Gaussian_filter(5, 1), + bool erase_below_diagonal = false, size_t number_of_pixels = 1000, + double min_ = std::numeric_limits<double>::max(), + double max_ = std::numeric_limits<double>::max(), + unsigned dimension = std::numeric_limits<unsigned>::max()): + Persistence_heat_maps(filename,filter,erase_below_diagonal,number_of_pixels,min_,max_,dimension){} + + void compute_mean_interface(const std::vector<Persistence_heat_maps*>& maps) + { + this->compute_mean(maps); + } + + void compute_median_interface(const std::vector<Persistence_heat_maps*>& maps) + { + this->compute_median(maps); + } + + void compute_percentage_of_active_interface(const std::vector<Persistence_heat_maps*>& maps, size_t cutoff = 1) + { + this->compute_percentage_of_active(maps,cutoff); + } + + void print_to_file_interface(const char* filename) const + { + this->print_to_file(filename); + } + + void load_from_file_interface(const char* filename) + { + this->load_from_file( filename ); + } + + inline bool check_if_the_same_interface(const Persistence_heat_maps& second) const + { + return this->check_if_the_same( second ); + } + + inline double get_min_interface() const + { + return this->get_min(); + } + + inline double get_max_interface() const + { + return this->get_max(); + } + + std::vector<double> vectorize_interface(int number_of_function) const + { + return this->vectorize(number_of_function); + } + + size_t number_of_vectorize_functions_interface() const + { + return this->number_of_vectorize_functions(); + } + + double project_to_R_interface(int number_of_function) const + { + return this->project_to_R( number_of_function ); + } + + size_t number_of_projections_to_R_interface() const + { + return this->number_of_projections_to_R(); + } + + double distance_interface(const Persistence_heat_maps& second_, double power = 1) const + { + return this->distance( second, power ); + } + + void compute_average_interface(const std::vector<Persistence_heat_maps*>& to_average) + { + this->compute_average( to_average ); + } + + double compute_scalar_product_interface(const Persistence_heat_maps& second_) const + { + return this->compute_scalar_product( second_ ); + } + + std::pair<double, double> get_x_range_interface() const + { + return this->get_x_range(); + } + + std::pair<double, double> get_y_range_interface() const + { + return this->get_y_range(); + } + +}; + + +} // namespace Persistence_representations +} // namespace Gudhi + +#endif // PERSISTENCE_HEAT_MAPS_INTERFACE_H_ diff --git a/src/cython/include/persistence_representations_intervals.h b/src/cython/include/Persistence_intervals_interface.h index a4ad0e0f..b43dd091 100644 --- a/src/cython/include/persistence_representations_intervals.h +++ b/src/cython/include/Persistence_intervals_interface.h @@ -53,7 +53,6 @@ class Persistence_intervals_interface : public Persistence_intervals std::pair<double, double> get_x_range_interface() const { std::pair<double, double> range = this->get_x_range(); - std::cout << std::endl << std::endl << range.first << " " << range.second << std::endl << std::endl <<std::endl; return range; } diff --git a/src/cython/include/Persistence_intervals_with_distances_interface.h b/src/cython/include/Persistence_intervals_with_distances_interface.h new file mode 100644 index 00000000..05caa14a --- /dev/null +++ b/src/cython/include/Persistence_intervals_with_distances_interface.h @@ -0,0 +1,43 @@ +/* This file is part of the Gudhi hiLibrary. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Pawel Dlotko + * + * Copyright (C) 2017 Swansea University + * + * 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 PERSISTENCE_INTERVALS_WITH_DISTANCES_INTERFACE_H_ +#define PERSISTENCE_INTERVALS_WITH_DISTANCES_INTERFACE_H_ + +#include <gudhi/Persistence_intervals_with_distances.h> + +namespace Gudhi { +namespace Persistence_representations { + +class Persistence_intervals_with_distances_interface : public Persistence_intervals_with_distances { + public: + double distance_interface(const Persistence_intervals_with_distances& second, double power = std::numeric_limits<double>::max(), + double tolerance = 0) const + { + return this->distance( second, power, tolerance ); + } +}; + +} // namespace Persistence_representations +} // namespace Gudhi + +#endif // PERSISTENCE_INTERVALS_WITH_DISTANCES_INTERFACE_H_ diff --git a/src/cython/include/Persistence_landscape_interface.h b/src/cython/include/Persistence_landscape_interface.h new file mode 100644 index 00000000..251d15ee --- /dev/null +++ b/src/cython/include/Persistence_landscape_interface.h @@ -0,0 +1,167 @@ +/* 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) 2017 Swansea University + * + * 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 PERSISTENCE_LANDSCAPE_INTERFACE_H_ +#define PERSISTENCE_LANDSCAPE_INTERFACE_H_ + +#include <gudhi/Persistence_landscape.h> + +namespace Gudhi { +namespace Persistence_representations { + + +class Persistence_landscape_interface : public Persistence_landscape +{ + public: + Persistence_landscape_interface():Persistence_landscape(){} + + Persistence_landscape_interface(const std::vector<std::pair<double, double> >& p, size_t number_of_levels = std::numeric_limits<size_t>::max() ):Persistence_landscape(p,number_of_levels){} + + + Persistence_landscape_interface(const char* filename, size_t dimension = std::numeric_limits<unsigned>::max() , size_t number_of_levels = std::numeric_limits<size_t>::max() ):Persistence_landscape(filename,dimension,number_of_levels){} + + + void load_landscape_from_file_interface(const char* filename) + { + this->load_landscape_from_file(filename); + } + + + void print_to_file_interface(const char* filename) const + { + this->print_to_file(filename); + } + + + double compute_integral_of_landscape_interface() const + { + return this->compute_integral_of_landscape(); + } + + + double compute_integral_of_a_level_of_a_landscape_interface(size_t level) const + { + return this->compute_integral_of_a_level_of_a_landscape(level); + } + + + double compute_integral_of_landscape_interface(double p) const + { + return this->compute_integral_of_landscape(p); + } + + + double compute_value_at_a_given_point_interface(unsigned level, double x) const + { + return this->compute_value_at_a_given_point(level,x); + } + + + double compute_maximum_interface() const + { + return this->compute_maximum(); + } + + + double compute_minimum_interface() const + { + return this->compute_minimum(); + } + + + double compute_norm_of_landscape_interface(double i) + { + return this->compute_norm_of_landscape(i); + } + + + Persistence_landscape abs_interface() + { + return this->abs(); + } + + size_t size_interface() const + { + return this->size(); + } + + double find_max_interface(unsigned lambda) const + { + return this->find_max(); + } + + friend double compute_inner_product_interface(const Persistence_landscape& l1, const Persistence_landscape& l2) + { + return this->compute_inner_product(l1,l2); + } + + double project_to_R_interface(int number_of_function) const + { + return this->project_to_R(number_of_function); + } + + + size_t number_of_projections_to_R_interface() const + { + return this->number_of_projections_to_R(); + } + + + std::vector<double> vectorize_interface(int number_of_function) const + { + return this->vectorize( number_of_function ); + } + + + size_t number_of_vectorize_function_interface() const + { + return this->number_of_vectorize_function(); + } + + + void compute_average_interface(const std::vector<Persistence_landscape*>& to_average) + { + return this->compute_average(to_average); + } + + + double distance_interface(const Persistence_landscape& second, double power = 1) + { + return this->distance( second, power ); + } + + + double compute_scalar_product_interface(const Persistence_landscape& second) const + { + return this->compute_scalar_product( second ); + } + + + std::pair<double, double> get_y_range_interface(size_t level = 0) const + { + return this->get_y_range( level ); + } + +} // namespace Persistence_representations +} // namespace Gudhi + +#endif // PERSISTENCE_LANDSCAPE_INTERFACE_H_ diff --git a/src/cython/include/Persistence_landscape_on_grid_interface.h b/src/cython/include/Persistence_landscape_on_grid_interface.h new file mode 100644 index 00000000..91a12d39 --- /dev/null +++ b/src/cython/include/Persistence_landscape_on_grid_interface.h @@ -0,0 +1,187 @@ +/* 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) 2017 Swansea University + * + * 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 PERSISTENCE_LANDSCAPE_ON_GRID_INTERFACE_H_ +#define PERSISTENCE_LANDSCAPE_ON_GRID_INTERFACE_H_ + +#include <gudhi/Persistence_landscape_on_grid.h> + +namespace Gudhi { +namespace Persistence_representations { + + +class Persistence_landscape_on_grid_interface : public Persistence_landscape_on_grid +{ + public: + Persistence_landscape_on_grid_interface():Persistence_landscape_on_grid(){} + + Persistence_landscape_on_grid_interface(const std::vector<std::pair<double, double> >& p, double grid_min_, double grid_max_, + size_t number_of_points_):Persistence_landscape_on_grid(p, grid_min_, grid_max_,number_of_points_){} + + + Persistence_landscape_on_grid_interface(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(p, grid_min_, grid_max_,number_of_points_, number_of_levels_of_landscape){} + + + Persistence_landscape_on_grid_interface(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(filename, grid_min_, grid_max_, number_of_points_, number_of_levels_of_landscape, dimension_ ){} + + + Persistence_landscape_on_grid_interface(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(filename,grid_min_,grid_max_,number_of_points_,dimension_ ){} + + + Persistence_landscape_on_grid_interface(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(filename,number_of_points,number_of_levels_of_landscape,dimension){} + + + Persistence_landscape_on_grid_interface(const char* filename, size_t number_of_points, uint16_t dimension = std::numeric_limits<uint16_t>::max()): + Persistence_landscape_on_grid(filename,number_of_points,dimension){} + + + void load_landscape_from_file_interface(const char* filename) + { + this->load_landscape_from_file(filename); + } + + + void print_to_file_interface(const char* filename) const + { + this->print_to_file(filename); + } + + + double compute_integral_of_landscape_interface() const + { + return this->compute_integral_of_landscape(); + } + + + double compute_integral_of_a_level_of_a_landscape_interface(size_t level) const + { + return this->compute_integral_of_a_level_of_a_landscape(level); + } + + + double compute_integral_of_landscape_interface(double p) const + { + return this->compute_integral_of_landscape(p); + } + + + double compute_value_at_a_given_point_interface(unsigned level, double x) const + { + return this->compute_value_at_a_given_point(level,x); + } + + + double compute_maximum_interface() const + { + return this->compute_maximum(); + } + + + double compute_minimum_interface() const + { + return this->compute_minimum(); + } + + + double compute_norm_of_landscape_interface(double i) + { + return this->compute_norm_of_landscape(i); + } + + + Persistence_landscape abs_interface() + { + return this->abs(); + } + + size_t size_interface() const + { + return this->size(); + } + + double find_max_interface(unsigned lambda) const + { + return this->find_max(); + } + + friend double compute_inner_product_interface(const Persistence_landscape& l1, const Persistence_landscape& l2) + { + return this->compute_inner_product(l1,l2); + } + + double project_to_R_interface(int number_of_function) const + { + return this->project_to_R(number_of_function); + } + + + size_t number_of_projections_to_R_interface() const + { + return this->number_of_projections_to_R(); + } + + + std::vector<double> vectorize_interface(int number_of_function) const + { + return this->vectorize( number_of_function ); + } + + + size_t number_of_vectorize_function_interface() const + { + return this->number_of_vectorize_function(); + } + + + void compute_average_interface(const std::vector<Persistence_landscape*>& to_average) + { + return this->compute_average(to_average); + } + + + double distance_interface(const Persistence_landscape& second, double power = 1) + { + return this->distance( second, power ); + } + + + double compute_scalar_product_interface(const Persistence_landscape& second) const + { + return this->compute_scalar_product( second ); + } + + + std::pair<double, double> get_y_range_interface(size_t level = 0) const + { + return this->get_y_range( level ); + } + +} // namespace Persistence_representations +} // namespace Gudhi + +#endif // PERSISTENCE_LANDSCAPE_ON_GRID_INTERFACE_H_ diff --git a/src/cython/include/Persistence_vectors_interface.h b/src/cython/include/Persistence_vectors_interface.h new file mode 100644 index 00000000..3fc482d7 --- /dev/null +++ b/src/cython/include/Persistence_vectors_interface.h @@ -0,0 +1,121 @@ +/* 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) 2016 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 PERSISTENCE_VECTORS_INTERFACE_H_ +#define PERSISTENCE_VECTORS_INTERFACE_H_ + +// gudhi include +#include <gudhi/persistence_vectors.h> +s +namespace Gudhi { +namespace Persistence_representations { + + + +template <typename F> +class Vector_distances_in_diagram_interface : Vector_distances_in_diagram<Euclidean_distance> { + public: + Vector_distances_in_diagram_interface():Vector_distances_in_diagram(){} + + Vector_distances_in_diagram_interface(const std::vector<std::pair<double, double> >& intervals, size_t where_to_cut): + Vector_distances_in_diagram(intervals,where_to_cut){} + + Vector_distances_in_diagram_interface(const char* filename, size_t where_to_cut, + unsigned dimension = std::numeric_limits<unsigned>::max()): + Vector_distances_in_diagram_interface(filename,where_to_cut,dimension){} + + inline double vector_in_position_interface(size_t position) const + { + return this->vector_in_position(position): + } + + inline size_t size_interface() const + { + return this->size(); + } + + void write_to_file_interface(const char* filename) const + { + this->write_to_file( filename ); + } + + void print_to_file_interface(const char* filename) const + { + this->print_to_file(filename); + } + + void load_from_file_interface(const char* filename) + { + this->load_from_file(filename); + } + + double project_to_R_interface(int number_of_function) const + { + return this->project_to_R(number_of_function); + } + + size_t number_of_projections_to_R_interface() const + { + return this->number_of_projections_to_R(); + } + + std::vector<double> vectorize_interface(int number_of_function) const + { + return this->vectorize(number_of_function); + } + + size_t number_of_vectorize_functions_interface() const + { + return this->number_of_vectorize_functions(); + } + + void compute_average_interface(const std::vector<Vector_distances_in_diagram*>& to_average) + { + this->compute_average(to_average); + } + + double distance_interface(const Vector_distances_in_diagram& second, double power = 1) const + { + return this->distance(second,power); + } + + double compute_scalar_product_interface(const Vector_distances_in_diagram& second) const + { + return this->compute_scalar_product(second); + } + + std::pair<double, double> get_x_range_interface() const + { + return this->get_x_range(); + } + + std::pair<double, double> get_y_range_interface() const + { + return this->get_y_range(); + } + +}; + +} // namespace Persistence_representations +} // namespace Gudhi + +#endif // PERSISTENCE_VECTORS_INTERFACE_H_ |