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
18#ifndef PM_CHAIN_PAIRING_H
19#define PM_CHAIN_PAIRING_H
20
21#include <utility> //std::move
22
23namespace Gudhi {
24namespace persistence_matrix {
25
34{
35 friend void swap([[maybe_unused]] Dummy_chain_pairing& d1, [[maybe_unused]] Dummy_chain_pairing& d2) {}
36};
37
46template <class Master_matrix>
48{
49 public:
50 using Barcode = typename Master_matrix::Barcode;
51 using Dimension = typename Master_matrix::Dimension;
62 Chain_pairing(const Chain_pairing& matrixToCopy);
68 Chain_pairing(Chain_pairing&& other) noexcept;
69
75 const Barcode& get_current_barcode() const;
76
84 friend void swap(Chain_pairing& pairing1, Chain_pairing& pairing2) {
85 pairing1.barcode_.swap(pairing2.barcode_);
86 pairing1.indexToBar_.swap(pairing2.indexToBar_);
87 std::swap(pairing1.nextPosition_, pairing2.nextPosition_);
88 }
89
90 protected:
91 using Dictionary = typename Master_matrix::Bar_dictionary;
92 using Pos_index = typename Master_matrix::Pos_index;
93
94 Barcode barcode_;
95 Dictionary indexToBar_;
96 Pos_index nextPosition_;
97};
98
99template <class Master_matrix>
101{}
102
103template <class Master_matrix>
105 : barcode_(matrixToCopy.barcode_),
106 indexToBar_(matrixToCopy.indexToBar_),
107 nextPosition_(matrixToCopy.nextPosition_)
108{}
109
110template <class Master_matrix>
112 : barcode_(std::move(other.barcode_)),
113 indexToBar_(std::move(other.indexToBar_)),
114 nextPosition_(std::exchange(other.nextPosition_, 0))
115{}
116
117template <class Master_matrix>
119 const
120{
121 return barcode_;
122}
123
124template <class Master_matrix>
126{
127 barcode_.swap(other.barcode_);
128 indexToBar_.swap(other.indexToBar_);
129 std::swap(nextPosition_, other.nextPosition_);
130 return *this;
131}
132
133} // namespace persistence_matrix
134} // namespace Gudhi
135
136#endif // PM_CHAIN_PAIRING_H
Class managing the barcode for Chain_matrix if the option was enabled.
Definition: chain_pairing.h:48
const Barcode & get_current_barcode() const
Returns the current barcode which is maintained at any insertion, removal or vine swap.
Definition: chain_pairing.h:118
typename Master_matrix::Dimension Dimension
Definition: chain_pairing.h:51
friend void swap(Chain_pairing &pairing1, Chain_pairing &pairing2)
Swap operator.
Definition: chain_pairing.h:84
Chain_pairing()
Default constructor.
Definition: chain_pairing.h:100
typename Master_matrix::Barcode Barcode
Definition: chain_pairing.h:50
Chain_pairing & operator=(Chain_pairing other)
Assign operator.
Definition: chain_pairing.h:125
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Empty structure. Inherited instead of Chain_pairing, when the computation of the barcode was not enab...
Definition: chain_pairing.h:34