18 #ifndef PM_SET_COLUMN_H
19 #define PM_SET_COLUMN_H
23 #include <type_traits>
27 #include <boost/iterator/indirect_iterator.hpp>
33 namespace persistence_matrix {
47 template <
class Master_matrix>
53 using Master = Master_matrix;
54 using index =
typename Master_matrix::index;
55 using id_index =
typename Master_matrix::id_index;
56 using dimension_type =
typename Master_matrix::dimension_type;
57 using Field_element_type =
typename Master_matrix::element_type;
58 using Cell =
typename Master_matrix::Cell_type;
59 using Column_settings =
typename Master_matrix::Column_settings;
62 using Field_operators =
typename Master_matrix::Field_operators;
64 struct CellPointerComp {
65 bool operator()(
const Cell* c1,
const Cell* c2)
const {
return *c1 < *c2; }
68 using Column_type = std::set<Cell*, CellPointerComp>;
69 using Cell_constructor =
typename Master_matrix::Cell_constructor;
72 using iterator = boost::indirect_iterator<typename Column_type::iterator>;
73 using const_iterator = boost::indirect_iterator<typename Column_type::const_iterator>;
74 using reverse_iterator = boost::indirect_iterator<typename Column_type::reverse_iterator>;
75 using const_reverse_iterator = boost::indirect_iterator<typename Column_type::const_reverse_iterator>;
77 Set_column(Column_settings* colSettings =
nullptr);
78 template <
class Container_type =
typename Master_matrix::boundary_type>
79 Set_column(
const Container_type& nonZeroRowIndices, Column_settings* colSettings);
80 template <
class Container_type =
typename Master_matrix::boundary_type,
class Row_container_type>
82 const Container_type& nonZeroRowIndices,
83 Row_container_type* rowContainer,
84 Column_settings* colSettings);
85 template <
class Container_type =
typename Master_matrix::boundary_type>
86 Set_column(
const Container_type& nonZeroChainRowIndices,
87 dimension_type dimension,
88 Column_settings* colSettings);
89 template <
class Container_type =
typename Master_matrix::boundary_type,
class Row_container_type>
91 const Container_type& nonZeroChainRowIndices,
92 dimension_type dimension,
93 Row_container_type* rowContainer,
94 Column_settings* colSettings);
96 Column_settings* colSettings =
nullptr);
97 template <
class Row_container_type>
100 Row_container_type* rowContainer,
101 Column_settings* colSettings =
nullptr);
105 std::vector<Field_element_type> get_content(
int columnLength = -1)
const;
106 bool is_non_zero(id_index rowIndex)
const;
107 bool is_empty()
const;
108 std::size_t size()
const;
110 template <
class Map_type>
111 void reorder(
const Map_type& valueMap, [[maybe_unused]] index columnIndex = -1);
113 void clear(id_index rowIndex);
115 id_index get_pivot()
const;
116 Field_element_type get_pivot_value()
const;
118 iterator begin() noexcept;
119 const_iterator begin()
const noexcept;
120 iterator end() noexcept;
121 const_iterator end()
const noexcept;
122 reverse_iterator rbegin() noexcept;
123 const_reverse_iterator rbegin()
const noexcept;
124 reverse_iterator rend() noexcept;
125 const_reverse_iterator rend()
const noexcept;
127 template <
class Cell_range>
128 Set_column& operator+=(
const Cell_range& column);
134 template <
class Cell_range>
135 Set_column& multiply_target_and_add(
const Field_element_type& val,
const Cell_range& column);
138 template <
class Cell_range>
139 Set_column& multiply_source_and_add(
const Cell_range& column,
const Field_element_type& val);
143 if (&c1 == &c2)
return true;
145 auto it1 = c1.column_.begin();
146 auto it2 = c2.column_.begin();
147 if (c1.column_.size() != c2.column_.size())
return false;
148 while (it1 != c1.column_.end() && it2 != c2.column_.end()) {
149 if constexpr (Master_matrix::Option_list::is_z2) {
150 if ((*it1)->get_row_index() != (*it2)->get_row_index())
return false;
152 if ((*it1)->get_row_index() != (*it2)->get_row_index() || (*it1)->get_element() != (*it2)->get_element())
161 if (&c1 == &c2)
return false;
163 auto it1 = c1.column_.begin();
164 auto it2 = c2.column_.begin();
165 while (it1 != c1.column_.end() && it2 != c2.column_.end()) {
166 if ((*it1)->get_row_index() != (*it2)->get_row_index())
return (*it1)->get_row_index() < (*it2)->get_row_index();
167 if constexpr (!Master_matrix::Option_list::is_z2) {
168 if ((*it1)->get_element() != (*it2)->get_element())
return (*it1)->get_element() < (*it2)->get_element();
173 return it2 != c2.column_.end();
186 col1.column_.swap(col2.column_);
187 std::swap(col1.operators_, col2.operators_);
188 std::swap(col1.cellPool_, col2.cellPool_);
197 Field_operators* operators_;
198 Cell_constructor* cellPool_;
200 template <
class Column_type,
class Cell_iterator,
typename F1,
typename F2,
typename F3,
typename F4>
201 friend void _generic_merge_cell_to_column(Column_type& targetColumn,
202 Cell_iterator& itSource,
203 typename Column_type::Column_type::iterator& itTarget,
208 bool& pivotIsZeroed);
209 template <
class Column_type,
class Cell_range,
typename F1,
typename F2,
typename F3,
typename F4,
typename F5>
210 friend bool _generic_add_to_column(
const Cell_range& source,
211 Column_type& targetColumn,
217 template <
class Column_type,
class Cell_range>
218 friend bool _add_to_column(
const Cell_range& source, Column_type& targetColumn);
219 template <
class Column_type,
class Cell_range>
220 friend bool _multiply_target_and_add_to_column(
const typename Column_type::Field_element_type& val,
221 const Cell_range& source,
222 Column_type& targetColumn);
223 template <
class Column_type,
class Cell_range>
224 friend bool _multiply_source_and_add_to_column(
const typename Column_type::Field_element_type& val,
225 const Cell_range& source,
226 Column_type& targetColumn);
228 void _delete_cell(
typename Column_type::iterator& it);
229 Cell* _insert_cell(
const Field_element_type& value,
231 const typename Column_type::iterator& position);
232 void _insert_cell(id_index rowIndex,
const typename Column_type::iterator& position);
233 template <
class Cell_range>
234 bool _add(
const Cell_range& column);
235 template <
class Cell_range>
236 bool _multiply_target_and_add(
const Field_element_type& val,
const Cell_range& column);
237 template <
class Cell_range>
238 bool _multiply_source_and_add(
const Cell_range& column,
const Field_element_type& val);
241 template <
class Master_matrix>
247 cellPool_(colSettings == nullptr ? nullptr : &(colSettings->cellConstructor))
249 if (operators_ ==
nullptr && cellPool_ ==
nullptr)
return;
250 if constexpr (!Master_matrix::Option_list::is_z2) {
251 operators_ = &(colSettings->operators);
255 template <
class Master_matrix>
256 template <
class Container_type>
257 inline Set_column<Master_matrix>::Set_column(
const Container_type& nonZeroRowIndices,
258 Column_settings* colSettings)
260 dim_opt(nonZeroRowIndices.size() == 0 ? 0 : nonZeroRowIndices.size() - 1),
263 cellPool_(&(colSettings->cellConstructor))
265 static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
266 "Constructor not available for chain columns, please specify the dimension of the chain.");
268 if constexpr (Master_matrix::Option_list::is_z2) {
269 for (id_index
id : nonZeroRowIndices) {
270 _insert_cell(
id, column_.end());
273 operators_ = &(colSettings->operators);
274 for (
const auto& p : nonZeroRowIndices) {
275 _insert_cell(operators_->get_value(p.second), p.first, column_.end());
280 template <
class Master_matrix>
281 template <
class Container_type,
class Row_container_type>
282 inline Set_column<Master_matrix>::Set_column(index columnIndex,
283 const Container_type& nonZeroRowIndices,
284 Row_container_type* rowContainer,
285 Column_settings* colSettings)
286 : ra_opt(columnIndex, rowContainer),
287 dim_opt(nonZeroRowIndices.size() == 0 ? 0 : nonZeroRowIndices.size() - 1),
289 if constexpr (Master_matrix::Option_list::is_z2) {
290 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : *std::prev(nonZeroRowIndices.end());
292 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : std::prev(nonZeroRowIndices.end())->first;
296 cellPool_(&(colSettings->cellConstructor))
298 static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
299 "Constructor not available for chain columns, please specify the dimension of the chain.");
301 if constexpr (Master_matrix::Option_list::is_z2) {
302 for (id_index
id : nonZeroRowIndices) {
303 _insert_cell(
id, column_.end());
306 operators_ = &(colSettings->operators);
307 for (
const auto& p : nonZeroRowIndices) {
308 _insert_cell(operators_->get_value(p.second), p.first, column_.end());
313 template <
class Master_matrix>
314 template <
class Container_type>
315 inline Set_column<Master_matrix>::Set_column(
const Container_type& nonZeroRowIndices,
316 dimension_type dimension,
317 Column_settings* colSettings)
321 if constexpr (Master_matrix::Option_list::is_z2) {
322 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : *std::prev(nonZeroRowIndices.end());
324 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : std::prev(nonZeroRowIndices.end())->first;
328 cellPool_(&(colSettings->cellConstructor))
330 if constexpr (Master_matrix::Option_list::is_z2) {
331 for (id_index
id : nonZeroRowIndices) {
332 _insert_cell(
id, column_.end());
335 operators_ = &(colSettings->operators);
336 for (
const auto& p : nonZeroRowIndices) {
337 _insert_cell(operators_->get_value(p.second), p.first, column_.end());
342 template <
class Master_matrix>
343 template <
class Container_type,
class Row_container_type>
344 inline Set_column<Master_matrix>::Set_column(
346 const Container_type& nonZeroRowIndices,
347 dimension_type dimension,
348 Row_container_type* rowContainer,
349 Column_settings* colSettings)
350 : ra_opt(columnIndex, rowContainer),
353 if constexpr (Master_matrix::Option_list::is_z2) {
354 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : *std::prev(nonZeroRowIndices.end());
356 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : std::prev(nonZeroRowIndices.end())->first;
360 cellPool_(&(colSettings->cellConstructor))
362 if constexpr (Master_matrix::Option_list::is_z2) {
363 for (id_index
id : nonZeroRowIndices) {
364 _insert_cell(
id, column_.end());
367 operators_ = &(colSettings->operators);
368 for (
const auto& p : nonZeroRowIndices) {
369 _insert_cell(operators_->get_value(p.second), p.first, column_.end());
374 template <
class Master_matrix>
375 inline Set_column<Master_matrix>::Set_column(
const Set_column& column,
376 Column_settings* colSettings)
378 dim_opt(static_cast<const dim_opt&>(column)),
379 chain_opt(static_cast<const chain_opt&>(column)),
380 operators_(colSettings == nullptr ? column.operators_ : nullptr),
381 cellPool_(colSettings == nullptr ? column.cellPool_ : &(colSettings->cellConstructor))
383 static_assert(!Master_matrix::Option_list::has_row_access,
384 "Simple copy constructor not available when row access option enabled. Please specify the new column "
385 "index and the row container.");
387 if constexpr (!Master_matrix::Option_list::is_z2){
388 if (colSettings !=
nullptr) operators_ = &(colSettings->operators);
391 for (
const Cell* cell : column.column_) {
392 if constexpr (Master_matrix::Option_list::is_z2) {
393 _insert_cell(cell->get_row_index(), column_.end());
395 _insert_cell(cell->get_element(), cell->get_row_index(), column_.end());
400 template <
class Master_matrix>
401 template <
class Row_container_type>
402 inline Set_column<Master_matrix>::Set_column(
const Set_column& column, index columnIndex,
403 Row_container_type* rowContainer,
404 Column_settings* colSettings)
405 : ra_opt(columnIndex, rowContainer),
406 dim_opt(static_cast<const dim_opt&>(column)),
407 chain_opt(static_cast<const chain_opt&>(column)),
408 operators_(colSettings == nullptr ? column.operators_ : nullptr),
409 cellPool_(colSettings == nullptr ? column.cellPool_ : &(colSettings->cellConstructor))
411 if constexpr (!Master_matrix::Option_list::is_z2){
412 if (colSettings !=
nullptr) operators_ = &(colSettings->operators);
415 for (
const Cell* cell : column.column_) {
416 if constexpr (Master_matrix::Option_list::is_z2) {
417 _insert_cell(cell->get_row_index(), column_.end());
419 _insert_cell(cell->get_element(), cell->get_row_index(), column_.end());
424 template <
class Master_matrix>
425 inline Set_column<Master_matrix>::Set_column(Set_column&& column) noexcept
426 : ra_opt(std::move(
static_cast<ra_opt&
>(column))),
427 dim_opt(std::move(
static_cast<dim_opt&
>(column))),
428 chain_opt(std::move(
static_cast<chain_opt&
>(column))),
429 column_(std::move(column.column_)),
430 operators_(std::exchange(column.operators_,
nullptr)),
431 cellPool_(std::exchange(column.cellPool_,
nullptr))
434 template <
class Master_matrix>
435 inline Set_column<Master_matrix>::~Set_column()
437 for (
auto* cell : column_) {
438 if constexpr (Master_matrix::Option_list::has_row_access) ra_opt::unlink(cell);
439 cellPool_->destroy(cell);
443 template <
class Master_matrix>
444 inline std::vector<typename Set_column<Master_matrix>::Field_element_type>
445 Set_column<Master_matrix>::get_content(
int columnLength)
const
447 if (columnLength < 0 && column_.size() > 0)
448 columnLength = (*column_.rbegin())->get_row_index() + 1;
449 else if (columnLength < 0)
450 return std::vector<Field_element_type>();
452 std::vector<Field_element_type> container(columnLength, 0);
453 for (
auto it = column_.begin(); it != column_.end() && (*it)->get_row_index() <
static_cast<id_index
>(columnLength);
455 if constexpr (Master_matrix::Option_list::is_z2) {
456 container[(*it)->get_row_index()] = 1;
458 container[(*it)->get_row_index()] = (*it)->get_element();
464 template <
class Master_matrix>
465 inline bool Set_column<Master_matrix>::is_non_zero(id_index rowIndex)
const
468 return column_.find(&cell) != column_.end();
471 template <
class Master_matrix>
472 inline bool Set_column<Master_matrix>::is_empty()
const
474 return column_.empty();
477 template <
class Master_matrix>
478 inline std::size_t Set_column<Master_matrix>::size()
const
480 return column_.size();
483 template <
class Master_matrix>
484 template <
class Map_type>
485 inline void Set_column<Master_matrix>::reorder(
const Map_type& valueMap,
486 [[maybe_unused]] index columnIndex)
488 static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
489 "Method not available for chain columns.");
493 for (Cell* cell : column_) {
494 if constexpr (Master_matrix::Option_list::has_row_access) {
495 ra_opt::unlink(cell);
496 if (columnIndex !=
static_cast<index
>(-1)) cell->set_column_index(columnIndex);
498 cell->set_row_index(valueMap.at(cell->get_row_index()));
500 if constexpr (Master_matrix::Option_list::has_row_access &&
501 Master_matrix::Option_list::has_intrusive_rows)
502 ra_opt::insert_cell(cell->get_row_index(), cell);
506 if constexpr (Master_matrix::Option_list::has_row_access && !Master_matrix::Option_list::has_intrusive_rows) {
507 for (Cell* cell : newSet) {
508 ra_opt::insert_cell(cell->get_row_index(), cell);
512 column_.swap(newSet);
515 template <
class Master_matrix>
516 inline void Set_column<Master_matrix>::clear()
518 static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
519 "Method not available for chain columns as a base element should not be empty.");
521 for (
auto* cell : column_) {
522 if constexpr (Master_matrix::Option_list::has_row_access) ra_opt::unlink(cell);
523 cellPool_->destroy(cell);
529 template <
class Master_matrix>
530 inline void Set_column<Master_matrix>::clear(id_index rowIndex)
532 static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
533 "Method not available for chain columns.");
535 auto cell = cellPool_->construct(rowIndex);
536 auto it = column_.find(cell);
537 if (it != column_.end()) {
540 cellPool_->destroy(cell);
543 template <
class Master_matrix>
544 inline typename Set_column<Master_matrix>::id_index
545 Set_column<Master_matrix>::get_pivot()
const
547 static_assert(Master_matrix::isNonBasic,
548 "Method not available for base columns.");
550 if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
551 if (column_.empty())
return -1;
552 return (*column_.rbegin())->get_row_index();
554 return chain_opt::get_pivot();
558 template <
class Master_matrix>
559 inline typename Set_column<Master_matrix>::Field_element_type
560 Set_column<Master_matrix>::get_pivot_value()
const
562 static_assert(Master_matrix::isNonBasic,
563 "Method not available for base columns.");
565 if constexpr (Master_matrix::Option_list::is_z2) {
568 if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
569 if (column_.empty())
return 0;
570 return (*column_.rbegin())->get_element();
572 if (chain_opt::get_pivot() ==
static_cast<id_index
>(-1))
return Field_element_type();
573 for (
const Cell* cell : column_) {
574 if (cell->get_row_index() == chain_opt::get_pivot())
return cell->get_element();
576 return Field_element_type();
581 template <
class Master_matrix>
582 inline typename Set_column<Master_matrix>::iterator
583 Set_column<Master_matrix>::begin() noexcept
585 return column_.begin();
588 template <
class Master_matrix>
589 inline typename Set_column<Master_matrix>::const_iterator
590 Set_column<Master_matrix>::begin() const noexcept
592 return column_.begin();
595 template <
class Master_matrix>
596 inline typename Set_column<Master_matrix>::iterator
597 Set_column<Master_matrix>::end() noexcept
599 return column_.end();
602 template <
class Master_matrix>
603 inline typename Set_column<Master_matrix>::const_iterator
604 Set_column<Master_matrix>::end() const noexcept
606 return column_.end();
609 template <
class Master_matrix>
610 inline typename Set_column<Master_matrix>::reverse_iterator
611 Set_column<Master_matrix>::rbegin() noexcept
613 return column_.rbegin();
616 template <
class Master_matrix>
617 inline typename Set_column<Master_matrix>::const_reverse_iterator
618 Set_column<Master_matrix>::rbegin() const noexcept
620 return column_.rbegin();
623 template <
class Master_matrix>
624 inline typename Set_column<Master_matrix>::reverse_iterator
625 Set_column<Master_matrix>::rend() noexcept
627 return column_.rend();
630 template <
class Master_matrix>
631 inline typename Set_column<Master_matrix>::const_reverse_iterator
632 Set_column<Master_matrix>::rend() const noexcept
634 return column_.rend();
637 template <
class Master_matrix>
638 template <
class Cell_range>
639 inline Set_column<Master_matrix>& Set_column<Master_matrix>::operator+=(
640 const Cell_range& column)
642 static_assert((!Master_matrix::isNonBasic || std::is_same_v<Cell_range, Set_column>),
643 "For boundary columns, the range has to be a column of same type to help ensure the validity of the "
645 static_assert((!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type),
646 "For chain columns, the given column cannot be constant.");
653 template <
class Master_matrix>
654 inline Set_column<Master_matrix>& Set_column<Master_matrix>::operator+=(
657 if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
660 chain_opt::swap_pivots(column);
661 dim_opt::swap_dimension(column);
670 template <
class Master_matrix>
671 inline Set_column<Master_matrix>& Set_column<Master_matrix>::operator*=(
674 if constexpr (Master_matrix::Option_list::is_z2) {
676 if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
677 throw std::invalid_argument(
"A chain column should not be multiplied by 0.");
683 Field_element_type val = operators_->get_value(v);
685 if (val == Field_operators::get_additive_identity()) {
686 if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
687 throw std::invalid_argument(
"A chain column should not be multiplied by 0.");
694 if (val == Field_operators::get_multiplicative_identity())
return *
this;
696 for (Cell* cell : column_) {
697 operators_->multiply_inplace(cell->get_element(), val);
698 if constexpr (Master_matrix::Option_list::has_row_access) ra_opt::update_cell(*cell);
705 template <
class Master_matrix>
706 template <
class Cell_range>
707 inline Set_column<Master_matrix>& Set_column<Master_matrix>::multiply_target_and_add(
708 const Field_element_type& val,
const Cell_range& column)
710 static_assert((!Master_matrix::isNonBasic || std::is_same_v<Cell_range, Set_column>),
711 "For boundary columns, the range has to be a column of same type to help ensure the validity of the "
713 static_assert((!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type),
714 "For chain columns, the given column cannot be constant.");
716 if constexpr (Master_matrix::Option_list::is_z2) {
724 _multiply_target_and_add(val, column);
730 template <
class Master_matrix>
731 inline Set_column<Master_matrix>& Set_column<Master_matrix>::multiply_target_and_add(
732 const Field_element_type& val, Set_column& column)
734 if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
736 if constexpr (Master_matrix::Option_list::is_z2) {
739 chain_opt::swap_pivots(column);
740 dim_opt::swap_dimension(column);
743 throw std::invalid_argument(
"A chain column should not be multiplied by 0.");
746 if (_multiply_target_and_add(val, column)) {
747 chain_opt::swap_pivots(column);
748 dim_opt::swap_dimension(column);
752 if constexpr (Master_matrix::Option_list::is_z2) {
760 _multiply_target_and_add(val, column);
767 template <
class Master_matrix>
768 template <
class Cell_range>
769 inline Set_column<Master_matrix>& Set_column<Master_matrix>::multiply_source_and_add(
770 const Cell_range& column,
const Field_element_type& val)
772 static_assert((!Master_matrix::isNonBasic || std::is_same_v<Cell_range, Set_column>),
773 "For boundary columns, the range has to be a column of same type to help ensure the validity of the "
775 static_assert((!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type),
776 "For chain columns, the given column cannot be constant.");
778 if constexpr (Master_matrix::Option_list::is_z2) {
783 _multiply_source_and_add(column, val);
789 template <
class Master_matrix>
790 inline Set_column<Master_matrix>& Set_column<Master_matrix>::multiply_source_and_add(
791 Set_column& column,
const Field_element_type& val)
793 if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
795 if constexpr (Master_matrix::Option_list::is_z2) {
798 chain_opt::swap_pivots(column);
799 dim_opt::swap_dimension(column);
803 if (_multiply_source_and_add(column, val)) {
804 chain_opt::swap_pivots(column);
805 dim_opt::swap_dimension(column);
809 if constexpr (Master_matrix::Option_list::is_z2) {
814 _multiply_source_and_add(column, val);
821 template <
class Master_matrix>
822 inline Set_column<Master_matrix>& Set_column<Master_matrix>::operator=(
823 const Set_column& other)
825 static_assert(!Master_matrix::Option_list::has_row_access,
"= assignement not enabled with row access option.");
827 dim_opt::operator=(other);
828 chain_opt::operator=(other);
830 for (
auto* cell : column_) {
831 if constexpr (Master_matrix::Option_list::has_row_access) ra_opt::unlink(cell);
832 cellPool_->destroy(cell);
836 cellPool_ = other.cellPool_;
837 operators_ = other.operators_;
839 for (
const Cell* cell : other.column_) {
840 if constexpr (Master_matrix::Option_list::is_z2) {
841 _insert_cell(cell->get_row_index(), column_.end());
843 _insert_cell(cell->get_element(), cell->get_row_index(), column_.end());
850 template <
class Master_matrix>
851 inline void Set_column<Master_matrix>::_delete_cell(
typename Column_type::iterator& it)
853 if constexpr (Master_matrix::Option_list::has_row_access) ra_opt::unlink(*it);
854 cellPool_->destroy(*it);
855 it = column_.erase(it);
858 template <
class Master_matrix>
859 inline typename Set_column<Master_matrix>::Cell* Set_column<Master_matrix>::_insert_cell(
860 const Field_element_type& value, id_index rowIndex,
const typename Column_type::iterator& position)
862 if constexpr (Master_matrix::Option_list::has_row_access) {
863 Cell* newCell = cellPool_->construct(ra_opt::columnIndex_, rowIndex);
864 newCell->set_element(value);
865 column_.insert(position, newCell);
866 ra_opt::insert_cell(rowIndex, newCell);
869 Cell* newCell = cellPool_->construct(rowIndex);
870 newCell->set_element(value);
871 column_.insert(position, newCell);
876 template <
class Master_matrix>
877 inline void Set_column<Master_matrix>::_insert_cell(id_index rowIndex,
878 const typename Column_type::iterator& position)
880 if constexpr (Master_matrix::Option_list::has_row_access) {
881 Cell* newCell = cellPool_->construct(ra_opt::columnIndex_, rowIndex);
882 column_.insert(position, newCell);
883 ra_opt::insert_cell(rowIndex, newCell);
885 Cell* newCell = cellPool_->construct(rowIndex);
886 column_.insert(position, newCell);
890 template <
class Master_matrix>
891 template <
class Cell_range>
892 inline bool Set_column<Master_matrix>::_add(
const Cell_range& column)
894 return _add_to_column(column, *
this);
897 template <
class Master_matrix>
898 template <
class Cell_range>
899 inline bool Set_column<Master_matrix>::_multiply_target_and_add(
const Field_element_type& val,
900 const Cell_range& column)
902 return _multiply_target_and_add_to_column(val, column, *
this);
905 template <
class Master_matrix>
906 template <
class Cell_range>
907 inline bool Set_column<Master_matrix>::_multiply_source_and_add(
const Cell_range& column,
908 const Field_element_type& val)
910 return _multiply_source_and_add_to_column(val, column, *
this);
924 template <
class Master_matrix>
925 struct std::hash<
Gudhi::persistence_matrix::Set_column<Master_matrix> >
928 return Gudhi::persistence_matrix::hash_column(column);
Contains the New_cell_constructor and Pool_cell_constructor structures.
Column class following the PersistenceMatrixColumn concept.
Definition: set_column.h:51
Contains helper methods for column addition and column hasher.
Chain_column_extra_properties Chain_column_option
If PersistenceMatrixOptions::is_of_boundary_type is false, and, PersistenceMatrixOptions::has_column_...
Definition: PersistenceMatrixColumn.h:45
Row_access Row_access_option
If PersistenceMatrixOptions::has_row_access is true, then Row_access. Otherwise Dummy_row_access....
Definition: PersistenceMatrixColumn.h:28
Column_dimension_holder Column_dimension_option
If PersistenceMatrixOptions::has_column_pairings or PersistenceMatrixOptions::has_vine_update or Pers...
Definition: PersistenceMatrixColumn.h:36
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14