Skip to content

Commit

Permalink
doc fix + change of multiply_and_add method name to separate the two …
Browse files Browse the repository at this point in the history
…versions
  • Loading branch information
hschreiber committed May 27, 2024
1 parent 9d91ea5 commit b8d6c3d
Show file tree
Hide file tree
Showing 17 changed files with 207 additions and 207 deletions.
26 changes: 13 additions & 13 deletions src/Persistence_matrix/concept/PersistenceMatrixColumn.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ class PersistenceMatrixColumn :
* @brief Adds the given @ref Cell range onto the column.
*
* @tparam Cell_range @ref Cell range with %begin() and %end() method.
* @param column @ref Cell range. Every cell has to return the right value when using @ref Cell::get_row_index and,
* if @ref PersistenceMatrixOptions::is_z2 is false, also when using
* @ref Cell_field_element::get_element "Cell::get_element".
* @param column @ref Cell range. Only the stored row index and the stored element value
* (if @ref PersistenceMatrixOptions::is_z2 is false) are token into account for this method.
* Even if @ref PersistenceMatrixOptions::has_row_access is true, the column index does not need to be correct.
* @return Reference to this column.
*/
template <class Cell_range>
Expand All @@ -393,41 +393,41 @@ class PersistenceMatrixColumn :
*
* @tparam Cell_range @ref Cell range with %begin() and %end() method.
* @param val Value to multiply.
* @param column @ref Cell range. Every cell has to return the right value when using @ref Cell::get_row_index and,
* if @ref PersistenceMatrixOptions::is_z2 is false, also when using
* @ref Cell_field_element::get_element "Cell::get_element".
* @param column @ref Cell range. Only the stored row index and the stored element value
* (if @ref PersistenceMatrixOptions::is_z2 is false) are token into account for this method.
* Even if @ref PersistenceMatrixOptions::has_row_access is true, the column index does not need to be correct.
* @return Reference to this column.
*/
template <class Cell_range>
PersistenceMatrixColumn& multiply_and_add(const Field_element_type& val, const Cell_range& column);
PersistenceMatrixColumn& multiply_target_and_add(const Field_element_type& val, const Cell_range& column);
/**
* @brief `this = val * this + column`
*
* @param val Value to multiply.
* @param column Column to add.
* @return Reference to this column.
*/
PersistenceMatrixColumn& multiply_and_add(const Field_element_type& val, PersistenceMatrixColumn& column);
PersistenceMatrixColumn& multiply_target_and_add(const Field_element_type& val, PersistenceMatrixColumn& column);
/**
* @brief `this = this + column * val`
*
* @tparam Cell_range @ref Cell range with %begin() and %end() method.
* @param column @ref Cell range. Every cell has to return the right value when using @ref Cell::get_row_index and,
* if @ref PersistenceMatrixOptions::is_z2 is false, also when using
* @ref Cell_field_element::get_element "Cell::get_element".
* @param column @ref Cell range. Only the stored row index and the stored element value
* (if @ref PersistenceMatrixOptions::is_z2 is false) are token into account for this method.
* Even if @ref PersistenceMatrixOptions::has_row_access is true, the column index does not need to be correct.
* @param val Value to multiply.
* @return Reference to this column.
*/
template <class Cell_range>
PersistenceMatrixColumn& multiply_and_add(const Cell_range& column, const Field_element_type& val);
PersistenceMatrixColumn& multiply_source_and_add(const Cell_range& column, const Field_element_type& val);
/**
* @brief `this = this + column * val`
*
* @param column Column to add.
* @param val Value to multiply.
* @return Reference to this column.
*/
PersistenceMatrixColumn& multiply_and_add(PersistenceMatrixColumn& column, const Field_element_type& val);
PersistenceMatrixColumn& multiply_source_and_add(PersistenceMatrixColumn& column, const Field_element_type& val);

