summaryrefslogtreecommitdiff
path: root/src/Witness_complex
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-01 06:03:29 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-01 06:03:29 +0000
commitfda43b1fde4774909c632a0604ae7ad05a660d3a (patch)
treea88abda1b405b7e0baa56ff8d08d68f4829e7ad4 /src/Witness_complex
parentd070c2916225acdd928db5929c0cab02589ca8a8 (diff)
Fix cppcheck
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@2122 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 92d11c064056138ce4aa8cbe3a42df29a8a5ca7d
Diffstat (limited to 'src/Witness_complex')
-rw-r--r--src/Witness_complex/example/example_strong_witness_persistence.cpp3
-rw-r--r--src/Witness_complex/example/example_witness_complex_persistence.cpp35
-rw-r--r--src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h11
-rw-r--r--src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h6
-rw-r--r--src/Witness_complex/include/gudhi/Euclidean_witness_complex.h20
-rw-r--r--src/Witness_complex/include/gudhi/Strong_witness_complex.h17
-rw-r--r--src/Witness_complex/include/gudhi/Witness_complex.h2
7 files changed, 45 insertions, 49 deletions
diff --git a/src/Witness_complex/example/example_strong_witness_persistence.cpp b/src/Witness_complex/example/example_strong_witness_persistence.cpp
index 5efe69fd..f786fe7b 100644
--- a/src/Witness_complex/example/example_strong_witness_persistence.cpp
+++ b/src/Witness_complex/example/example_strong_witness_persistence.cpp
@@ -126,13 +126,14 @@ void program_options(int argc, char * argv[]
"Name of file containing a point set in off format.");
po::options_description visible("Allowed options", 100);
+ Filtration_value default_alpha = std::numeric_limits<Filtration_value>::infinity();
visible.add_options()
("help,h", "produce help message")
("landmarks,l", po::value<int>(&nbL),
"Number of landmarks to choose from the point cloud.")
("output-file,o", po::value<std::string>(&filediag)->default_value(std::string()),
"Name of file in which the persistence diagram is written. Default print in std::cout")
- ("max-sq-alpha,a", po::value<Filtration_value>(&max_squared_alpha)->default_value(std::numeric_limits<Filtration_value>::infinity()),
+ ("max-sq-alpha,a", po::value<Filtration_value>(&max_squared_alpha)->default_value(default_alpha),
"Maximal squared relaxation parameter.")
("field-charac,p", po::value<int>(&p)->default_value(11),
"Characteristic p of the coefficient field Z/pZ for computing homology.")
diff --git a/src/Witness_complex/example/example_witness_complex_persistence.cpp b/src/Witness_complex/example/example_witness_complex_persistence.cpp
index 364a114a..a1146922 100644
--- a/src/Witness_complex/example/example_witness_complex_persistence.cpp
+++ b/src/Witness_complex/example/example_witness_complex_persistence.cpp
@@ -34,18 +34,17 @@
#include <vector>
#include <limits> // infinity
-using namespace Gudhi;
-using namespace Gudhi::persistent_cohomology;
+using K = CGAL::Epick_d<CGAL::Dynamic_dimension_tag>;
+using Point_d = K::Point_d;
-typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
-typedef typename K::Point_d Point_d;
+using Point_vector = std::vector<Point_d>;
+using Witness_complex = Gudhi::witness_complex::Euclidean_witness_complex<K>;
+using SimplexTree = Gudhi::Simplex_tree<>;
-typedef typename std::vector<Point_d> Point_vector;
-typedef typename Gudhi::witness_complex::Euclidean_witness_complex<K> Witness_complex;
-typedef Gudhi::Simplex_tree<> SimplexTree;
+using Filtration_value = SimplexTree::Filtration_value;
-typedef int Vertex_handle;
-typedef double Filtration_value;
+using Field_Zp = Gudhi::persistent_cohomology::Field_Zp;
+using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<SimplexTree, Field_Zp>;
void program_options(int argc, char * argv[]
, int & nbL
@@ -83,9 +82,9 @@ int main(int argc, char * argv[]) {
// Compute witness complex
Witness_complex witness_complex(landmarks,
witnesses);
-
+
witness_complex.create_complex(simplex_tree, max_squared_alpha, lim_d);
-
+
std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n";
std::cout << " and has dimension " << simplex_tree.dimension() << " \n";
@@ -93,7 +92,7 @@ int main(int argc, char * argv[]) {
simplex_tree.initialize_filtration();
// Compute the persistence diagram of the complex
- persistent_cohomology::Persistent_cohomology<SimplexTree, Field_Zp > pcoh(simplex_tree);
+ Persistent_cohomology pcoh(simplex_tree);
// initializes the coefficient field for homology
pcoh.init_coefficients(p);
@@ -120,15 +119,14 @@ void program_options(int argc, char * argv[]
, int & p
, int & dim_max
, Filtration_value & min_persistence) {
-
namespace po = boost::program_options;
-
+
po::options_description hidden("Hidden options");
hidden.add_options()
("input-file", po::value<std::string>(&file_name),
"Name of file containing a point set in off format.");
-
+ Filtration_value default_alpha = std::numeric_limits<Filtration_value>::infinity();
po::options_description visible("Allowed options", 100);
visible.add_options()
("help,h", "produce help message")
@@ -136,7 +134,7 @@ void program_options(int argc, char * argv[]
"Number of landmarks to choose from the point cloud.")
("output-file,o", po::value<std::string>(&filediag)->default_value(std::string()),
"Name of file in which the persistence diagram is written. Default print in std::cout")
- ("max-sq-alpha,a", po::value<Filtration_value>(&max_squared_alpha)->default_value(std::numeric_limits<Filtration_value>::infinity()),
+ ("max-sq-alpha,a", po::value<Filtration_value>(&max_squared_alpha)->default_value(default_alpha),
"Maximal squared relaxation parameter.")
("field-charac,p", po::value<int>(&p)->default_value(11),
"Characteristic p of the coefficient field Z/pZ for computing homology.")
@@ -144,7 +142,7 @@ void program_options(int argc, char * argv[]
"Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals")
("cpx-dimension,d", po::value<int>(&dim_max)->default_value(std::numeric_limits<int>::max()),
"Maximal dimension of the weak witness complex we want to compute.");
-
+
po::positional_options_description pos;
pos.add("input-file", 1);
@@ -155,7 +153,7 @@ void program_options(int argc, char * argv[]
po::store(po::command_line_parser(argc, argv).
options(all).positional(pos).run(), vm);
po::notify(vm);
-
+
if (vm.count("help") || !vm.count("input-file")) {
std::cout << std::endl;
std::cout << "Compute the persistent homology with coefficient field Z/pZ \n";
@@ -171,4 +169,3 @@ void program_options(int argc, char * argv[]
std::abort();
}
}
-
diff --git a/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h b/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h
index 4e29a40d..0a05173a 100644
--- a/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h
+++ b/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h
@@ -36,7 +36,6 @@ namespace witness_complex {
* If all the landmarks are present in the list, iterator returns the specific end value
* of the corresponding 'Active_witness' object.
*/
-
template< typename Active_witness,
typename Id_distance_pair,
typename INS_iterator >
@@ -47,15 +46,14 @@ class Active_witness_iterator
Id_distance_pair const> {
friend class boost::iterator_core_access;
- //typedef Active_witness<Id_distance_pair, INS_iterator> Active_witness;
typedef typename std::list<Id_distance_pair>::iterator Pair_iterator;
typedef typename Gudhi::witness_complex::Active_witness_iterator<Active_witness,
Id_distance_pair,
INS_iterator> Iterator;
Active_witness *aw_;
- Pair_iterator lh_; // landmark handle
- bool is_end_; // true only if the pointer is end and there are no more neighbors to add
+ Pair_iterator lh_; // landmark handle
+ bool is_end_; // true only if the pointer is end and there are no more neighbors to add
public:
Active_witness_iterator(Active_witness* aw)
@@ -87,7 +85,8 @@ class Active_witness_iterator
void increment() {
// the neighbor search can't be at the end iterator of a list
- GUDHI_CHECK(!is_end_ && lh_ != aw_->nearest_landmark_table_.end(), std::logic_error("Wrong active witness increment."));
+ GUDHI_CHECK(!is_end_ && lh_ != aw_->nearest_landmark_table_.end(),
+ std::logic_error("Wrong active witness increment."));
// if the id of the current landmark is the same as the last one
lh_++;
@@ -105,5 +104,5 @@ class Active_witness_iterator
} // namespace witness_complex
} // namespace Gudhi
-
+
#endif // ACTIVE_WITNESS_ACTIVE_WITNESS_ITERATOR_H_
diff --git a/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h b/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h
index 6870c183..fb669ef8 100644
--- a/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h
@@ -83,13 +83,13 @@ class Euclidean_strong_witness_complex
const WitnessRange & witnesses)
: landmarks_(std::begin(landmarks), std::end(landmarks)), landmark_tree_(landmarks_) {
nearest_landmark_table_.reserve(boost::size(witnesses));
- for (auto w: witnesses)
+ for (auto w : witnesses)
nearest_landmark_table_.push_back(landmark_tree_.query_incremental_nearest_neighbors(w));
}
/** \brief Returns the point corresponding to the given vertex.
*/
- template <typename Vertex_handle>
+ template <typename Vertex_handle>
Point_d get_point(Vertex_handle vertex) const {
return landmarks_[vertex];
}
@@ -101,4 +101,4 @@ class Euclidean_strong_witness_complex
} // namespace Gudhi
-#endif // EUCLIDEAN_STRONG_WITNESS_COMPLEX_H_
+#endif // EUCLIDEAN_STRONG_WITNESS_COMPLEX_H_
diff --git a/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h b/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h
index 146271f7..6afe9a5d 100644
--- a/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h
@@ -33,7 +33,7 @@
#include <limits>
namespace Gudhi {
-
+
namespace witness_complex {
/**
@@ -46,8 +46,10 @@ namespace witness_complex {
* href="http://doc.cgal.org/latest/Kernel_d/classCGAL_1_1Epick__d.html">CGAL::Epick_d</a> class.
*/
template< class Kernel_ >
-class Euclidean_witness_complex : public Witness_complex<std::vector<typename Gudhi::spatial_searching::Kd_tree_search<Kernel_, std::vector<typename Kernel_::Point_d>>::INS_range>> {
-private:
+class Euclidean_witness_complex
+ : public Witness_complex<std::vector<typename Gudhi::spatial_searching::Kd_tree_search<Kernel_,
+ std::vector<typename Kernel_::Point_d>>::INS_range>> {
+ private:
typedef Kernel_ K;
typedef typename K::Point_d Point_d;
typedef std::vector<Point_d> Point_range;
@@ -64,7 +66,7 @@ private:
Kd_tree landmark_tree_;
using Witness_complex<Nearest_landmark_table>::nearest_landmark_table_;
-public:
+ public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* @name Constructor
*/
@@ -81,24 +83,22 @@ public:
typename WitnessRange >
Euclidean_witness_complex(const LandmarkRange & landmarks,
const WitnessRange & witnesses)
- : landmarks_(std::begin(landmarks), std::end(landmarks)), landmark_tree_(landmarks)
- {
+ : landmarks_(std::begin(landmarks), std::end(landmarks)), landmark_tree_(landmarks) {
nearest_landmark_table_.reserve(boost::size(witnesses));
- for (auto w: witnesses)
+ for (auto w : witnesses)
nearest_landmark_table_.push_back(landmark_tree_.query_incremental_nearest_neighbors(w));
}
/** \brief Returns the point corresponding to the given vertex.
* @param[in] vertex Vertex handle of the point to retrieve.
*/
- Point_d get_point( Vertex_handle vertex ) const
- {
+ Point_d get_point(Vertex_handle vertex) const {
return landmarks_[vertex];
}
//@}
};
-
+
} // namespace witness_complex
} // namespace Gudhi
diff --git a/src/Witness_complex/include/gudhi/Strong_witness_complex.h b/src/Witness_complex/include/gudhi/Strong_witness_complex.h
index 3fbbb366..6708ac29 100644
--- a/src/Witness_complex/include/gudhi/Strong_witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Strong_witness_complex.h
@@ -79,8 +79,8 @@ class Strong_witness_complex {
* The range of pairs must admit a member type 'iterator'. The dereference type
* of the pair range iterator needs to be 'std::pair<std::size_t, double>'.
*/
- Strong_witness_complex(Nearest_landmark_table_ const & nearest_landmark_table)
- : nearest_landmark_table_(std::begin(nearest_landmark_table), std::end(nearest_landmark_table)) {
+ Strong_witness_complex(Nearest_landmark_table_ const & nearest_landmark_table)
+ : nearest_landmark_table_(std::begin(nearest_landmark_table), std::end(nearest_landmark_table)) {
}
/** \brief Outputs the strong witness complex of relaxation 'max_alpha_square'
@@ -110,7 +110,7 @@ class Strong_witness_complex {
std::cerr << "Strong witness complex cannot create complex - limit dimension must be non-negative.\n";
return false;
}
- for (auto w: nearest_landmark_table_) {
+ for (auto w : nearest_landmark_table_) {
ActiveWitness aw(w);
typeVectorVertex simplex;
typename ActiveWitness::iterator aw_it = aw.begin();
@@ -121,7 +121,7 @@ class Strong_witness_complex {
aw_it++;
}
// continue inserting limD-faces of the following simplices
- typeVectorVertex& vertices = simplex; //'simplex' now will be called vertices
+ typeVectorVertex& vertices = simplex; // 'simplex' now will be called vertices
while (aw_it != aw.end() && aw_it->second < lim_dist2) {
typeVectorVertex facet = {};
add_all_faces_of_dimension(limit_dimension, vertices, vertices.begin(), aw_it,
@@ -153,7 +153,7 @@ class Strong_witness_complex {
if (dim > 0) {
while (curr_it != vertices.end()) {
simplex.push_back(*curr_it);
- ++curr_it;
+ ++curr_it;
add_all_faces_of_dimension(dim-1,
vertices,
curr_it,
@@ -169,14 +169,13 @@ class Strong_witness_complex {
filtration_value,
simplex,
sc);
- }
+ }
} else if (dim == 0) {
simplex.push_back(aw_it->first);
sc.insert_simplex_and_subfaces(simplex, filtration_value);
simplex.pop_back();
- }
- }
-
+ }
+ }
//@}
};
diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h
index c0506367..a79bf294 100644
--- a/src/Witness_complex/include/gudhi/Witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Witness_complex.h
@@ -183,7 +183,7 @@ class Witness_complex {
simplex.push_back(l_it->first);
double filtration_value = 0;
// if norelax_dist is infinite, relaxation is 0.
- if (l_it->second > norelax_dist2)
+ if (l_it->second > norelax_dist2)
filtration_value = l_it->second - norelax_dist2;
if (all_faces_in(simplex, &filtration_value, sc)) {
will_be_active = true;