17 #ifndef PM_CHAIN_REP_CYCLES_H
18 #define PM_CHAIN_REP_CYCLES_H
25 namespace persistence_matrix {
48 template <
class Master_matrix>
52 using Bar =
typename Master_matrix::Bar;
54 using matrix_type =
typename Master_matrix::column_container_type;
103 base1.representativeCycles_.swap(base2.representativeCycles_);
104 base1.birthToCycle_.swap(base2.birthToCycle_);
108 using chain_matrix =
typename Master_matrix::Chain_matrix_type;
110 std::vector<cycle_type> representativeCycles_;
111 std::vector<typename Master_matrix::index> birthToCycle_;
114 constexpr chain_matrix* _matrix() {
return static_cast<chain_matrix*
>(
this); }
115 constexpr
const chain_matrix* _matrix()
const {
return static_cast<const chain_matrix*
>(
this); }
118 template <
class Master_matrix>
122 template <
class Master_matrix>
125 : representativeCycles_(matrixToCopy.representativeCycles_), birthToCycle_(matrixToCopy.birthToCycle_)
128 template <
class Master_matrix>
131 : representativeCycles_(std::move(other.representativeCycles_)), birthToCycle_(std::move(other.birthToCycle_))
134 template <
class Master_matrix>
137 birthToCycle_.clear();
138 birthToCycle_.resize(_matrix()->get_number_of_columns(), -1);
139 representativeCycles_.clear();
143 for (
typename Master_matrix::id_index i = 0; i < _matrix()->get_number_of_columns(); i++) {
144 auto& col = _matrix()->get_column(_matrix()->get_column_with_pivot(i));
145 if (!col.is_paired() || i < col.get_paired_chain_index()) {
147 for (
auto& c : col) {
148 cycle.push_back(c.get_row_index());
150 if constexpr (std::is_same_v<typename Master_matrix::Column_type, typename Master_matrix::Heap_column_type> ||
151 std::is_same_v<
typename Master_matrix::Column_type,
152 typename Master_matrix::Unordered_set_column_type>)
153 std::sort(cycle.begin(), cycle.end());
154 representativeCycles_.push_back(cycle);
155 birthToCycle_[i] = representativeCycles_.size() - 1;
160 template <
class Master_matrix>
161 inline const std::vector<typename Chain_representative_cycles<Master_matrix>::cycle_type>&
164 if (representativeCycles_.empty()) update_representative_cycles();
165 return representativeCycles_;
168 template <
class Master_matrix>
172 if (representativeCycles_.empty()) update_representative_cycles();
173 return representativeCycles_[birthToCycle_[bar.birth]];
176 template <
class Master_matrix>
180 representativeCycles_.
swap(other.representativeCycles_);
181 birthToCycle_.swap(other.birthToCycle_);
Class managing the representative cycles for Chain_matrix if the option was enabled.
Definition: chain_rep_cycles.h:50
typename Master_matrix::Bar Bar
Definition: chain_rep_cycles.h:52
Chain_representative_cycles & operator=(Chain_representative_cycles other)
Assign operator.
Definition: chain_rep_cycles.h:177
const std::vector< cycle_type > & get_representative_cycles()
Returns the current representative cycles. If the matrix is modified later after the first call,...
Definition: chain_rep_cycles.h:162
typename Master_matrix::cycle_type cycle_type
Definition: chain_rep_cycles.h:53
const cycle_type & get_representative_cycle(const Bar &bar)
Returns the representative cycle corresponding to the given bar. If the matrix is modified later afte...
Definition: chain_rep_cycles.h:170
void update_representative_cycles()
Computes the current representative cycles of the matrix.
Definition: chain_rep_cycles.h:135
friend void swap(Chain_representative_cycles &base1, Chain_representative_cycles &base2)
Swap operator.
Definition: chain_rep_cycles.h:102
Chain_representative_cycles()
Default constructor.
Definition: chain_rep_cycles.h:119
typename Master_matrix::column_container_type matrix_type
Definition: chain_rep_cycles.h:54
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Empty structure. Inheritated instead of Chain_representative_cycles, when the computation of the repr...
Definition: chain_rep_cycles.h:34