18 #ifndef PM_INTRUSIVE_LIST_COLUMN_H
19 #define PM_INTRUSIVE_LIST_COLUMN_H
23 #include <type_traits>
26 #include <boost/intrusive/list.hpp>
32 namespace persistence_matrix {
46 template <
class Master_matrix>
52 using Master = Master_matrix;
53 using index =
typename Master_matrix::index;
54 using id_index =
typename Master_matrix::id_index;
55 using dimension_type =
typename Master_matrix::dimension_type;
56 using Field_element_type =
typename Master_matrix::element_type;
57 using Cell =
typename Master_matrix::Cell_type;
58 using Column_settings =
typename Master_matrix::Column_settings;
61 using Field_operators =
typename Master_matrix::Field_operators;
63 boost::intrusive::list<Cell,
64 boost::intrusive::constant_time_size<false>,
65 boost::intrusive::base_hook<typename Master_matrix::base_hook_matrix_list_column> >;
66 using Cell_constructor =
typename Master_matrix::Cell_constructor;
69 using iterator =
typename Column_type::iterator;
70 using const_iterator =
typename Column_type::const_iterator;
71 using reverse_iterator =
typename Column_type::reverse_iterator;
72 using const_reverse_iterator =
typename Column_type::const_reverse_iterator;
75 template <
class Container_type =
typename Master_matrix::boundary_type>
77 Column_settings* colSettings);
78 template <
class Container_type =
typename Master_matrix::boundary_type,
class Row_container_type>
80 const Container_type& nonZeroRowIndices,
81 Row_container_type* rowContainer,
82 Column_settings* colSettings);
83 template <
class Container_type =
typename Master_matrix::boundary_type>
85 dimension_type dimension,
86 Column_settings* colSettings);
87 template <
class Container_type =
typename Master_matrix::boundary_type,
class Row_container_type>
89 const Container_type& nonZeroChainRowIndices,
90 dimension_type dimension,
91 Row_container_type* rowContainer,
92 Column_settings* colSettings);
94 Column_settings* colSettings =
nullptr);
95 template <
class Row_container_type>
98 Row_container_type* rowContainer,
99 Column_settings* colSettings =
nullptr);
103 std::vector<Field_element_type> get_content(
int columnLength = -1)
const;
104 bool is_non_zero(id_index rowIndex)
const;
105 bool is_empty()
const;
106 std::size_t size()
const;
108 template <
class Map_type>
109 void reorder(
const Map_type& valueMap, [[maybe_unused]] index columnIndex = -1);
111 void clear(id_index rowIndex);
113 id_index get_pivot()
const;
114 Field_element_type get_pivot_value()
const;
116 iterator begin() noexcept;
117 const_iterator begin()
const noexcept;
118 iterator end() noexcept;
119 const_iterator end()
const noexcept;
120 reverse_iterator rbegin() noexcept;
121 const_reverse_iterator rbegin()
const noexcept;
122 reverse_iterator rend() noexcept;
123 const_reverse_iterator rend()
const noexcept;
125 template <
class Cell_range>
132 template <
class Cell_range>
133 Intrusive_list_column& multiply_target_and_add(
const Field_element_type& val,
const Cell_range& column);
136 template <
class Cell_range>
137 Intrusive_list_column& multiply_source_and_add(
const Cell_range& column,
const Field_element_type& val);
141 if (&c1 == &c2)
return true;
143 if constexpr (Master_matrix::Option_list::is_z2) {
144 return c1.column_ == c2.column_;
146 auto it1 = c1.column_.begin();
147 auto it2 = c2.column_.begin();
148 if (c1.column_.size() != c2.column_.size())
return false;
149 while (it1 != c1.column_.end() && it2 != c2.column_.end()) {
150 if (it1->get_row_index() != it2->get_row_index() || it1->get_element() != it2->get_element())
return false;
158 if (&c1 == &c2)
return false;
160 if constexpr (Master_matrix::Option_list::is_z2) {
161 return c1.column_ < c2.column_;
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 (it1->get_element() != it2->get_element())
return it1->get_element() < it2->get_element();
171 return it2 != c2.column_.end();
185 col1.column_.swap(col2.column_);
186 std::swap(col1.operators_, col2.operators_);
187 std::swap(col1.cellPool_, col2.cellPool_);
197 new_cloner(Cell_constructor* cellPool) : cellPool_(cellPool){};
199 Cell* operator()(
const Cell& clone_this) {
return cellPool_->construct(clone_this); }
201 Cell_constructor* cellPool_;
205 struct delete_disposer {
209 void operator()(Cell* delete_this) {
210 if constexpr (Master_matrix::Option_list::has_row_access) col_->unlink(delete_this);
211 col_->cellPool_->destroy(delete_this);
217 Field_operators* operators_;
218 Cell_constructor* cellPool_;
221 template <
class Column_type,
class Cell_iterator,
typename F1,
typename F2,
typename F3,
typename F4>
222 friend void _generic_merge_cell_to_column(Column_type& targetColumn,
223 Cell_iterator& itSource,
224 typename Column_type::Column_type::iterator& itTarget,
229 bool& pivotIsZeroed);
230 template <
class Column_type,
class Cell_range,
typename F1,
typename F2,
typename F3,
typename F4,
typename F5>
231 friend bool _generic_add_to_column(
const Cell_range& source,
232 Column_type& targetColumn,
238 template <
class Column_type,
class Cell_range>
239 friend bool _add_to_column(
const Cell_range& source, Column_type& targetColumn);
240 template <
class Column_type,
class Cell_range>
241 friend bool _multiply_target_and_add_to_column(
const typename Column_type::Field_element_type& val,
242 const Cell_range& source,
243 Column_type& targetColumn);
244 template <
class Column_type,
class Cell_range>
245 friend bool _multiply_source_and_add_to_column(
const typename Column_type::Field_element_type& val,
246 const Cell_range& source,
247 Column_type& targetColumn);
249 void _delete_cell(iterator& it);
250 Cell* _insert_cell(
const Field_element_type& value, id_index rowIndex,
const iterator& position);
251 void _insert_cell(id_index rowIndex,
const iterator& position);
252 template <
class Cell_range>
253 bool _add(
const Cell_range& column);
254 template <
class Cell_range>
255 bool _multiply_target_and_add(
const Field_element_type& val,
const Cell_range& column);
256 template <
class Cell_range>
257 bool _multiply_source_and_add(
const Cell_range& column,
const Field_element_type& val);
260 template <
class Master_matrix>
266 cellPool_(colSettings == nullptr ? nullptr : &(colSettings->cellConstructor)),
269 if (colSettings ==
nullptr)
return;
270 if constexpr (!Master_matrix::Option_list::is_z2) {
271 operators_ = &(colSettings->operators);
275 template <
class Master_matrix>
276 template <
class Container_type>
277 inline Intrusive_list_column<Master_matrix>::Intrusive_list_column(
278 const Container_type& nonZeroRowIndices, Column_settings* colSettings)
280 dim_opt(nonZeroRowIndices.size() == 0 ? 0 : nonZeroRowIndices.size() - 1),
283 cellPool_(&(colSettings->cellConstructor)),
286 static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
287 "Constructor not available for chain columns, please specify the dimension of the chain.");
289 if constexpr (Master_matrix::Option_list::is_z2) {
290 for (id_index
id : nonZeroRowIndices) {
291 _insert_cell(
id, column_.end());
294 operators_ = &(colSettings->operators);
295 for (
const auto& p : nonZeroRowIndices) {
296 _insert_cell(operators_->get_value(p.second), p.first, column_.end());
301 template <
class Master_matrix>
302 template <
class Container_type,
class Row_container_type>
303 inline Intrusive_list_column<Master_matrix>::Intrusive_list_column(
305 const Container_type& nonZeroRowIndices,
306 Row_container_type* rowContainer,
307 Column_settings* colSettings)
308 : ra_opt(columnIndex, rowContainer),
309 dim_opt(nonZeroRowIndices.size() == 0 ? 0 : nonZeroRowIndices.size() - 1),
311 if constexpr (Master_matrix::Option_list::is_z2) {
312 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : *std::prev(nonZeroRowIndices.end());
314 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : std::prev(nonZeroRowIndices.end())->first;
318 cellPool_(&(colSettings->cellConstructor)),
321 static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
322 "Constructor not available for chain columns, please specify the dimension of the chain.");
324 if constexpr (Master_matrix::Option_list::is_z2) {
325 for (id_index
id : nonZeroRowIndices) {
326 _insert_cell(
id, column_.end());
329 operators_ = &(colSettings->operators);
330 for (
const auto& p : nonZeroRowIndices) {
331 _insert_cell(operators_->get_value(p.second), p.first, column_.end());
336 template <
class Master_matrix>
337 template <
class Container_type>
338 inline Intrusive_list_column<Master_matrix>::Intrusive_list_column(
339 const Container_type& nonZeroRowIndices,
340 dimension_type dimension,
341 Column_settings* colSettings)
345 if constexpr (Master_matrix::Option_list::is_z2) {
346 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : *std::prev(nonZeroRowIndices.end());
348 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : std::prev(nonZeroRowIndices.end())->first;
352 cellPool_(&(colSettings->cellConstructor)),
355 if constexpr (Master_matrix::Option_list::is_z2) {
356 for (id_index
id : nonZeroRowIndices) {
357 _insert_cell(
id, column_.end());
360 operators_ = &(colSettings->operators);
361 for (
const auto& p : nonZeroRowIndices) {
362 _insert_cell(operators_->get_value(p.second), p.first, column_.end());
367 template <
class Master_matrix>
368 template <
class Container_type,
class Row_container_type>
369 inline Intrusive_list_column<Master_matrix>::Intrusive_list_column(
371 const Container_type& nonZeroRowIndices,
372 dimension_type dimension,
373 Row_container_type* rowContainer,
374 Column_settings* colSettings)
375 : ra_opt(columnIndex, rowContainer),
378 if constexpr (Master_matrix::Option_list::is_z2) {
379 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : *std::prev(nonZeroRowIndices.end());
381 return nonZeroRowIndices.begin() == nonZeroRowIndices.end() ? -1 : std::prev(nonZeroRowIndices.end())->first;
385 cellPool_(&(colSettings->cellConstructor)),
388 if constexpr (Master_matrix::Option_list::is_z2) {
389 for (id_index
id : nonZeroRowIndices) {
390 _insert_cell(
id, column_.end());
393 operators_ = &(colSettings->operators);
394 for (
const auto& p : nonZeroRowIndices) {
395 _insert_cell(operators_->get_value(p.second), p.first, column_.end());
400 template <
class Master_matrix>
401 inline Intrusive_list_column<Master_matrix>::Intrusive_list_column(
402 const Intrusive_list_column& column, Column_settings* colSettings)
404 dim_opt(static_cast<const dim_opt&>(column)),
405 chain_opt(static_cast<const chain_opt&>(column)),
406 operators_(colSettings == nullptr ? column.operators_ : nullptr),
407 cellPool_(colSettings == nullptr ? column.cellPool_ : &(colSettings->cellConstructor)),
410 static_assert(!Master_matrix::Option_list::has_row_access,
411 "Simple copy constructor not available when row access option enabled. Please specify the new column "
412 "index and the row container.");
413 if constexpr (!Master_matrix::Option_list::is_z2){
414 if (colSettings !=
nullptr) operators_ = &(colSettings->operators);
417 column_.clone_from(column.column_, new_cloner(cellPool_), delete_disposer(
this));
420 template <
class Master_matrix>
421 template <
class Row_container_type>
422 inline Intrusive_list_column<Master_matrix>::Intrusive_list_column(
423 const Intrusive_list_column& column, index columnIndex, Row_container_type* rowContainer,
424 Column_settings* colSettings)
425 : ra_opt(columnIndex, rowContainer),
426 dim_opt(static_cast<const dim_opt&>(column)),
427 chain_opt(static_cast<const chain_opt&>(column)),
428 operators_(colSettings == nullptr ? column.operators_ : nullptr),
429 cellPool_(colSettings == nullptr ? column.cellPool_ : &(colSettings->cellConstructor)),
432 if constexpr (!Master_matrix::Option_list::is_z2){
433 if (colSettings !=
nullptr) operators_ = &(colSettings->operators);
436 for (
const Cell& cell : column.column_) {
437 if constexpr (Master_matrix::Option_list::is_z2) {
438 _insert_cell(cell.get_row_index(), column_.end());
440 _insert_cell(cell.get_element(), cell.get_row_index(), column_.end());
445 template <
class Master_matrix>
446 inline Intrusive_list_column<Master_matrix>::Intrusive_list_column(
447 Intrusive_list_column&& column) noexcept
448 : ra_opt(std::move(
static_cast<ra_opt&
>(column))),
449 dim_opt(std::move(
static_cast<dim_opt&
>(column))),
450 chain_opt(std::move(
static_cast<chain_opt&
>(column))),
451 operators_(std::exchange(column.operators_,
nullptr)),
452 cellPool_(std::exchange(column.cellPool_,
nullptr)),
453 column_(std::move(column.column_))
456 template <
class Master_matrix>
457 inline Intrusive_list_column<Master_matrix>::~Intrusive_list_column()
459 column_.clear_and_dispose(delete_disposer(
this));
462 template <
class Master_matrix>
463 inline std::vector<typename Intrusive_list_column<Master_matrix>::Field_element_type>
464 Intrusive_list_column<Master_matrix>::get_content(
int columnLength)
const
466 if (columnLength < 0 && column_.size() > 0)
467 columnLength = column_.back().get_row_index() + 1;
468 else if (columnLength < 0)
469 return std::vector<Field_element_type>();
471 std::vector<Field_element_type> container(columnLength);
472 for (
auto it = column_.begin(); it != column_.end() && it->get_row_index() <
static_cast<id_index
>(columnLength);
474 if constexpr (Master_matrix::Option_list::is_z2) {
475 container[it->get_row_index()] = 1;
477 container[it->get_row_index()] = it->get_element();
483 template <
class Master_matrix>
484 inline bool Intrusive_list_column<Master_matrix>::is_non_zero(id_index rowIndex)
const
489 for (
const Cell& cell : column_)
490 if (cell.get_row_index() == rowIndex)
return true;
495 template <
class Master_matrix>
496 inline bool Intrusive_list_column<Master_matrix>::is_empty()
const
498 return column_.empty();
501 template <
class Master_matrix>
502 inline std::size_t Intrusive_list_column<Master_matrix>::size()
const
504 return column_.size();
507 template <
class Master_matrix>
508 template <
class Map_type>
509 inline void Intrusive_list_column<Master_matrix>::reorder(
const Map_type& valueMap,
510 [[maybe_unused]] index columnIndex)
512 static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
513 "Method not available for chain columns.");
515 for (
auto it = column_.begin(); it != column_.end(); ++it) {
517 if constexpr (Master_matrix::Option_list::has_row_access) {
518 ra_opt::unlink(cell);
519 if (columnIndex !=
static_cast<index
>(-1)) cell->set_column_index(columnIndex);
521 cell->set_row_index(valueMap.at(cell->get_row_index()));
522 if constexpr (Master_matrix::Option_list::has_intrusive_rows && Master_matrix::Option_list::has_row_access)
523 ra_opt::insert_cell(cell->get_row_index(), cell);
527 if constexpr (!Master_matrix::Option_list::has_intrusive_rows && Master_matrix::Option_list::has_row_access) {
528 for (
auto it = column_.begin(); it != column_.end(); ++it) {
530 ra_opt::insert_cell(cell->get_row_index(), cell);
537 template <
class Master_matrix>
538 inline void Intrusive_list_column<Master_matrix>::clear()
540 static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
541 "Method not available for chain columns as a base element should not be empty.");
543 column_.clear_and_dispose(delete_disposer(
this));
546 template <
class Master_matrix>
547 inline void Intrusive_list_column<Master_matrix>::clear(id_index rowIndex)
549 static_assert(!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type,
550 "Method not available for chain columns.");
552 auto it = column_.begin();
553 while (it != column_.end() && it->get_row_index() != rowIndex) it++;
554 if (it != column_.end()) _delete_cell(it);
557 template <
class Master_matrix>
558 inline typename Intrusive_list_column<Master_matrix>::id_index
559 Intrusive_list_column<Master_matrix>::get_pivot()
const
561 static_assert(Master_matrix::isNonBasic,
562 "Method not available for base columns.");
564 if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
565 if (column_.empty())
return -1;
566 return column_.back().get_row_index();
568 return chain_opt::get_pivot();
572 template <
class Master_matrix>
573 inline typename Intrusive_list_column<Master_matrix>::Field_element_type
574 Intrusive_list_column<Master_matrix>::get_pivot_value()
const
576 static_assert(Master_matrix::isNonBasic,
577 "Method not available for base columns.");
579 if constexpr (Master_matrix::Option_list::is_z2) {
582 if constexpr (Master_matrix::Option_list::is_of_boundary_type) {
583 if (column_.empty())
return 0;
584 return column_.back().get_element();
586 if (chain_opt::get_pivot() ==
static_cast<id_index
>(-1))
return Field_element_type();
587 for (
const Cell& cell : column_) {
588 if (cell.get_row_index() == chain_opt::get_pivot())
return cell.get_element();
590 return Field_element_type();
595 template <
class Master_matrix>
596 inline typename Intrusive_list_column<Master_matrix>::iterator
597 Intrusive_list_column<Master_matrix>::begin() noexcept
599 return column_.begin();
602 template <
class Master_matrix>
603 inline typename Intrusive_list_column<Master_matrix>::const_iterator
604 Intrusive_list_column<Master_matrix>::begin() const noexcept
606 return column_.begin();
609 template <
class Master_matrix>
610 inline typename Intrusive_list_column<Master_matrix>::iterator
611 Intrusive_list_column<Master_matrix>::end() noexcept
613 return column_.end();
616 template <
class Master_matrix>
617 inline typename Intrusive_list_column<Master_matrix>::const_iterator
618 Intrusive_list_column<Master_matrix>::end() const noexcept
620 return column_.end();
623 template <
class Master_matrix>
624 inline typename Intrusive_list_column<Master_matrix>::reverse_iterator
625 Intrusive_list_column<Master_matrix>::rbegin() noexcept
627 return column_.rbegin();
630 template <
class Master_matrix>
631 inline typename Intrusive_list_column<Master_matrix>::const_reverse_iterator
632 Intrusive_list_column<Master_matrix>::rbegin() const noexcept
634 return column_.rbegin();
637 template <
class Master_matrix>
638 inline typename Intrusive_list_column<Master_matrix>::reverse_iterator
639 Intrusive_list_column<Master_matrix>::rend() noexcept
641 return column_.rend();
644 template <
class Master_matrix>
645 inline typename Intrusive_list_column<Master_matrix>::const_reverse_iterator
646 Intrusive_list_column<Master_matrix>::rend() const noexcept
648 return column_.rend();
651 template <
class Master_matrix>
652 template <
class Cell_range>
653 inline Intrusive_list_column<Master_matrix>&
654 Intrusive_list_column<Master_matrix>::operator+=(
const Cell_range& column)
656 static_assert((!Master_matrix::isNonBasic || std::is_same_v<Cell_range, Intrusive_list_column>),
657 "For boundary columns, the range has to be a column of same type to help ensure the validity of the "
659 static_assert((!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type),
660 "For chain columns, the given column cannot be constant.");
667 template <
class Master_matrix>
668 inline Intrusive_list_column<Master_matrix>&
669 Intrusive_list_column<Master_matrix>::operator+=(Intrusive_list_column& column)
671 if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
674 chain_opt::swap_pivots(column);
675 dim_opt::swap_dimension(column);
684 template <
class Master_matrix>
685 inline Intrusive_list_column<Master_matrix>&
686 Intrusive_list_column<Master_matrix>::operator*=(
const Field_element_type& val)
688 if constexpr (Master_matrix::Option_list::is_z2) {
690 if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
691 throw std::invalid_argument(
"A chain column should not be multiplied by 0.");
697 Field_element_type realVal = operators_->get_value(val);
699 if (realVal == Field_operators::get_additive_identity()) {
700 if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
701 throw std::invalid_argument(
"A chain column should not be multiplied by 0.");
708 if (realVal == Field_operators::get_multiplicative_identity())
return *
this;
710 for (Cell& cell : column_) {
711 operators_->multiply_inplace(cell.get_element(), realVal);
712 if constexpr (Master_matrix::Option_list::has_row_access) ra_opt::update_cell(cell);
719 template <
class Master_matrix>
720 template <
class Cell_range>
721 inline Intrusive_list_column<Master_matrix>&
722 Intrusive_list_column<Master_matrix>::multiply_target_and_add(
const Field_element_type& val,
723 const Cell_range& column)
725 static_assert((!Master_matrix::isNonBasic || std::is_same_v<Cell_range, Intrusive_list_column>),
726 "For boundary columns, the range has to be a column of same type to help ensure the validity of the "
728 static_assert((!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type),
729 "For chain columns, the given column cannot be constant.");
731 if constexpr (Master_matrix::Option_list::is_z2) {
739 _multiply_target_and_add(val, column);
745 template <
class Master_matrix>
746 inline Intrusive_list_column<Master_matrix>&
747 Intrusive_list_column<Master_matrix>::multiply_target_and_add(
const Field_element_type& val,
748 Intrusive_list_column& column)
750 if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
752 if constexpr (Master_matrix::Option_list::is_z2) {
755 chain_opt::swap_pivots(column);
756 dim_opt::swap_dimension(column);
759 throw std::invalid_argument(
"A chain column should not be multiplied by 0.");
762 if (_multiply_target_and_add(val, column)) {
763 chain_opt::swap_pivots(column);
764 dim_opt::swap_dimension(column);
768 if constexpr (Master_matrix::Option_list::is_z2) {
776 _multiply_target_and_add(val, column);
783 template <
class Master_matrix>
784 template <
class Cell_range>
785 inline Intrusive_list_column<Master_matrix>&
786 Intrusive_list_column<Master_matrix>::multiply_source_and_add(
const Cell_range& column,
787 const Field_element_type& val)
789 static_assert((!Master_matrix::isNonBasic || std::is_same_v<Cell_range, Intrusive_list_column>),
790 "For boundary columns, the range has to be a column of same type to help ensure the validity of the "
792 static_assert((!Master_matrix::isNonBasic || Master_matrix::Option_list::is_of_boundary_type),
793 "For chain columns, the given column cannot be constant.");
795 if constexpr (Master_matrix::Option_list::is_z2) {
800 _multiply_source_and_add(column, val);
806 template <
class Master_matrix>
807 inline Intrusive_list_column<Master_matrix>&
808 Intrusive_list_column<Master_matrix>::multiply_source_and_add(Intrusive_list_column& column,
809 const Field_element_type& val)
811 if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
813 if constexpr (Master_matrix::Option_list::is_z2) {
816 chain_opt::swap_pivots(column);
817 dim_opt::swap_dimension(column);
821 if (_multiply_source_and_add(column, val)) {
822 chain_opt::swap_pivots(column);
823 dim_opt::swap_dimension(column);
827 if constexpr (Master_matrix::Option_list::is_z2) {
832 _multiply_source_and_add(column, val);
839 template <
class Master_matrix>
840 inline Intrusive_list_column<Master_matrix>&
841 Intrusive_list_column<Master_matrix>::operator=(
const Intrusive_list_column& other)
843 static_assert(!Master_matrix::Option_list::has_row_access,
"= assignement not enabled with row access option.");
845 dim_opt::operator=(other);
846 chain_opt::operator=(other);
849 column_.clear_and_dispose(delete_disposer(
this));
850 operators_ = other.operators_;
851 cellPool_ = other.cellPool_;
852 column_.clone_from(other.column_, new_cloner(cellPool_), delete_disposer(
this));
857 template <
class Master_matrix>
858 inline void Intrusive_list_column<Master_matrix>::_delete_cell(iterator& it)
860 it = column_.erase_and_dispose(it, delete_disposer(
this));
863 template <
class Master_matrix>
864 inline typename Intrusive_list_column<Master_matrix>::Cell* Intrusive_list_column<Master_matrix>::_insert_cell(
865 const Field_element_type& value, id_index rowIndex,
const iterator& position)
867 if constexpr (Master_matrix::Option_list::has_row_access) {
868 Cell* newCell = cellPool_->construct(ra_opt::columnIndex_, rowIndex);
869 newCell->set_element(value);
870 column_.insert(position, *newCell);
871 ra_opt::insert_cell(rowIndex, newCell);
874 Cell* newCell = cellPool_->construct(rowIndex);
875 newCell->set_element(value);
876 column_.insert(position, *newCell);
881 template <
class Master_matrix>
882 inline void Intrusive_list_column<Master_matrix>::_insert_cell(id_index rowIndex,
883 const iterator& position)
885 if constexpr (Master_matrix::Option_list::has_row_access) {
886 Cell* newCell = cellPool_->construct(ra_opt::columnIndex_, rowIndex);
887 column_.insert(position, *newCell);
888 ra_opt::insert_cell(rowIndex, newCell);
890 Cell* newCell = cellPool_->construct(rowIndex);
891 column_.insert(position, *newCell);
895 template <
class Master_matrix>
896 template <
class Cell_range>
897 inline bool Intrusive_list_column<Master_matrix>::_add(
const Cell_range& column)
899 return _add_to_column(column, *
this);
902 template <
class Master_matrix>
903 template <
class Cell_range>
904 inline bool Intrusive_list_column<Master_matrix>::_multiply_target_and_add(
const Field_element_type& val,
905 const Cell_range& column)
907 return _multiply_target_and_add_to_column(val, column, *
this);
910 template <
class Master_matrix>
911 template <
class Cell_range>
912 inline bool Intrusive_list_column<Master_matrix>::_multiply_source_and_add(
const Cell_range& column,
913 const Field_element_type& val)
915 return _multiply_source_and_add_to_column(val, column, *
this);
929 template <
class Master_matrix>
930 struct std::hash<
Gudhi::persistence_matrix::Intrusive_list_column<Master_matrix> >
933 return Gudhi::persistence_matrix::hash_column(column);
Contains the New_cell_constructor and Pool_cell_constructor structures.
Column class following the PersistenceMatrixColumn concept.
Definition: intrusive_list_column.h:50
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