61template <
typename value_t,
74 template <
bool const_range>
86 using pointer =
typename storage_type::pointer;
121 template <std::ranges::forward_range entries_t>
122 requires (std::convertible_to<std::ranges::range_value_t<entries_t>,
value_type>)
127 static_assert(std::move_constructible<std::ranges::range_value_t<entries_t>>,
128 "The value type must be moveable.");
130 assert(
static_cast<size_t>(std::ranges::distance(entries)) == (
row_dim.get() *
col_dim.get()));
140 assert(
static_cast<size_t>(std::ranges::distance(entries)) == (
row_dim.get() *
col_dim.get()));
169 template <
typename other_value_t,
typename other_allocator_t, matrix_major_order other_order>
170 requires std::assignable_from<other_value_t &, value_t &>
175 for (
size_t i = 0; i <
cols(); ++i)
177 for (
size_t j = 0; j <
rows(); ++j)
180 (*this)[coord] =
matrix[coord];
191 assert(coordinate.col <
cols());
192 assert(coordinate.row <
rows());
202 assert(coordinate.col <
cols());
203 assert(coordinate.row <
rows());
213 if (coordinate.col >=
cols())
214 throw std::invalid_argument{
"Column index is out of range. Please check the dimensions of the matrix."};
215 if (coordinate.row >=
rows())
216 throw std::invalid_argument{
"Row index is out of range. Please check the dimensions of the matrix."};
218 return (*
this)[coordinate];
224 if (coordinate.col >=
cols())
225 throw std::invalid_argument{
"Column index is out of range. Please check the dimensions of the matrix."};
226 if (coordinate.row >=
rows())
227 throw std::invalid_argument{
"Row index is out of range. Please check the dimensions of the matrix."};
229 return (*
this)[coordinate];
322template <
typename value_t,
typename allocator_t, matrix_major_order order>
323template <
bool const_range>
335 template <
typename derived_t, matrix_major_order other_order>
336 requires is_value_specialisation_of_v<derived_t, basic_iterator> && (other_order == order)
340 template <
bool other_const_range>
355 using pointer =
typename storage_iterator::pointer;
382 : matrix_ptr{other.matrix_ptr}, host_iter{other.host_iter}
387 using base_t::operator+=;
392 assert(matrix_ptr !=
nullptr);
396 host_iter += (
offset.col * matrix_ptr->rows());
402 host_iter += (
offset.row * matrix_ptr->cols());
410 assert(matrix_ptr !=
nullptr);
412 auto diff = *
this - matrix_ptr->begin();
Defines the requirements of a matrix (e.g. score matrices, trace matrices).
Definition: matrix_concept.hpp:61
CRTP base class to declare a strong typedef for a regular type to avoid ambiguous parameter settings ...
Definition: strong_type.hpp:177
constexpr strong_type() noexcept=default
Defaulted.
A two-dimensional matrix iterator.
Definition: two_dimensional_matrix.hpp:326
constexpr basic_iterator(parent_t &matrix, storage_iterator iter)
Construction from the underlying matrix and the iterator over actual storage.
Definition: two_dimensional_matrix.hpp:376
matrix_coordinate coordinate() const noexcept
Returns the current position of the iterator as a two-dimensional matrix coordinate.
Definition: two_dimensional_matrix.hpp:408
constexpr basic_iterator & operator+=(matrix_offset const &offset) noexcept
Advances the iterator by the given offset.
Definition: two_dimensional_matrix.hpp:390
constexpr basic_iterator(basic_iterator &&)=default
Defaulted.
constexpr basic_iterator & operator=(basic_iterator &&)=default
Defaulted.
detail::maybe_const_iterator_t< const_range, storage_type > storage_iterator
The iterator of the underlying storage.
Definition: two_dimensional_matrix.hpp:344
typename storage_iterator::pointer pointer
The pointer type.
Definition: two_dimensional_matrix.hpp:355
constexpr basic_iterator & operator=(basic_iterator const &)=default
Defaulted.
constexpr basic_iterator()=default
Defaulted.
~basic_iterator()=default
Defaulted.
constexpr basic_iterator(basic_iterator const &)=default
Defaulted.
constexpr basic_iterator(basic_iterator<!const_range > const &other) noexcept
Construction of cons-iterator from non-const-iterator.
Definition: two_dimensional_matrix.hpp:380
A crtp-base class for iterators over seqan3::detail::two_dimensional_matrix.
Definition: two_dimensional_matrix_iterator_base.hpp:77
A two dimensional matrix used inside of alignment algorithms.
Definition: two_dimensional_matrix.hpp:65
size_type row_dim
The number of rows in the matrix.
Definition: two_dimensional_matrix.hpp:310
two_dimensional_matrix(number_rows const row_dim, number_cols const col_dim)
Constructs the matrix by the given dimensions.
Definition: two_dimensional_matrix.hpp:108
constexpr iterator begin() noexcept
Returns an iterator pointing to the first element of the matrix.
Definition: two_dimensional_matrix.hpp:273
typename storage_type::reference reference
The reference type.
Definition: two_dimensional_matrix.hpp:84
typename storage_type::pointer pointer
The pointer type.
Definition: two_dimensional_matrix.hpp:86
constexpr const_reference operator[](matrix_coordinate const &coordinate) const noexcept
Returns a reference to the element at the given coordinate.
Definition: two_dimensional_matrix.hpp:200
constexpr two_dimensional_matrix(two_dimensional_matrix< other_value_t, other_allocator_t, other_order > const &matrix)
Explicit construction from the other major-order.
Definition: two_dimensional_matrix.hpp:171
constexpr const_iterator begin() const noexcept
Returns an iterator pointing to the first element of the matrix.
Definition: two_dimensional_matrix.hpp:278
two_dimensional_matrix & operator=(two_dimensional_matrix &&)=default
Defaulted.
two_dimensional_matrix()=default
Defaulted.
size_type col_dim
The number of columns in the matrix.
Definition: two_dimensional_matrix.hpp:311
void resize(number_rows const row_dim, number_cols const col_dim)
Resizes the underlying matrix storage to the given matrix dimensions.
Definition: two_dimensional_matrix.hpp:237
constexpr const_pointer data() const noexcept
Returns a pointer to the data.
Definition: two_dimensional_matrix.hpp:263
typename storage_type::const_reference const_reference
The const reference type.
Definition: two_dimensional_matrix.hpp:85
constexpr const_iterator cbegin() const noexcept
Returns an iterator pointing to the first element of the matrix.
Definition: two_dimensional_matrix.hpp:284
two_dimensional_matrix(two_dimensional_matrix const &)=default
Defaulted.
constexpr pointer data() noexcept
Returns a pointer to the data.
Definition: two_dimensional_matrix.hpp:257
constexpr reference operator[](matrix_coordinate const &coordinate) noexcept
Returns a reference to the element at the given coordinate.
Definition: two_dimensional_matrix.hpp:189
storage_type storage
The matrix as a one-dimensional (flattened) vector of entries.
Definition: two_dimensional_matrix.hpp:309
two_dimensional_matrix(number_rows const row_dim, number_cols const col_dim, entries_t entries)
Constructs the matrix by the given dimensions and initialises it with the given range.
Definition: two_dimensional_matrix.hpp:123
~two_dimensional_matrix()=default
Defaulted.
constexpr const_iterator cend() const noexcept
Returns an iterator pointing behind-the-end of the matrix.
Definition: two_dimensional_matrix.hpp:302
size_t cols() const noexcept
The number of columns in the matrix.
Definition: two_dimensional_matrix.hpp:251
constexpr const_reference at(matrix_coordinate const &coordinate) const
A reference to the entry of the matrix at the given coordinate.
Definition: two_dimensional_matrix.hpp:222
typename storage_type::value_type value_type
The value type.
Definition: two_dimensional_matrix.hpp:83
two_dimensional_matrix(number_rows const row_dim, number_cols const col_dim, storage_type entries)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: two_dimensional_matrix.hpp:136
typename storage_type::const_pointer const_pointer
The pointer type.
Definition: two_dimensional_matrix.hpp:87
constexpr iterator end() noexcept
Returns an iterator pointing behind-the-end of the matrix.
Definition: two_dimensional_matrix.hpp:290
constexpr reference at(matrix_coordinate const &coordinate)
A reference to the entry of the matrix at the given coordinate.
Definition: two_dimensional_matrix.hpp:211
two_dimensional_matrix(two_dimensional_matrix &&)=default
Defaulted.
two_dimensional_matrix & operator=(two_dimensional_matrix const &)=default
Defaulted.
constexpr const_iterator end() const noexcept
Returns an iterator pointing behind-the-end of the matrix.
Definition: two_dimensional_matrix.hpp:296
typename storage_type::size_type size_type
The difference type.
Definition: two_dimensional_matrix.hpp:89
size_t rows() const noexcept
The number of rows in the matrix.
Definition: two_dimensional_matrix.hpp:245
typename storage_type::difference_type difference_type
The difference type.
Definition: two_dimensional_matrix.hpp:88
Provides various transformation traits used by the range module.
Provides seqan3::detail::deferred_crtp_base.
matrix_major_order
Selects the major order of the matrix.
Definition: two_dimensional_matrix_iterator_base.hpp:39
@ column
Accesses matrix in column major order.
@ row
Accesses matrix in row major order.
std::ranges::iterator_t< maybe_const_range_t< const_range, range_t > > maybe_const_iterator_t
Returns the const iterator of range_t if const_range is true; otherwise the non-const iterator.
Definition: core/range/type_traits.hpp:44
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
constexpr auto const & get(configuration< configs_t... > const &config) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: configuration.hpp:415
A strong type for designated initialisation of the column index of a matrix.
Definition: matrix_coordinate.hpp:32
A representation of a location or offset within a two-dimensional matrix.
Definition: matrix_coordinate.hpp:90
Strong type for setting the column dimension of a matrix.
Definition: two_dimensional_matrix.hpp:32
Strong type for setting the row dimension of a matrix.
Definition: two_dimensional_matrix.hpp:40
A strong type for designated initialisation of the row index of a matrix.
Definition: matrix_coordinate.hpp:61
Provides type traits for working with templates.
Provides seqan3::detail::two_dimensional_matrix_iterator_base.