summaryrefslogtreecommitdiff
path: root/src/Witness_complex/include
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-02-28 16:16:08 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-02-28 16:16:08 +0000
commitf2b63bcaa647d1ec839dbe2e5edbe5c4fde1b304 (patch)
tree106ab2bbf7c34a2b0f6cd73cb4221661a05bc9c0 /src/Witness_complex/include
parentba56545de435b62e0528d01fbde342bc4653da13 (diff)
Fix cppcheck
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@2120 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 49a5c2c6e94d9fbf235eecc92fa30e62980c7c70
Diffstat (limited to 'src/Witness_complex/include')
-rw-r--r--src/Witness_complex/include/gudhi/Active_witness/Active_witness.h22
-rw-r--r--src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h41
-rw-r--r--src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h29
-rw-r--r--src/Witness_complex/include/gudhi/Strong_witness_complex.h54
-rw-r--r--src/Witness_complex/include/gudhi/Witness_complex.h42
-rw-r--r--src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h30
6 files changed, 107 insertions, 111 deletions
diff --git a/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h b/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h
index ffc1750f..d41a6811 100644
--- a/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h
+++ b/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h
@@ -24,8 +24,7 @@
#define ACTIVE_WITNESS_ACTIVE_WITNESS_H_
#include <gudhi/Active_witness/Active_witness_iterator.h>
-#include <vector>
-#include <utility>
+#include <list>
namespace Gudhi {
@@ -38,7 +37,7 @@ namespace witness_complex {
template< typename Id_distance_pair,
typename INS_range >
class Active_witness {
-public:
+ public:
typedef Active_witness<Id_distance_pair, INS_range> ActiveWitness;
typedef typename INS_range::iterator INS_iterator;
typedef Active_witness_iterator< ActiveWitness, Id_distance_pair, INS_iterator > iterator;
@@ -50,22 +49,19 @@ public:
INS_iterator iterator_end_;
Active_witness(const INS_range& search_range)
- : search_range_(search_range), iterator_next_(search_range_.begin()), iterator_end_(search_range_.end())
- {
+ : search_range_(search_range), iterator_next_(search_range_.begin()), iterator_end_(search_range_.end()) {
}
-
- iterator begin()
- {
+
+ iterator begin() {
return iterator(this, nearest_landmark_table_.begin());
}
- iterator end()
- {
+ iterator end() {
return iterator(this);
}
};
-}
-}
-
+} // namespace witness_complex
+} // namespace Gudhi
+
#endif // ACTIVE_WITNESS_ACTIVE_WITNESS_H_
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 69a335fa..4e29a40d 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
@@ -24,7 +24,7 @@
#define ACTIVE_WITNESS_ACTIVE_WITNESS_ITERATOR_H_
#include <boost/iterator/iterator_facade.hpp>
-#include <vector>
+#include <list>
namespace Gudhi {
@@ -41,30 +41,29 @@ template< typename Active_witness,
typename Id_distance_pair,
typename INS_iterator >
class Active_witness_iterator
- : public boost::iterator_facade< Active_witness_iterator <Active_witness, Id_distance_pair, INS_iterator>
-, Id_distance_pair const
-, boost::forward_traversal_tag
-, Id_distance_pair const> {
+ : public boost::iterator_facade< Active_witness_iterator <Active_witness, Id_distance_pair, INS_iterator>,
+ Id_distance_pair const,
+ boost::forward_traversal_tag,
+ 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;
-
-
+ 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
-public:
+ public:
Active_witness_iterator(Active_witness* aw)
- : aw_(aw), lh_(aw_->nearest_landmark_table_.end()), is_end_(true)
- {
+ : aw_(aw), lh_(aw_->nearest_landmark_table_.end()), is_end_(true) {
}
Active_witness_iterator(Active_witness* aw, const Pair_iterator& lh)
- : aw_(aw), lh_(lh)
- {
+ : aw_(aw), lh_(lh) {
is_end_ = false;
if (lh_ == aw_->nearest_landmark_table_.end()) {
if (aw_->iterator_next_ == aw_->iterator_end_) {
@@ -76,21 +75,17 @@ public:
}
}
}
-
-private :
- Id_distance_pair& dereference() const
- {
+ private :
+ Id_distance_pair& dereference() const {
return *lh_;
}
- bool equal(const Iterator& other) const
- {
+ bool equal(const Iterator& other) const {
return (is_end_ == other.is_end_) || (lh_ == other.lh_);
}
-
- void increment()
- {
+
+ 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."));
// if the id of the current landmark is the same as the last one
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 aad05547..6870c183 100644
--- a/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h
@@ -23,17 +23,15 @@
#ifndef EUCLIDEAN_STRONG_WITNESS_COMPLEX_H_
#define EUCLIDEAN_STRONG_WITNESS_COMPLEX_H_
-#include <utility>
-#include <vector>
-#include <list>
-#include <limits>
-
#include <gudhi/Strong_witness_complex.h>
#include <gudhi/Active_witness/Active_witness.h>
#include <gudhi/Kd_tree_search.h>
+#include <utility>
+#include <vector>
+
namespace Gudhi {
-
+
namespace witness_complex {
/**
@@ -46,8 +44,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_strong_witness_complex : public Strong_witness_complex<std::vector<typename Gudhi::spatial_searching::Kd_tree_search<Kernel_, std::vector<typename Kernel_::Point_d>>::INS_range>> {
-private:
+class Euclidean_strong_witness_complex
+ : public Strong_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;
@@ -58,12 +58,12 @@ private:
typedef typename Nearest_landmark_range::Point_with_transformed_distance Id_distance_pair;
typedef typename Id_distance_pair::first_type Landmark_id;
typedef Landmark_id Vertex_handle;
-
+
private:
Point_range landmarks_;
Kd_tree landmark_tree_;
using Strong_witness_complex<Nearest_landmark_table>::nearest_landmark_table_;
-
+
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* @name Constructor
@@ -81,22 +81,19 @@ private:
typename WitnessRange >
Euclidean_strong_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)
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>
- Point_d get_point( Vertex_handle vertex ) const
- {
+ Point_d get_point(Vertex_handle vertex) const {
return landmarks_[vertex];
}
-
+
//@}
};
diff --git a/src/Witness_complex/include/gudhi/Strong_witness_complex.h b/src/Witness_complex/include/gudhi/Strong_witness_complex.h
index ad741794..3fbbb366 100644
--- a/src/Witness_complex/include/gudhi/Strong_witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Strong_witness_complex.h
@@ -23,20 +23,19 @@
#ifndef STRONG_WITNESS_COMPLEX_H_
#define STRONG_WITNESS_COMPLEX_H_
+#include <gudhi/Active_witness/Active_witness.h>
+#include <gudhi/Kd_tree_search.h>
+
#include <utility>
#include <vector>
#include <list>
#include <limits>
-#include <gudhi/Active_witness/Active_witness.h>
-#include <gudhi/Kd_tree_search.h>
-
namespace Gudhi {
-
+
namespace witness_complex {
-/**
- * \private
+/* \private
* \class Strong_witness_complex
* \brief Constructs strong witness complex for a given table of nearest landmarks with respect to witnesses.
* \ingroup witness_complex
@@ -48,7 +47,7 @@ namespace witness_complex {
*/
template< class Nearest_landmark_table_ >
class Strong_witness_complex {
-private:
+ private:
typedef typename Nearest_landmark_table_::value_type Nearest_landmark_range;
typedef std::size_t Witness_id;
typedef std::size_t Landmark_id;
@@ -57,12 +56,11 @@ private:
typedef std::list< ActiveWitness > ActiveWitnessList;
typedef std::vector< Landmark_id > typeVectorVertex;
typedef std::vector<Nearest_landmark_range> Nearest_landmark_table_internal;
-
typedef Landmark_id Vertex_handle;
-
+
protected:
Nearest_landmark_table_internal nearest_landmark_table_;
-
+
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* @name Constructor
@@ -70,11 +68,9 @@ private:
//@{
- Strong_witness_complex()
- {
+ Strong_witness_complex() {
}
-
/**
* \brief Initializes member variables before constructing simplicial complex.
* \details Records nearest landmark table.
@@ -84,10 +80,9 @@ private:
* 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))
- {
+ : nearest_landmark_table_(std::begin(nearest_landmark_table), std::end(nearest_landmark_table)) {
}
-
+
/** \brief Outputs the strong witness complex of relaxation 'max_alpha_square'
* in a simplicial complex data structure.
* \details The function returns true if the construction is successful and false otherwise.
@@ -100,15 +95,15 @@ private:
template < typename SimplicialComplexForWitness >
bool create_complex(SimplicialComplexForWitness& complex,
double max_alpha_square,
- Landmark_id limit_dimension = std::numeric_limits<Landmark_id>::max()) const
- {
+ Landmark_id limit_dimension = std::numeric_limits<Landmark_id>::max()) const {
Landmark_id complex_dim = 0;
if (complex.num_vertices() > 0) {
std::cerr << "Strong witness complex cannot create complex - complex is not empty.\n";
return false;
}
if (max_alpha_square < 0) {
- std::cerr << "Strong witness complex cannot create complex - squared relaxation parameter must be non-negative.\n";
+ std::cerr << "Strong witness complex cannot create complex - squared relaxation parameter must be "
+ << "non-negative.\n";
return false;
}
if (limit_dimension < 0) {
@@ -129,7 +124,8 @@ private:
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, aw_it->second - aw.begin()->second, facet, complex);
+ add_all_faces_of_dimension(limit_dimension, vertices, vertices.begin(), aw_it,
+ aw_it->second - aw.begin()->second, facet, complex);
vertices.push_back(aw_it->first);
aw_it++;
}
@@ -140,13 +136,12 @@ private:
return true;
}
-private:
-
+ private:
/* \brief Adds recursively all the faces of a certain dimension dim-1 witnessed by the same witness.
- * Iterator is needed to know until how far we can take landmarks to form simplexes.
- * simplex is the prefix of the simplexes to insert.
- * The landmark pointed by aw_it is added to all formed simplices.
- */
+ * Iterator is needed to know until how far we can take landmarks to form simplexes.
+ * simplex is the prefix of the simplexes to insert.
+ * The landmark pointed by aw_it is added to all formed simplices.
+ */
template < typename SimplicialComplexForWitness >
void add_all_faces_of_dimension(Landmark_id dim,
typeVectorVertex& vertices,
@@ -154,9 +149,8 @@ private:
typename ActiveWitness::iterator aw_it,
double filtration_value,
typeVectorVertex& simplex,
- SimplicialComplexForWitness& sc) const
- {
- if (dim > 0)
+ SimplicialComplexForWitness& sc) const {
+ if (dim > 0) {
while (curr_it != vertices.end()) {
simplex.push_back(*curr_it);
++curr_it;
@@ -176,7 +170,7 @@ private:
simplex,
sc);
}
- else if (dim == 0) {
+ } 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 c09e6af9..c0506367 100644
--- a/src/Witness_complex/include/gudhi/Witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Witness_complex.h
@@ -33,7 +33,7 @@
#include <limits>
namespace Gudhi {
-
+
namespace witness_complex {
/**
@@ -49,7 +49,7 @@ namespace witness_complex {
*/
template< class Nearest_landmark_table_ >
class Witness_complex {
-private:
+ private:
typedef typename Nearest_landmark_table_::value_type Nearest_landmark_range;
typedef std::size_t Witness_id;
typedef std::size_t Landmark_id;
@@ -58,12 +58,11 @@ private:
typedef std::list< ActiveWitness > ActiveWitnessList;
typedef std::vector< Landmark_id > typeVectorVertex;
typedef std::vector<Nearest_landmark_range> Nearest_landmark_table_internal;
-
typedef Landmark_id Vertex_handle;
protected:
Nearest_landmark_table_internal nearest_landmark_table_;
-
+
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* @name Constructor
@@ -71,10 +70,9 @@ private:
//@{
- Witness_complex()
- {
+ Witness_complex() {
}
-
+
/**
* \brief Initializes member variables before constructing simplicial complex.
* \details Records nearest landmark table.
@@ -85,11 +83,9 @@ private:
*/
Witness_complex(Nearest_landmark_table_ const & nearest_landmark_table)
- : nearest_landmark_table_(std::begin(nearest_landmark_table), std::end(nearest_landmark_table))
- {
+ : nearest_landmark_table_(std::begin(nearest_landmark_table), std::end(nearest_landmark_table)) {
}
-
/** \brief Outputs the (weak) witness complex of relaxation 'max_alpha_square'
* in a simplicial complex data structure.
* \details The function returns true if the construction is successful and false otherwise.
@@ -102,8 +98,7 @@ private:
template < typename SimplicialComplexForWitness >
bool create_complex(SimplicialComplexForWitness& complex,
double max_alpha_square,
- std::size_t limit_dimension = std::numeric_limits<std::size_t>::max()) const
- {
+ std::size_t limit_dimension = std::numeric_limits<std::size_t>::max()) const {
if (complex.num_vertices() > 0) {
std::cerr << "Witness complex cannot create complex - complex is not empty.\n";
return false;
@@ -118,9 +113,9 @@ private:
}
ActiveWitnessList active_witnesses;
Landmark_id k = 0; /* current dimension in iterative construction */
- for (auto w: nearest_landmark_table_)
+ for (auto w : nearest_landmark_table_)
active_witnesses.push_back(ActiveWitness(w));
- while (!active_witnesses.empty() && k <= limit_dimension ) {
+ while (!active_witnesses.empty() && k <= limit_dimension) {
typename ActiveWitnessList::iterator aw_it = active_witnesses.begin();
std::vector<Landmark_id> simplex;
simplex.reserve(k+1);
@@ -134,10 +129,10 @@ private:
aw_it->end());
assert(simplex.empty());
if (!ok)
- active_witnesses.erase(aw_it++); //First increase the iterator and then erase the previous element
+ active_witnesses.erase(aw_it++); // First increase the iterator and then erase the previous element
else
aw_it++;
- }
+ }
k++;
}
complex.set_dimension(k-1);
@@ -159,13 +154,12 @@ private:
typename ActiveWitness::iterator curr_l,
std::vector<Landmark_id>& simplex,
SimplicialComplexForWitness& sc,
- typename ActiveWitness::iterator end) const
- {
+ typename ActiveWitness::iterator end) const {
if (curr_l == end)
return false;
bool will_be_active = false;
typename ActiveWitness::iterator l_it = curr_l;
- if (dim > 0)
+ if (dim > 0) {
for (; l_it->second - alpha2 <= norelax_dist2 && l_it != end; ++l_it) {
simplex.push_back(l_it->first);
if (sc.find(simplex) != sc.null_simplex()) {
@@ -183,8 +177,8 @@ private:
// If norelax_dist is infinity, change to first omitted distance
if (l_it->second <= norelax_dist2)
norelax_dist2 = l_it->second;
- }
- else if (dim == 0)
+ }
+ } else if (dim == 0) {
for (; l_it->second - alpha2 <= norelax_dist2 && l_it != end; ++l_it) {
simplex.push_back(l_it->first);
double filtration_value = 0;
@@ -200,12 +194,12 @@ private:
// If norelax_dist is infinity, change to first omitted distance
if (l_it->second < norelax_dist2)
norelax_dist2 = l_it->second;
- }
+ }
+ }
return will_be_active;
}
-
};
-
+
} // namespace witness_complex
} // namespace Gudhi
diff --git a/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h b/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h
index d009caca..b68d75a1 100644
--- a/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h
+++ b/src/Witness_complex/include/gudhi/Witness_complex/all_faces_in.h
@@ -1,3 +1,25 @@
+/* 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): Siargey Kachanovich
+ *
+ * Copyright (C) 2015 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 WITNESS_COMPLEX_ALL_FACES_IN_H_
#define WITNESS_COMPLEX_ALL_FACES_IN_H_
@@ -9,16 +31,14 @@ template < typename SimplicialComplexForWitness,
typename Simplex >
bool all_faces_in(Simplex& simplex,
double* filtration_value,
- SimplicialComplexForWitness& sc)
- {
+ SimplicialComplexForWitness& sc) {
typedef typename SimplicialComplexForWitness::Simplex_handle Simplex_handle;
if (simplex.size() == 1)
return true; /* Add vertices unconditionally */
-
+
Simplex facet;
- for (typename Simplex::iterator not_it = simplex.begin(); not_it != simplex.end(); ++not_it)
- {
+ for (typename Simplex::iterator not_it = simplex.begin(); not_it != simplex.end(); ++not_it) {
facet.clear();
for (typename Simplex::iterator it = simplex.begin(); it != simplex.end(); ++it)
if (it != not_it)