diff options
author | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-09-22 16:43:54 +0200 |
---|---|---|
committer | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-09-22 16:43:54 +0200 |
commit | e0041b766b647f3906b52f861e97edba1f089312 (patch) | |
tree | 693206fa60c757346750461922e107e5f16f5c0a /src/Coxeter_triangulation/include/gudhi/Permutahedral_representation | |
parent | cba4b7047cc8665a3f20e2334358a4ca28bf021a (diff) |
include what you use
Diffstat (limited to 'src/Coxeter_triangulation/include/gudhi/Permutahedral_representation')
8 files changed, 97 insertions, 99 deletions
diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Combination_iterator.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Combination_iterator.h index 36bf4b55..ce6a34ec 100644 --- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Combination_iterator.h +++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Combination_iterator.h @@ -83,7 +83,7 @@ public: } } -protected: + private: value_t value_; // the dereference value bool is_end_; // is true when the current permutation is the final one diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Integer_combination_iterator.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Integer_combination_iterator.h index 8bf75711..c4e86a36 100644 --- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Integer_combination_iterator.h +++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Integer_combination_iterator.h @@ -25,11 +25,11 @@ typedef unsigned uint; * Based on the algorithm by Mifsud. */ class Integer_combination_iterator : public boost::iterator_facade< Integer_combination_iterator, - std::vector<uint> const, - boost::forward_traversal_tag> { - typedef std::vector<uint> value_t; + std::vector<uint> const, + boost::forward_traversal_tag> { + using value_t = std::vector<uint>; -protected: + private: friend class boost::iterator_core_access; bool equal(Integer_combination_iterator const& other) const { @@ -71,7 +71,6 @@ protected: } public: - template <class Bound_range> Integer_combination_iterator(const uint& n, const uint& k, const Bound_range& bounds) : @@ -109,8 +108,8 @@ public: // Used for the creating an end iterator Integer_combination_iterator() : is_end_(true), n_(0), k_(0) {} - -protected: + + private: value_t value_; // the dereference value bool is_end_; // is true when the current integer combination is the final one diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Ordered_set_partition_iterator.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Ordered_set_partition_iterator.h index 73b98337..d6f9f121 100644 --- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Ordered_set_partition_iterator.h +++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Ordered_set_partition_iterator.h @@ -13,8 +13,10 @@ #include <vector> #include <limits> + #include <gudhi/Permutahedral_representation/Permutation_iterator.h> #include <gudhi/Permutahedral_representation/Set_partition_iterator.h> + #include <boost/range/iterator_range.hpp> namespace Gudhi { @@ -48,11 +50,11 @@ struct Ordered_set_partition { * */ class Ordered_set_partition_iterator : public boost::iterator_facade< Ordered_set_partition_iterator, - Ordered_set_partition const, - boost::forward_traversal_tag> { - typedef Ordered_set_partition value_t; + Ordered_set_partition const, + boost::forward_traversal_tag> { + using value_t = Ordered_set_partition; -protected: + private: friend class boost::iterator_core_access; bool equal(Ordered_set_partition_iterator const& other) const { @@ -66,22 +68,19 @@ protected: void increment() { if (++value_.p_it_ == p_end_) { if (++value_.s_it_ == s_end_) { - is_end_ = true; - return; + is_end_ = true; + return; } else - value_.p_it_.reinitialize(); + value_.p_it_.reinitialize(); } } -public: - + public: Ordered_set_partition_iterator(const uint& n, const uint& k) : value_({Set_partition_iterator(n,k), Permutation_iterator(k)}), - is_end_(n == 0) - { - } + is_end_(n == 0) {} // Used for the creating an end iterator Ordered_set_partition_iterator() : is_end_(true) {} @@ -92,7 +91,7 @@ public: value_.s_it_.reinitialize(); } -protected: + private: Set_partition_iterator s_end_; // Set partition iterator and the corresponding end iterator Permutation_iterator p_end_; // Permutation iterator and the corresponding end iterator value_t value_; // the dereference value diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h index e892b73b..d42e892a 100644 --- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h +++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h @@ -20,7 +20,7 @@ #include <vector> #include <iostream> -#include <algorithm> +#include <algorithm> // for std::find namespace Gudhi { @@ -37,15 +37,15 @@ namespace coxeter_triangulation { * Forward iterator, 'value_type' is Permutahedral_representation::Vertex.*/ template <class Permutahedral_representation> class Vertex_iterator : public boost::iterator_facade< Vertex_iterator<Permutahedral_representation>, - typename Permutahedral_representation::Vertex const, - boost::forward_traversal_tag> { -protected: + typename Permutahedral_representation::Vertex const, + boost::forward_traversal_tag> { + private: friend class boost::iterator_core_access; using Vertex = typename Permutahedral_representation::Vertex; using Ordered_partition = typename Permutahedral_representation::OrderedSetPartition; - typedef Vertex value_t; + using value_t = Vertex; bool equal(Vertex_iterator const& other) const { @@ -60,12 +60,12 @@ protected: std::size_t d = value_.size(); for (auto i: *o_it_) if (i != d) - value_[i]++; + value_[i]++; else - for (std::size_t j = 0; j < d; j++) - value_[j]--; + for (std::size_t j = 0; j < d; j++) + value_[j]--; } - + void increment() { if (is_end_) return; @@ -84,9 +84,8 @@ public: {} Vertex_iterator() : is_end_(true) {} - - -protected: + + private: typename Ordered_partition::const_iterator o_it_, o_end_; value_t value_; bool is_end_; @@ -100,11 +99,11 @@ protected: * Forward iterator, value_type is Permutahedral_representation. */ template <class Permutahedral_representation> class Face_iterator : public boost::iterator_facade< Face_iterator<Permutahedral_representation>, - Permutahedral_representation const, - boost::forward_traversal_tag> { - typedef Permutahedral_representation value_t; + Permutahedral_representation const, + boost::forward_traversal_tag> { + using value_t = Permutahedral_representation; -protected: + private: friend class boost::iterator_core_access; using Vertex = typename Permutahedral_representation::Vertex; @@ -130,9 +129,8 @@ protected: // Combination *c_it_ is supposed to be sorted in increasing order value_ = face_from_indices<Permutahedral_representation>(simplex_, *c_it_); } - + public: - Face_iterator(const Permutahedral_representation& simplex, const uint& k) : simplex_(simplex), k_(k), @@ -147,7 +145,7 @@ public: // Used for the creating an end iterator Face_iterator() : is_end_(true) {} -protected: + private: Permutahedral_representation simplex_; // Input simplex uint k_; uint l_; // Dimension of the input simplex @@ -165,11 +163,11 @@ protected: * Forward iterator, value_type is Permutahedral_representation. */ template <class Permutahedral_representation> class Coface_iterator : public boost::iterator_facade< Coface_iterator<Permutahedral_representation>, - Permutahedral_representation const, - boost::forward_traversal_tag> { - typedef Permutahedral_representation value_t; - -protected: + Permutahedral_representation const, + boost::forward_traversal_tag> { + using value_t = Permutahedral_representation; + + private: friend class boost::iterator_core_access; using Vertex = typename Permutahedral_representation::Vertex; @@ -187,20 +185,20 @@ protected: uint i = 0; for (; i < k_+1; i++) { if (++(o_its_[i]) != o_end_) - break; + break; } if (i == k_+1) { if (++i_it_ == i_end_) { - is_end_ = true; - return; + is_end_ = true; + return; } o_its_.clear(); for (uint j = 0; j < k_ + 1; j++) - o_its_.emplace_back(Ordered_set_partition_iterator(simplex_.partition()[j].size(), (*i_it_)[j]+1)); + o_its_.emplace_back(Ordered_set_partition_iterator(simplex_.partition()[j].size(), (*i_it_)[j]+1)); } else for (uint j = 0; j < i; j++) - o_its_[j].reinitialize(); + o_its_[j].reinitialize(); update_value(); } @@ -212,30 +210,29 @@ protected: for (; u_ <= (*i_it_)[k_]; u_++) { auto range = (*o_its_[k_])[u_]; if (std::find(range.begin(), range.end(), t_) != range.end()) - break; + break; } uint i = 0; for (uint j = u_+1; j <= (*i_it_)[k_]; j++, i++) for (uint b: (*o_its_[k_])[j]) { - uint c = simplex_.partition()[k_][b]; + uint c = simplex_.partition()[k_][b]; value_.partition()[i].push_back(c); - value_.vertex()[c]--; + value_.vertex()[c]--; } for (uint h = 0; h < k_; h++) for (uint j = 0; j <= (*i_it_)[h]; j++, i++) { - for (uint b: (*o_its_[h])[j]) - value_.partition()[i].push_back(simplex_.partition()[h][b]); + for (uint b: (*o_its_[h])[j]) + value_.partition()[i].push_back(simplex_.partition()[h][b]); } for (uint j = 0; j <= u_; j++, i++) for (uint b: (*o_its_[k_])[j]) - value_.partition()[i].push_back(simplex_.partition()[k_][b]); + value_.partition()[i].push_back(simplex_.partition()[k_][b]); // sort the values in each part (probably not needed) for (auto& part: value_.partition()) std::sort(part.begin(), part.end()); } - -public: - + + public: Coface_iterator(const Permutahedral_representation& simplex, const uint& l) : simplex_(simplex), d_(simplex.vertex().size()), @@ -248,8 +245,8 @@ public: uint j = 0; for (; j < simplex_.partition()[k_].size(); j++) if (simplex_.partition()[k_][j] == d_) { - t_ = j; - break; + t_ = j; + break; } if (j == simplex_.partition()[k_].size()) { std::cerr << "Coface iterator: the argument simplex is not a permutahedral representation\n"; @@ -263,8 +260,8 @@ public: // Used for the creating an end iterator Coface_iterator() : is_end_(true) {} - -protected: + + private: Permutahedral_representation simplex_; // Input simplex uint d_; // Ambient dimension uint l_; // Dimension of the coface diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutation_iterator.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutation_iterator.h index ed1fb337..e0142bf4 100644 --- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutation_iterator.h +++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutation_iterator.h @@ -11,7 +11,9 @@ #ifndef PERMUTAHEDRAL_REPRESENTATION_PERMUTATION_ITERATOR_H_ #define PERMUTAHEDRAL_REPRESENTATION_PERMUTATION_ITERATOR_H_ +#include <cstdlib> // for std::size_t #include <vector> + #include <boost/range/iterator_range.hpp> namespace Gudhi { @@ -24,11 +26,11 @@ typedef unsigned uint; * Based on the optimization of the Heap's algorithm by Sedgewick. */ class Permutation_iterator : public boost::iterator_facade< Permutation_iterator, - std::vector<uint> const, - boost::forward_traversal_tag> { - typedef std::vector<uint> value_t; + std::vector<uint> const, + boost::forward_traversal_tag> { + using value_t = std::vector<uint>; -protected: + private: friend class boost::iterator_core_access; bool equal(Permutation_iterator const& other) const { @@ -70,12 +72,12 @@ protected: ct_ = 5; uint j = 2; while (d_[j] == j+1) { - d_[j] = 0; - ++j; + d_[j] = 0; + ++j; } if (j == n_ - 1) { - is_end_ = true; - return; + is_end_ = true; + return; } uint k = j+1; uint x = (k%2 ? d_[j] : 0); @@ -117,8 +119,8 @@ public: if (n_ > 0) is_end_ = false; } - -protected: + + private: value_t value_; // the dereference value bool is_end_; // is true when the current permutation is the final one bool optim_3_; // true if n>=3. for n >= 3, the algorithm is optimized diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Set_partition_iterator.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Set_partition_iterator.h index 26bbc1ef..bd1770bc 100644 --- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Set_partition_iterator.h +++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Set_partition_iterator.h @@ -25,11 +25,11 @@ typedef unsigned uint; * */ class Set_partition_iterator : public boost::iterator_facade< Set_partition_iterator, - std::vector<std::vector<uint> > const, - boost::forward_traversal_tag> { - typedef std::vector<std::vector<uint> > value_t; - -protected: + std::vector<std::vector<uint> > const, + boost::forward_traversal_tag> { + using value_t = std::vector<std::vector<uint>>; + + private: friend class boost::iterator_core_access; bool equal(Set_partition_iterator const& other) const { @@ -54,7 +54,7 @@ protected: } uint i = n_ - 1; while (rgs_[i] + 1 > max_[i] || - rgs_[i] + 1 >= k_) + rgs_[i] + 1 >= k_) i--; if (i == 0) { is_end_ = true; @@ -71,16 +71,15 @@ protected: uint p = k_; if (mm < p) do { - max_[i] = p; - --i; - --p; - rgs_[i] = p; + max_[i] = p; + --i; + --p; + rgs_[i] = p; } while (max_[i] < p); update_value(); } -public: - + public: Set_partition_iterator(const uint& n, const uint& k) : value_(k), @@ -116,12 +115,12 @@ public: max_[i] = rgs_[i-1] + 1; update_value(); } - -protected: + + private: value_t value_; // the dereference value std::vector<uint> rgs_; // restricted growth string std::vector<uint> max_; // max_[i] = max(rgs_[0],...,rgs[i-1]) + 1 - bool is_end_; // is true when the current permutation is the final one + bool is_end_; // is true when the current permutation is the final one uint n_; uint k_; diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h index 262915fb..f41335e9 100644 --- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h +++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h @@ -11,8 +11,9 @@ #ifndef PERMUTAHEDRAL_REPRESENTATION_SIZE_RANGE_H_ #define PERMUTAHEDRAL_REPRESENTATION_SIZE_RANGE_H_ +#include <cstdlib> // for std::size_t + #include <boost/range/iterator_range.hpp> -#include <cstdlib> // std::size_t namespace Gudhi { @@ -22,11 +23,11 @@ namespace coxeter_triangulation { */ template <class T_it> class Size_iterator : public boost::iterator_facade< Size_iterator<T_it>, - std::size_t const, - boost::forward_traversal_tag> { + std::size_t const, + boost::forward_traversal_tag> { friend class boost::iterator_core_access; -protected: + private: bool equal(Size_iterator const& other) const { return (is_end_ && other.is_end_); } @@ -43,15 +44,14 @@ protected: value_ = t_it_->size()-1; } -public: - + public: Size_iterator(const T_it& t_begin, const T_it& t_end) : t_it_(t_begin), t_end_(t_end), is_end_(t_begin == t_end) { if (!is_end_) value_ = t_it_->size()-1; } -protected: + private: T_it t_it_, t_end_; bool is_end_; std::size_t value_; @@ -61,7 +61,7 @@ template <class T> class Size_range { const T& t_; -public: + public: typedef Size_iterator<typename T::const_iterator> iterator; Size_range(const T& t) : t_(t) {} diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/face_from_indices.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/face_from_indices.h index c658a06d..21ee3c8b 100644 --- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/face_from_indices.h +++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/face_from_indices.h @@ -15,6 +15,9 @@ namespace Gudhi { namespace coxeter_triangulation { +#include <cstdlib> // for std::size_t +#include <algorithm> + /** \brief Computes the permutahedral representation of a face of a given simplex * and a range of the vertex indices that compose the face. * @@ -25,10 +28,9 @@ namespace coxeter_triangulation { * @param[in] simplex Input simplex. * @param[in] indices Input range of indices. */ -template <class Permutahedral_representation, - class Index_range> +template <class Permutahedral_representation, class Index_range> Permutahedral_representation face_from_indices(const Permutahedral_representation& simplex, - const Index_range& indices) { + const Index_range& indices) { using range_index = typename Index_range::value_type; using Ordered_set_partition = typename Permutahedral_representation::OrderedSetPartition; using Part = typename Ordered_set_partition::value_type; |