/**
* @brief Equality comparator. Equal in the sense that what is "supposed" to be contained in the columns is equal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,15 +564,15 @@ inline void Base_matrix<Master_matrix>::multiply_target_and_add_to(const Cell_ra
{
if constexpr (std::is_integral_v<Cell_range_or_column_index>) {
if constexpr (Master_matrix::Option_list::has_map_column_container) {
matrix_.at(targetColumnIndex).multiply_and_add(coefficient, matrix_.at(sourceColumn));
matrix_.at(targetColumnIndex).multiply_target_and_add(coefficient, matrix_.at(sourceColumn));
} else {
matrix_[targetColumnIndex].multiply_and_add(coefficient, matrix_[sourceColumn]);
matrix_[targetColumnIndex].multiply_target_and_add(coefficient, matrix_[sourceColumn]);
}
} else {
if constexpr (Master_matrix::Option_list::has_map_column_container) {
matrix_.at(targetColumnIndex).multiply_and_add(coefficient, sourceColumn);
matrix_.at(targetColumnIndex).multiply_target_and_add(coefficient, sourceColumn);
} else {
matrix_[targetColumnIndex].multiply_and_add(coefficient, sourceColumn);
matrix_[targetColumnIndex].multiply_target_and_add(coefficient, sourceColumn);
}
}
}
Expand All @@ -585,15 +585,15 @@ inline void Base_matrix<Master_matrix>::multiply_source_and_add_to(const Field_e
{
if constexpr (std::is_integral_v<Cell_range_or_column_index>) {
if constexpr (Master_matrix::Option_list::has_map_column_container) {
matrix_.at(targetColumnIndex).multiply_and_add(matrix_.at(sourceColumn), coefficient);
matrix_.at(targetColumnIndex).multiply_source_and_add(matrix_.at(sourceColumn), coefficient);
} else {
matrix_[targetColumnIndex].multiply_and_add(matrix_[sourceColumn], coefficient);
matrix_[targetColumnIndex].multiply_source_and_add(matrix_[sourceColumn], coefficient);
}
} else {
if constexpr (Master_matrix::Option_list::has_map_column_container) {
matrix_.at(targetColumnIndex).multiply_and_add(sourceColumn, coefficient);
matrix_.at(targetColumnIndex).multiply_source_and_add(sourceColumn, coefficient);
} else {
matrix_[targetColumnIndex].multiply_and_add(sourceColumn, coefficient);
matrix_[targetColumnIndex].multiply_source_and_add(sourceColumn, coefficient);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ inline void Base_matrix_with_column_compression<Master_matrix>::multiply_target_
Column_type& target = *repToColumn_[targetRep];
columnToRep_.erase(target);
if constexpr (std::is_integral_v<Cell_range_or_column_index>) {
target.multiply_and_add(coefficient, get_column(sourceColumn));
target.multiply_target_and_add(coefficient, get_column(sourceColumn));
} else {
target.multiply_and_add(coefficient, sourceColumn);
target.multiply_target_and_add(coefficient, sourceColumn);
}
_insert_column(targetRep);
}
Expand All @@ -569,9 +569,9 @@ inline void Base_matrix_with_column_compression<Master_matrix>::multiply_source_
Column_type& target = *repToColumn_[targetRep];
columnToRep_.erase(target);
if constexpr (std::is_integral_v<Cell_range_or_column_index>) {
target.multiply_and_add(get_column(sourceColumn), coefficient);
target.multiply_source_and_add(get_column(sourceColumn), coefficient);
} else {
target.multiply_and_add(sourceColumn, coefficient);
target.multiply_source_and_add(sourceColumn, coefficient);
}
_insert_column(targetRep);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ inline void Base_pairing<Master_matrix>::_reduce()
auto& operators = _matrix()->colSettings_->operators;
coef = operators.get_inverse(coef);
coef = operators.multiply(coef, operators.get_characteristic() - toadd.get_pivot_value());
curr.multiply_and_add(coef, toadd);
curr.multiply_target_and_add(coef, toadd);
}

pivot = curr.get_pivot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,9 @@ inline void Boundary_matrix<Master_matrix>::multiply_target_and_add_to(index sou
index targetColumnIndex)
{
if constexpr (Master_matrix::Option_list::has_map_column_container) {
matrix_.at(targetColumnIndex).multiply_and_add(coefficient, matrix_.at(sourceColumnIndex));
matrix_.at(targetColumnIndex).multiply_target_and_add(coefficient, matrix_.at(sourceColumnIndex));
} else {
matrix_[targetColumnIndex].multiply_and_add(coefficient, matrix_[sourceColumnIndex]);
matrix_[targetColumnIndex].multiply_target_and_add(coefficient, matrix_[sourceColumnIndex]);
}
}

Expand All @@ -689,9 +689,9 @@ inline void Boundary_matrix<Master_matrix>::multiply_source_and_add_to(const Fie
index targetColumnIndex)
{
if constexpr (Master_matrix::Option_list::has_map_column_container) {
matrix_.at(targetColumnIndex).multiply_and_add(matrix_.at(sourceColumnIndex), coefficient);
matrix_.at(targetColumnIndex).multiply_source_and_add(matrix_.at(sourceColumnIndex), coefficient);
} else {
matrix_[targetColumnIndex].multiply_and_add(matrix_[sourceColumnIndex], coefficient);
matrix_[targetColumnIndex].multiply_source_and_add(matrix_[sourceColumnIndex], coefficient);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,10 @@ inline void Chain_matrix<Master_matrix>::multiply_target_and_add_to(index source
{
if constexpr (Master_matrix::Option_list::has_map_column_container) {
auto& col = matrix_.at(targetColumnIndex);
_add_to(col, [&]() { col.multiply_and_add(coefficient, matrix_.at(sourceColumnIndex)); });
_add_to(col, [&]() { col.multiply_target_and_add(coefficient, matrix_.at(sourceColumnIndex)); });
} else {
auto& col = matrix_[targetColumnIndex];
_add_to(col, [&]() { col.multiply_and_add(coefficient, matrix_[sourceColumnIndex]); });
_add_to(col, [&]() { col.multiply_target_and_add(coefficient, matrix_[sourceColumnIndex]); });
}
}

Expand All @@ -875,10 +875,10 @@ inline void Chain_matrix<Master_matrix>::multiply_source_and_add_to(const Field_
{
if constexpr (Master_matrix::Option_list::has_map_column_container) {
auto& col = matrix_.at(targetColumnIndex);
_add_to(col, [&]() { col.multiply_and_add(matrix_.at(sourceColumnIndex), coefficient); });
_add_to(col, [&]() { col.multiply_source_and_add(matrix_.at(sourceColumnIndex), coefficient); });
} else {
auto& col = matrix_[targetColumnIndex];
_add_to(col, [&]() { col.multiply_and_add(matrix_[sourceColumnIndex], coefficient); });
_add_to(col, [&]() { col.multiply_source_and_add(matrix_[sourceColumnIndex], coefficient); });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ class Heap_column : public Master_matrix::Column_dimension_option, public Master

// this = v * this + column
template <class Cell_range>
Heap_column& multiply_and_add(const Field_element_type& val, const Cell_range& column);
Heap_column& multiply_and_add(const Field_element_type& val, Heap_column& column);
Heap_column& multiply_target_and_add(const Field_element_type& val, const Cell_range& column);
Heap_column& multiply_target_and_add(const Field_element_type& val, Heap_column& column);
// this = this + column * v
template <class Cell_range>
Heap_column& multiply_and_add(const Cell_range& column, const Field_element_type& val);
Heap_column& multiply_and_add(Heap_column& column, const Field_element_type& val);
Heap_column& multiply_source_and_add(const Cell_range& column, const Field_element_type& val);
Heap_column& multiply_source_and_add(Heap_column& column, const Field_element_type& val);

friend bool operator==(const Heap_column& c1, const Heap_column& c2) {
if (&c1 == &c2) return true;
Expand Down Expand Up @@ -191,9 +191,9 @@ class Heap_column : public Master_matrix::Column_dimension_option, public Master
template <class Cell_range>
bool _add(const Cell_range& column);
template <class Cell_range>
bool _multiply_and_add(const Field_element_type& val, const Cell_range& column);
bool _multiply_target_and_add(const Field_element_type& val, const Cell_range& column);
template <class Cell_range>
bool _multiply_and_add(const Cell_range& column, const Field_element_type& val);
bool _multiply_source_and_add(const Cell_range& column, const Field_element_type& val);
};

template <class Master_matrix>
Expand Down Expand Up @@ -713,7 +713,7 @@ inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::operator*=(

template <class Master_matrix>
template <class Cell_range>
inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(
inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_target_and_add(
const Field_element_type& val, const Cell_range& column)
{
static_assert((!Master_matrix::isNonBasic || std::is_same_v<Cell_range, Heap_column>),
Expand All @@ -730,14 +730,14 @@ inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(
_add(column);
}
} else {
_multiply_and_add(val, column);
_multiply_target_and_add(val, column);
}

return *this;
}

template <class Master_matrix>
inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(
inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_target_and_add(
const Field_element_type& val, Heap_column& column)
{
if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
Expand All @@ -752,7 +752,7 @@ inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(
throw std::invalid_argument("A chain column should not be multiplied by 0.");
}
} else {
if (_multiply_and_add(val, column)) {
if (_multiply_target_and_add(val, column)) {
chain_opt::swap_pivots(column);
dim_opt::swap_dimension(column);
}
Expand All @@ -766,7 +766,7 @@ inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(
_add(column);
}
} else {
_multiply_and_add(val, column);
_multiply_target_and_add(val, column);
}
}

Expand All @@ -775,7 +775,7 @@ inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(

template <class Master_matrix>
template <class Cell_range>
inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(
inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_source_and_add(
const Cell_range& column, const Field_element_type& val)
{
static_assert((!Master_matrix::isNonBasic || std::is_same_v<Cell_range, Heap_column>),
Expand All @@ -789,14 +789,14 @@ inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(
_add(column);
}
} else {
_multiply_and_add(column, val);
_multiply_source_and_add(column, val);
}

return *this;
}

template <class Master_matrix>
inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(
inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_source_and_add(
Heap_column& column, const Field_element_type& val)
{
if constexpr (Master_matrix::isNonBasic && !Master_matrix::Option_list::is_of_boundary_type) {
Expand All @@ -809,7 +809,7 @@ inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(
}
}
} else {
if (_multiply_and_add(column, val)) {
if (_multiply_source_and_add(column, val)) {
chain_opt::swap_pivots(column);
dim_opt::swap_dimension(column);
}
Expand All @@ -820,7 +820,7 @@ inline Heap_column<Master_matrix>& Heap_column<Master_matrix>::multiply_and_add(
_add(column);
}
} else {
_multiply_and_add(column, val);
_multiply_source_and_add(column, val);
}
}

Expand Down Expand Up @@ -966,7 +966,7 @@ inline bool Heap_column<Master_matrix>::_add(const Cell_range& column)

template <class Master_matrix>
template <class Cell_range>
inline bool Heap_column<Master_matrix>::_multiply_and_add(const Field_element_type& val,
inline bool Heap_column<Master_matrix>::_multiply_target_and_add(const Field_element_type& val,
const Cell_range& column)
{
if (val == 0u) {
Expand Down Expand Up @@ -1017,7 +1017,7 @@ inline bool Heap_column<Master_matrix>::_multiply_and_add(const Field_element_ty

template <class Master_matrix>
template <class Cell_range>
inline bool Heap_column<Master_matrix>::_multiply_and_add(const Cell_range& column,
inline bool Heap_column<Master_matrix>::_multiply_source_and_add(const Cell_range& column,
const Field_element_type& val)
{
if (val == 0u || column.begin() == column.end()) {
Expand Down
Loading

0 comments on commit b8d6c3d

Please sign in to comment.