Loading...
Searching...
No Matches
chain_pairing.h
Go to the documentation of this file.
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Hannah Schreiber
*
* Copyright (C) 2022-24 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/
#ifndef PM_CHAIN_PAIRING_H
#define PM_CHAIN_PAIRING_H
#include <utility> //std::move
namespace Gudhi {
namespace persistence_matrix {
struct Dummy_chain_pairing
{
friend void swap([[maybe_unused]] Dummy_chain_pairing& d1, [[maybe_unused]] Dummy_chain_pairing& d2) {}
};
template <class Master_matrix>
class Chain_pairing
{
public:
using Barcode = typename Master_matrix::Barcode;
using Dimension = typename Master_matrix::Dimension;
Chain_pairing();
Chain_pairing(const Chain_pairing& matrixToCopy);
Chain_pairing(Chain_pairing&& other) noexcept;
const Barcode& get_current_barcode() const;
Chain_pairing& operator=(Chain_pairing other);
friend void swap(Chain_pairing& pairing1, Chain_pairing& pairing2) {
pairing1.barcode_.swap(pairing2.barcode_);
pairing1.indexToBar_.swap(pairing2.indexToBar_);
std::swap(pairing1.nextPosition_, pairing2.nextPosition_);
}
protected:
using Dictionary = typename Master_matrix::Bar_dictionary;
using Pos_index = typename Master_matrix::Pos_index;
Barcode barcode_;
Dictionary indexToBar_;
Pos_index nextPosition_;
};
template <class Master_matrix>
inline Chain_pairing<Master_matrix>::Chain_pairing() : nextPosition_(0)
{}
template <class Master_matrix>
inline Chain_pairing<Master_matrix>::Chain_pairing(const Chain_pairing& matrixToCopy)
: barcode_(matrixToCopy.barcode_),
indexToBar_(matrixToCopy.indexToBar_),
nextPosition_(matrixToCopy.nextPosition_)
{}
template <class Master_matrix>
inline Chain_pairing<Master_matrix>::Chain_pairing(Chain_pairing<Master_matrix>&& other) noexcept
: barcode_(std::move(other.barcode_)),
indexToBar_(std::move(other.indexToBar_)),
nextPosition_(std::exchange(other.nextPosition_, 0))
{}
template <class Master_matrix>
inline const typename Chain_pairing<Master_matrix>::Barcode& Chain_pairing<Master_matrix>::get_current_barcode()
const
{
return barcode_;
}
template <class Master_matrix>
inline Chain_pairing<Master_matrix>& Chain_pairing<Master_matrix>::operator=(Chain_pairing<Master_matrix> other)
{
barcode_.swap(other.barcode_);
indexToBar_.swap(other.indexToBar_);
std::swap(nextPosition_, other.nextPosition_);
return *this;
}
} // namespace persistence_matrix
} // namespace Gudhi
#endif // PM_CHAIN_PAIRING_H
Gudhi::persistence_matrix::Chain_pairing::get_current_barcode
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
Gudhi::persistence_matrix::Chain_pairing::Dimension
typename Master_matrix::Dimension Dimension
Definition chain_pairing.h:51
Gudhi::persistence_matrix::Chain_pairing::swap
friend void swap(Chain_pairing &pairing1, Chain_pairing &pairing2)
Swap operator.
Definition chain_pairing.h:84
Gudhi::persistence_matrix::Chain_pairing::Chain_pairing
Chain_pairing()
Default constructor.
Definition chain_pairing.h:100
Gudhi::persistence_matrix::Chain_pairing::Barcode
typename Master_matrix::Barcode Barcode
Definition chain_pairing.h:50
Gudhi::persistence_matrix::Chain_pairing::operator=
Chain_pairing & operator=(Chain_pairing other)
Assign operator.
Definition chain_pairing.h:125
Gudhi::persistence_matrix
Persistence matrix namespace.
Definition FieldOperators.h:18
Gudhi
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14
Gudhi::persistence_matrix::Dummy_chain_pairing
Empty structure. Inherited instead of Chain_pairing, when the computation of the barcode was not enab...
Definition chain_pairing.h:34