chain_pairing.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_PAIRING_H
18 #define PM_CHAIN_PAIRING_H
19 
20 #include <utility> //std::move
21 
22 namespace Gudhi {
23 namespace persistence_matrix {
24 
33  friend void swap([[maybe_unused]] Dummy_chain_pairing& d1, [[maybe_unused]] Dummy_chain_pairing& d2) {}
34 };
35 
44 template <class Master_matrix>
46 {
47  public:
48  using barcode_type = typename Master_matrix::barcode_type;
49  using dimension_type = typename Master_matrix::dimension_type;
54  Chain_pairing();
60  Chain_pairing(const Chain_pairing& matrixToCopy);
66  Chain_pairing(Chain_pairing&& other) noexcept;
67 
73  const barcode_type& get_current_barcode() const;
74 
82  friend void swap(Chain_pairing& pairing1, Chain_pairing& pairing2) {
83  pairing1.barcode_.swap(pairing2.barcode_);
84  pairing1.indexToBar_.swap(pairing2.indexToBar_);
85  std::swap(pairing1.nextPosition_, pairing2.nextPosition_);
86  }
87 
88  protected:
89  using dictionnary_type = typename Master_matrix::bar_dictionnary_type;
90  using pos_index = typename Master_matrix::pos_index;
91 
92  barcode_type barcode_;
93  dictionnary_type indexToBar_;
94  pos_index nextPosition_;
95 };
96 
97 template <class Master_matrix>
98 inline Chain_pairing<Master_matrix>::Chain_pairing() : nextPosition_(0)
99 {}
100 
101 template <class Master_matrix>
103  : barcode_(matrixToCopy.barcode_),
104  indexToBar_(matrixToCopy.indexToBar_),
105  nextPosition_(matrixToCopy.nextPosition_)
106 {}
107 
108 template <class Master_matrix>
110  : barcode_(std::move(other.barcode_)),
111  indexToBar_(std::move(other.indexToBar_)),
112  nextPosition_(std::exchange(other.nextPosition_, 0))
113 {}
114 
115 template <class Master_matrix>
117  const
118 {
119  return barcode_;
120 }
121 
122 template <class Master_matrix>
124 {
125  barcode_.swap(other.barcode_);
126  indexToBar_.swap(other.indexToBar_);
127  std::swap(nextPosition_, other.nextPosition_);
128  return *this;
129 }
130 
131 } // namespace persistence_matrix
132 } // namespace Gudhi
133 
134 #endif // PM_CHAIN_PAIRING_H
Class managing the barcode for Chain_matrix if the option was enabled.
Definition: chain_pairing.h:46
typename Master_matrix::dimension_type dimension_type
Definition: chain_pairing.h:49
friend void swap(Chain_pairing &pairing1, Chain_pairing &pairing2)
Swap operator.
Definition: chain_pairing.h:82
const barcode_type & get_current_barcode() const
Returns the current barcode which is maintained at any insertion, removal or vine swap.
Definition: chain_pairing.h:116
Chain_pairing()
Default constructor.
Definition: chain_pairing.h:98
typename Master_matrix::barcode_type barcode_type
Definition: chain_pairing.h:48
Chain_pairing & operator=(Chain_pairing other)
Assign operator.
Definition: chain_pairing.h:123
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Empty structure. Inheritated instead of Chain_pairing, when the computation of the barcode was not en...
Definition: chain_pairing.h:32