19 #ifndef PM_MATRIX_CELL_H
20 #define PM_MATRIX_CELL_H
26 namespace persistence_matrix {
37 template <
typename index>
50 template <
class Field_element_type>
61 template <
typename index>
105 std::swap(columnIndex_, other.columnIndex_);
120 template <
class Field_element_type>
158 const Field_element_type&
get_element()
const {
return element_; };
164 void set_element(
const Field_element_type& element) { element_ = element; }
170 std::swap(element_, other.element_);
175 Field_element_type element_;
188 template <
class Master_matrix>
189 class Cell :
public Master_matrix::Cell_column_index_option,
190 public Master_matrix::Cell_field_element_option,
191 public Master_matrix::row_hook_type,
192 public Master_matrix::column_hook_type
195 using col_opt =
typename Master_matrix::Cell_column_index_option;
196 using field_opt =
typename Master_matrix::Cell_field_element_option;
200 using index =
typename Master_matrix::index;
213 Cell(
id_index rowIndex) : col_opt(), field_opt(), rowIndex_(rowIndex){};
220 Cell(
index columnIndex,
id_index rowIndex) : col_opt(columnIndex), field_opt(), rowIndex_(rowIndex){};
227 : col_opt(static_cast<const col_opt&>(cell)),
228 field_opt(static_cast<const field_opt&>(cell)),
229 rowIndex_(cell.rowIndex_){};
236 : col_opt(std::move(
static_cast<col_opt&
>(cell))),
237 field_opt(std::move(
static_cast<field_opt&
>(cell))),
238 rowIndex_(std::exchange(cell.rowIndex_, 0)){};
257 col_opt::operator=(other);
258 field_opt::operator=(other);
259 std::swap(rowIndex_, other.rowIndex_);
293 operator std::pair<id_index, Field_element_type>()
const {
294 if constexpr (Master_matrix::Option_list::is_z2) {
295 return {rowIndex_, 1};
297 return {rowIndex_, field_opt::element_};
318 template <
class Master_matrix>
319 struct std::hash<
Gudhi::persistence_matrix::Cell<Master_matrix> > {
Class managing the column index access of a cell.
Definition: cell_types.h:63
void set_column_index(index columnIndex)
Sets the column index to the given value.
Definition: cell_types.h:99
Cell_column_index(Cell_column_index &&cell) noexcept
Move constructor.
Definition: cell_types.h:86
Cell_column_index & operator=(Cell_column_index other)
Assign operator.
Definition: cell_types.h:104
Cell_column_index(index columnIndex)
Stores the given column index.
Definition: cell_types.h:74
Cell_column_index()
Default constructor. Sets to the column index to -1.
Definition: cell_types.h:68
index get_column_index() const
Returns the MatIdx column index stored in the cell.
Definition: cell_types.h:93
Cell_column_index(const Cell_column_index &cell)
Copy constructor.
Definition: cell_types.h:80
Class managing the value access of a cell.
Definition: cell_types.h:122
Cell_field_element(const Cell_field_element &cell)
Copy constructor.
Definition: cell_types.h:139
Cell_field_element(Field_element_type element)
Stores the given element.
Definition: cell_types.h:133
const Field_element_type & get_element() const
Returns the value stored in the cell.
Definition: cell_types.h:158
Cell_field_element(Cell_field_element &&cell) noexcept
Move constructor.
Definition: cell_types.h:145
Cell_field_element()
Default constructor. Sets to the element to 0.
Definition: cell_types.h:127
Field_element_type & get_element()
Returns the value stored in the cell.
Definition: cell_types.h:152
Cell_field_element & operator=(Cell_field_element other)
Assign operator.
Definition: cell_types.h:169
void set_element(const Field_element_type &element)
Sets the value.
Definition: cell_types.h:164
Matrix cell class. Stores by default only the row index it belongs to, but can also store its column ...
Definition: cell_types.h:193
typename Master_matrix::id_index id_index
Definition: cell_types.h:201
Cell(index columnIndex, id_index rowIndex)
Constructs a cell with given row and column index. Other possible attributes are set at default value...
Definition: cell_types.h:220
friend bool operator==(const Cell &c1, const Cell &c2)
Equality comparator.
Definition: cell_types.h:280
Cell & operator=(Cell other)
Assign operator.
Definition: cell_types.h:256
Cell(id_index rowIndex)
Constructs a cell with given row index. Other possible attributes are set at default values.
Definition: cell_types.h:213
id_index get_row_index() const
Returns the row index stored in the cell.
Definition: cell_types.h:245
Master_matrix Master
Definition: cell_types.h:199
typename Master_matrix::index index
Definition: cell_types.h:200
Cell(const Cell &cell)
Copy constructor.
Definition: cell_types.h:226
Cell(Cell &&cell) noexcept
Move constructor.
Definition: cell_types.h:235
typename Master_matrix::element_type Field_element_type
Definition: cell_types.h:202
Cell()
Constructs an cell with all attributes at default values.
Definition: cell_types.h:207
friend bool operator<(const Cell &c1, const Cell &c2)
Strictly smaller than comparator.
Definition: cell_types.h:271
void set_row_index(id_index rowIndex)
Sets the row index stored in the cell.
Definition: cell_types.h:251
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Empty structure. Inheritated instead of Cell_column_index, when the row access is disabled.
Definition: cell_types.h:35
Empty structure. Inheritated instead of Cell_field_element, when PersistenceMatrixOptions::is_z2 is t...
Definition: cell_types.h:48