summaryrefslogtreecommitdiff
path: root/src/GudhUI/utils/Persistence_compute.h
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-10-08 21:15:51 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-10-08 21:15:51 +0000
commitcd2e83819689afd2cd1bc76810282111cf5cd59d (patch)
tree8cf97b1f5a8589fa160d03248ca3f429b436b814 /src/GudhUI/utils/Persistence_compute.h
parent58e633f51ffa06aa219231cd1c08eab59457a12f (diff)
cpplint fixes on GudhUI
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@844 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3acf1e789f3e4bded974f324ce3161bc1d1d2433
Diffstat (limited to 'src/GudhUI/utils/Persistence_compute.h')
-rw-r--r--src/GudhUI/utils/Persistence_compute.h138
1 files changed, 64 insertions, 74 deletions
diff --git a/src/GudhUI/utils/Persistence_compute.h b/src/GudhUI/utils/Persistence_compute.h
index 50d340b8..0b9961d3 100644
--- a/src/GudhUI/utils/Persistence_compute.h
+++ b/src/GudhUI/utils/Persistence_compute.h
@@ -1,13 +1,10 @@
-/*
- * Persistence_compute.h
- * Created on: Jan 26, 2015
- * This file is part of the Gudhi Library. The Gudhi library
+/* 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): David Salinas
*
- * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (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
@@ -25,83 +22,76 @@
*/
-#ifndef PERSISTENCE_COMPUTE_H_
-#define PERSISTENCE_COMPUTE_H_
+#ifndef UTILS_PERSISTENCE_COMPUTE_H_
+#define UTILS_PERSISTENCE_COMPUTE_H_
+#include <gudhi/graph_simplicial_complex.h>
+#include <gudhi/Simplex_tree.h>
+#include <gudhi/distance_functions.h>
+#include <gudhi/Persistent_cohomology.h>
-#include "gudhi/graph_simplicial_complex.h"
-#include "gudhi/Simplex_tree.h"
-#include "gudhi/distance_functions.h"
-#include "gudhi/Persistent_cohomology.h"
+#include <vector>
+struct Persistence_params {
+ int p;
+ double threshold;
+ int max_dim;
+ double min_pers;
-struct Persistence_params{
- int p;
- double threshold;
- int max_dim;
- double min_pers;
-
- Persistence_params(int p_,double th_,int max_dim_=10,double min_pers_=0)
- :p(p_),threshold(th_),max_dim(max_dim_),min_pers(min_pers_){}
+ Persistence_params(int p_, double th_, int max_dim_ = 10, double min_pers_ = 0)
+ : p(p_), threshold(th_), max_dim(max_dim_), min_pers(min_pers_) { }
};
-
/**
* Show persistence into output stream
*/
-template<typename SkBlComplex> class Persistence_compute{
-private:
- SkBlComplex& complex_;
- std::ostream& stream_;
-public:
- typedef typename SkBlComplex::Vertex_handle Vertex_handle;
- typedef typename SkBlComplex::Edge_handle Edge_handle;
-
- /**
- * @brief Compute persistence
- * parameters :
- * unsigned dim_max
- * double threshold
- * int p for coefficient Z_p
- */
- Persistence_compute(SkBlComplex& complex,std::ostream& stream,const Persistence_params& params):
-//
-// double threshold = 0.5,unsigned dim_max = 8):
- complex_(complex),stream_(stream){
-
- //for now everything is copied, todo boost adapt iterators to points of SkBlComplex instead of copying to an intial vector
- typedef std::vector<double> Point_t;
- std::vector< Point_t > points;
- points.reserve(complex.num_vertices());
- for(auto v : complex.vertex_range()){
- const auto & pt = complex.point(v);
- Point_t pt_to_add(pt.cartesian_begin(),pt.cartesian_end());
- points.emplace_back(std::move(pt_to_add));
- }
-
-
- Graph_t prox_graph = compute_proximity_graph( points, params.threshold, euclidean_distance<Point_t> );
- Gudhi::Simplex_tree<> st;
- st.insert_graph(prox_graph);
- st.expansion( params.max_dim );
-
- Gudhi::persistent_cohomology::Persistent_cohomology< Gudhi::Simplex_tree<>,Gudhi::persistent_cohomology::Field_Zp > pcoh (st);
- pcoh.init_coefficients( params.p ); //initilizes the coefficient field for homology
- pcoh.compute_persistent_cohomology( params.min_pers ); //put params.min_pers
- stream_<<"persistence: \n";
- stream_<<"p dimension birth death: \n";
-
- pcoh.output_diagram(stream_);
- }
-
-private:
-
-
+template<typename SkBlComplex> class Persistence_compute {
+ private:
+ SkBlComplex& complex_;
+ std::ostream& stream_;
+
+ public:
+ typedef typename SkBlComplex::Vertex_handle Vertex_handle;
+ typedef typename SkBlComplex::Edge_handle Edge_handle;
+
+ /**
+ * @brief Compute persistence
+ * parameters :
+ * unsigned dim_max
+ * double threshold
+ * int p for coefficient Z_p
+ */
+ Persistence_compute(SkBlComplex& complex, std::ostream& stream, const Persistence_params& params) :
+ // double threshold = 0.5,unsigned dim_max = 8):
+ complex_(complex), stream_(stream) {
+ // for now everything is copied, todo boost adapt iterators to points of SkBlComplex instead of copying to an
+ // initial vector
+ typedef std::vector<double> Point_t;
+ std::vector< Point_t > points;
+ points.reserve(complex.num_vertices());
+ for (auto v : complex.vertex_range()) {
+ const auto & pt = complex.point(v);
+ Point_t pt_to_add(pt.cartesian_begin(), pt.cartesian_end());
+ points.emplace_back(std::move(pt_to_add));
+ }
+
+
+ Graph_t prox_graph = compute_proximity_graph(points, params.threshold, euclidean_distance<Point_t>);
+ Gudhi::Simplex_tree<> st;
+ st.insert_graph(prox_graph);
+ st.expansion(params.max_dim);
+
+ Gudhi::persistent_cohomology::Persistent_cohomology< Gudhi::Simplex_tree<>,
+ Gudhi::persistent_cohomology::Field_Zp > pcoh(st);
+ // initializes the coefficient field for homology
+ pcoh.init_coefficients(params.p);
+ // put params.min_pers
+ pcoh.compute_persistent_cohomology(params.min_pers);
+ stream_ << "persistence: \n";
+ stream_ << "p dimension birth death: \n";
+
+ pcoh.output_diagram(stream_);
+ }
};
-
-
-
-
-
-#endif /* PERSISTENCE_COMPUTE_H_ */
+#endif // UTILS_PERSISTENCE_COMPUTE_H_