17 #ifndef PM_RU_REP_CYCLES_H
18 #define PM_RU_REP_CYCLES_H
25 namespace persistence_matrix {
48 template <
class Master_matrix>
52 using index =
typename Master_matrix::index;
53 using Bar =
typename Master_matrix::Bar;
103 base1.representativeCycles_.swap(base2.representativeCycles_);
104 base1.birthToCycle_.swap(base2.birthToCycle_);
108 using ru_matrix =
typename Master_matrix::RU_matrix_type;
110 std::vector<cycle_type> representativeCycles_;
111 std::vector<index> birthToCycle_;
113 constexpr ru_matrix* _matrix() {
return static_cast<ru_matrix*
>(
this); }
114 constexpr
const ru_matrix* _matrix()
const {
return static_cast<const ru_matrix*
>(
this); }
117 template <
class Master_matrix>
121 template <
class Master_matrix>
124 : representativeCycles_(matrixToCopy.representativeCycles_), birthToCycle_(matrixToCopy.birthToCycle_)
127 template <
class Master_matrix>
130 : representativeCycles_(std::move(other.representativeCycles_)), birthToCycle_(std::move(other.birthToCycle_))
133 template <
class Master_matrix>
136 if constexpr (Master_matrix::Option_list::has_vine_update) {
137 birthToCycle_.clear();
138 birthToCycle_.resize(_matrix()->reducedMatrixR_.get_number_of_columns(), -1);
140 for (
index i = 0; i < _matrix()->reducedMatrixR_.get_number_of_columns(); i++) {
141 if (_matrix()->reducedMatrixR_.is_zero_column(i)) {
142 birthToCycle_[i] = c;
146 representativeCycles_.clear();
147 representativeCycles_.resize(c);
148 for (
index i = 0; i < _matrix()->mirrorMatrixU_.get_number_of_columns(); i++) {
149 for (
const auto& cell : _matrix()->mirrorMatrixU_.get_column(i)) {
150 auto idx = birthToCycle_[cell.get_row_index()];
151 if (idx !=
static_cast<index>(-1)) {
152 representativeCycles_[idx].push_back(i);
157 birthToCycle_.clear();
158 birthToCycle_.resize(_matrix()->reducedMatrixR_.get_number_of_columns(), -1);
159 for (
index i = 0; i < _matrix()->reducedMatrixR_.get_number_of_columns(); i++) {
160 if (_matrix()->reducedMatrixR_.is_zero_column(i)) {
161 representativeCycles_.push_back(
cycle_type());
162 for (
const auto& cell : _matrix()->mirrorMatrixU_.get_column(i)) {
163 representativeCycles_.back().push_back(cell.get_row_index());
165 if constexpr (std::is_same_v<typename Master_matrix::Column_type, typename Master_matrix::Heap_column_type> ||
166 std::is_same_v<
typename Master_matrix::Column_type,
167 typename Master_matrix::Unordered_set_column_type>)
168 std::sort(representativeCycles_.back().begin(), representativeCycles_.back().end());
169 birthToCycle_[i] = representativeCycles_.size() - 1;
175 template <
class Master_matrix>
176 inline const std::vector<typename RU_representative_cycles<Master_matrix>::cycle_type>&
179 if (representativeCycles_.empty()) update_representative_cycles();
180 return representativeCycles_;
183 template <
class Master_matrix>
187 if (representativeCycles_.empty()) update_representative_cycles();
188 return representativeCycles_[birthToCycle_[bar.birth]];
191 template <
class Master_matrix>
195 representativeCycles_.
swap(other.representativeCycles_);
196 birthToCycle_.swap(other.birthToCycle_);
Class managing the representative cycles for RU_matrix if the option was enabled.
Definition: ru_rep_cycles.h:50
RU_representative_cycles()
Default constructor.
Definition: ru_rep_cycles.h:118
friend void swap(RU_representative_cycles &base1, RU_representative_cycles &base2)
Swap operator.
Definition: ru_rep_cycles.h:102
typename Master_matrix::Bar Bar
Definition: ru_rep_cycles.h:53
typename Master_matrix::cycle_type cycle_type
Definition: ru_rep_cycles.h:54
const std::vector< cycle_type > & get_representative_cycles()
Returns the current representative cycles. If the matrix is modified later after the first call,...
Definition: ru_rep_cycles.h:177
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: ru_rep_cycles.h:185
void update_representative_cycles()
Computes the current representative cycles of the matrix.
Definition: ru_rep_cycles.h:134
typename Master_matrix::index index
Definition: ru_rep_cycles.h:52
RU_representative_cycles & operator=(RU_representative_cycles other)
Assign operator.
Definition: ru_rep_cycles.h:192
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Empty structure. Inheritated instead of RU_representative_cycles, when the computation of the represe...
Definition: ru_rep_cycles.h:34