chain_column_extra_properties.h
Go to the documentation of this file.
1 /* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2  * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3  * Author(s): Hannah Schreiber
4  *
5  * Copyright (C) 2022-24 Inria
6  *
7  * Modification(s):
8  * - YYYY/MM Author: Description of the modification
9  */
10 
17 #ifndef PM_CHAIN_COLUMN_PROP_H
18 #define PM_CHAIN_COLUMN_PROP_H
19 
20 #include <utility> //std::swap
21 
22 namespace Gudhi {
23 namespace persistence_matrix {
24 
33 {
34  Dummy_chain_properties([[maybe_unused]] int pivot = 0, [[maybe_unused]] int pair = 0) {}
35 
36  friend void swap([[maybe_unused]] Dummy_chain_properties& col1, [[maybe_unused]] Dummy_chain_properties& col2) {}
37 };
38 
54 template <class Master_matrix>
56 {
57  public:
58  using index = typename Master_matrix::index;
59  using id_index = typename Master_matrix::id_index;
64  Chain_column_extra_properties() : pivot_(-1), pairedColumn_(-1) {}
71  Chain_column_extra_properties(id_index pivot) : pivot_(pivot), pairedColumn_(-1) {}
79  Chain_column_extra_properties(id_index pivot, index pair) : pivot_(pivot), pairedColumn_(pair) {}
86  : pivot_(col.pivot_), pairedColumn_(col.pairedColumn_) {}
93  : pivot_(std::exchange(col.pivot_, -1)), pairedColumn_(std::exchange(col.pairedColumn_, -1)) {}
94 
100  index get_paired_chain_index() const { return pairedColumn_; }
107  bool is_paired() const { return pairedColumn_ != static_cast<index>(-1); }
113  void assign_paired_chain(index other_col) { pairedColumn_ = other_col; }
117  void unassign_paired_chain() { pairedColumn_ = -1; };
118 
123  pivot_ = other.pivot_;
124  pairedColumn_ = other.pairedColumn_;
125  return *this;
126  }
131  std::swap(col1.pivot_, col2.pivot_);
132  std::swap(col1.pairedColumn_, col2.pairedColumn_);
133  }
134 
135  protected:
136  id_index get_pivot() const { return pivot_; }
137  void swap_pivots(Chain_column_extra_properties& other) { std::swap(pivot_, other.pivot_); }
138 
139  private:
140  id_index pivot_;
141  index pairedColumn_;
144 };
145 
146 } // namespace persistence_matrix
147 } // namespace Gudhi
148 
149 #endif // PM_CHAIN_COLUMN_PROP_H
Class managing the pivot and partitioning of columns in Chain_matrix.
Definition: chain_column_extra_properties.h:56
Chain_column_extra_properties & operator=(const Chain_column_extra_properties &other)
Assign operator.
Definition: chain_column_extra_properties.h:122
typename Master_matrix::index index
Definition: chain_column_extra_properties.h:58
void unassign_paired_chain()
Unpairs a column.
Definition: chain_column_extra_properties.h:117
Chain_column_extra_properties(id_index pivot, index pair)
Constructor setting the pivot and the pair at the given values.
Definition: chain_column_extra_properties.h:79
bool is_paired() const
Indicates if the column is paired or not.
Definition: chain_column_extra_properties.h:107
Chain_column_extra_properties(const Chain_column_extra_properties &col)
Copy constructor.
Definition: chain_column_extra_properties.h:85
void assign_paired_chain(index other_col)
Sets the value of the pair.
Definition: chain_column_extra_properties.h:113
Chain_column_extra_properties(id_index pivot)
Constructor setting the pivot at the given value and the pair to -1 (i.e. not paired).
Definition: chain_column_extra_properties.h:71
typename Master_matrix::id_index id_index
Definition: chain_column_extra_properties.h:59
friend void swap(Chain_column_extra_properties &col1, Chain_column_extra_properties &col2)
Swap operator.
Definition: chain_column_extra_properties.h:130
index get_paired_chain_index() const
Returns -1 if the column is not paired, the MatIdx of the pair otherwise.
Definition: chain_column_extra_properties.h:100
Chain_column_extra_properties(Chain_column_extra_properties &&col)
Move constructor.
Definition: chain_column_extra_properties.h:92
Chain_column_extra_properties()
Default constructor. Sets the pivot and pair to -1, which means "not existing".
Definition: chain_column_extra_properties.h:64
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Empty structure. Inheritated instead of Chain_column_extra_properties, when the columns are not meant...
Definition: chain_column_extra_properties.h:33