summaryrefslogtreecommitdiff
path: root/src/cython/include
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-02-16 14:58:11 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-02-16 14:58:11 +0000
commit518acce63202c7b89fa3f76467e50eee7630cf62 (patch)
treed9877e63720c6a6fa2cef113182fe1178c049cb1 /src/cython/include
parentdf173dbefd275c54d8f5e33794d51709b887d2d3 (diff)
Remove pandas examples and use of OFF files interfaces to be more consistent (pandas interface is not that hard to be done)
Add of distance matrix in Rips git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2081 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3a3b24f0824eed2710edb5bf17d120039973bf62
Diffstat (limited to 'src/cython/include')
-rw-r--r--src/cython/include/Rips_complex_interface.h32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/cython/include/Rips_complex_interface.h b/src/cython/include/Rips_complex_interface.h
index 7e897b1d..9295906c 100644
--- a/src/cython/include/Rips_complex_interface.h
+++ b/src/cython/include/Rips_complex_interface.h
@@ -27,6 +27,7 @@
#include <gudhi/Rips_complex.h>
#include <gudhi/Points_off_io.h>
#include <gudhi/distance_functions.h>
+#include <gudhi/reader_utils.h>
#include "Simplex_tree_interface.h"
@@ -41,17 +42,34 @@ namespace rips_complex {
class Rips_complex_interface {
using Point_d = std::vector<double>;
+ using Distance_matrix = std::vector<std::vector<Simplex_tree_interface<>::Filtration_value>>;
public:
- Rips_complex_interface(std::vector<std::vector<double>>&points, double threshold) {
- rips_complex_ = new Rips_complex<Simplex_tree_interface<>::Filtration_value>(points, threshold,
- Euclidean_distance());
+ Rips_complex_interface(std::vector<std::vector<double>>&values, double threshold, bool euclidean) {
+ if (euclidean) {
+ // Rips construction where values is a vector of points
+ rips_complex_ = new Rips_complex<Simplex_tree_interface<>::Filtration_value>(values, threshold,
+ Euclidean_distance());
+ } else {
+ // Rips construction where values is a distance matrix
+ rips_complex_ = new Rips_complex<Simplex_tree_interface<>::Filtration_value>(values, threshold);
+
+ }
}
- Rips_complex_interface(std::string off_file_name, double threshold, bool from_file = true) {
- Gudhi::Points_off_reader<Point_d> off_reader(off_file_name);
- rips_complex_ = new Rips_complex<Simplex_tree_interface<>::Filtration_value>(off_reader.get_point_cloud(),
- threshold, Euclidean_distance());
+ Rips_complex_interface(std::string file_name, double threshold, bool euclidean, bool from_file = true) {
+ if (euclidean) {
+ // Rips construction where file_name is an OFF file
+ Gudhi::Points_off_reader<Point_d> off_reader(file_name);
+ rips_complex_ = new Rips_complex<Simplex_tree_interface<>::Filtration_value>(off_reader.get_point_cloud(),
+ threshold, Euclidean_distance());
+ } else {
+ // Rips construction where values is a distance matrix
+ Distance_matrix distances = read_lower_triangular_matrix_from_csv_file<Simplex_tree_interface<>::Filtration_value>(file_name);
+ rips_complex_ = new Rips_complex<Simplex_tree_interface<>::Filtration_value>(distances, threshold);
+
+ }
+
}
void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, int dim_max) {