18#ifndef PM_CHAIN_REP_CYCLES_H
19#define PM_CHAIN_REP_CYCLES_H
26namespace persistence_matrix {
50template <
class Master_matrix>
54 using Bar =
typename Master_matrix::Bar;
55 using Cycle =
typename Master_matrix::Cycle;
105 base1.representativeCycles_.swap(base2.representativeCycles_);
106 base1.birthToCycle_.swap(base2.birthToCycle_);
110 using Master_chain_matrix =
typename Master_matrix::Master_chain_matrix;
112 std::vector<Cycle> representativeCycles_;
113 std::vector<typename Master_matrix::Index> birthToCycle_;
116 constexpr Master_chain_matrix* _matrix() {
return static_cast<Master_chain_matrix*
>(
this); }
117 constexpr const Master_chain_matrix* _matrix()
const {
return static_cast<const Master_chain_matrix*
>(
this); }
120template <
class Master_matrix>
124template <
class Master_matrix>
127 : representativeCycles_(matrixToCopy.representativeCycles_), birthToCycle_(matrixToCopy.birthToCycle_)
130template <
class Master_matrix>
133 : representativeCycles_(std::move(other.representativeCycles_)), birthToCycle_(std::move(other.birthToCycle_))
136template <
class Master_matrix>
139 birthToCycle_.clear();
140 birthToCycle_.resize(_matrix()->get_number_of_columns(), -1);
141 representativeCycles_.clear();
146 for (
typename Master_matrix::ID_index i = 0; i < _matrix()->get_number_of_columns(); i++) {
147 auto& col = _matrix()->get_column(_matrix()->get_column_with_pivot(i));
148 if (!col.is_paired() || i < col.get_paired_chain_index()) {
150 for (
auto& c : col) {
151 cycle.push_back(c.get_row_index());
153 if constexpr (std::is_same_v<typename Master_matrix::Column, typename Master_matrix::Matrix_heap_column> ||
154 std::is_same_v<typename Master_matrix::Column, typename Master_matrix::Matrix_unordered_set_column>)
155 std::sort(cycle.begin(), cycle.end());
156 representativeCycles_.push_back(cycle);
157 birthToCycle_[i] = representativeCycles_.size() - 1;
162template <
class Master_matrix>
163inline const std::vector<typename Chain_representative_cycles<Master_matrix>::Cycle>&
166 if (representativeCycles_.empty()) update_representative_cycles();
167 return representativeCycles_;
170template <
class Master_matrix>
174 if (representativeCycles_.empty()) update_representative_cycles();
175 return representativeCycles_[birthToCycle_[bar.birth]];
178template <
class Master_matrix>
182 representativeCycles_.
swap(other.representativeCycles_);
183 birthToCycle_.swap(other.birthToCycle_);
Class managing the representative cycles for Chain_matrix if the option was enabled.
Definition: chain_rep_cycles.h:52
typename Master_matrix::Bar Bar
Definition: chain_rep_cycles.h:54
Chain_representative_cycles & operator=(Chain_representative_cycles other)
Assign operator.
Definition: chain_rep_cycles.h:179
typename Master_matrix::Cycle Cycle
Definition: chain_rep_cycles.h:55
const std::vector< Cycle > & get_representative_cycles()
Returns the current representative cycles. If the matrix is modified later after the first call,...
Definition: chain_rep_cycles.h:164
void update_representative_cycles()
Computes the current representative cycles of the matrix.
Definition: chain_rep_cycles.h:137
friend void swap(Chain_representative_cycles &base1, Chain_representative_cycles &base2)
Swap operator.
Definition: chain_rep_cycles.h:104
const Cycle & 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:172
Chain_representative_cycles()
Default constructor.
Definition: chain_rep_cycles.h:121
typename Master_matrix::Column_container Column_container
Definition: chain_rep_cycles.h:56
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Empty structure. Inherited instead of Chain_representative_cycles, when the computation of the repres...
Definition: chain_rep_cycles.h:36