SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
|
A two dimensional matrix used inside of alignment algorithms. More...
#include <seqan3/alignment/matrix/detail/two_dimensional_matrix.hpp>
Classes | |
class | basic_iterator |
A two-dimensional matrix iterator. More... | |
Public Types | |
Associated types | |
using | value_type = typename storage_type::value_type |
The value type. | |
using | reference = typename storage_type::reference |
The reference type. | |
using | const_reference = typename storage_type::const_reference |
The const reference type. | |
using | pointer = typename storage_type::pointer |
The pointer type. | |
using | const_pointer = typename storage_type::const_pointer |
The pointer type. | |
using | difference_type = typename storage_type::difference_type |
The difference type. | |
using | size_type = typename storage_type::size_type |
The difference type. | |
using | iterator = basic_iterator< false > |
The iterator type. | |
using | const_iterator = basic_iterator< true > |
Public Member Functions | |
constexpr reference | at (matrix_coordinate const &coordinate) |
A reference to the entry of the matrix at the given coordinate. | |
constexpr const_reference | at (matrix_coordinate const &coordinate) const |
A reference to the entry of the matrix at the given coordinate. | |
size_t | cols () const noexcept |
The number of columns in the matrix. | |
constexpr const_pointer | data () const noexcept |
Returns a pointer to the data. | |
constexpr pointer | data () noexcept |
Returns a pointer to the data. | |
constexpr const_reference | operator[] (matrix_coordinate const &coordinate) const noexcept |
Returns a reference to the element at the given coordinate. | |
constexpr reference | operator[] (matrix_coordinate const &coordinate) noexcept |
Returns a reference to the element at the given coordinate. | |
void | resize (number_rows const row_dim, number_cols const col_dim) |
Resizes the underlying matrix storage to the given matrix dimensions. | |
size_t | rows () const noexcept |
The number of rows in the matrix. | |
Constructors, destructor and assignment | |
two_dimensional_matrix ()=default | |
Defaulted. | |
two_dimensional_matrix (two_dimensional_matrix const &)=default | |
Defaulted. | |
two_dimensional_matrix (two_dimensional_matrix &&)=default | |
Defaulted. | |
two_dimensional_matrix & | operator= (two_dimensional_matrix const &)=default |
Defaulted. | |
two_dimensional_matrix & | operator= (two_dimensional_matrix &&)=default |
Defaulted. | |
~two_dimensional_matrix ()=default | |
Defaulted. | |
two_dimensional_matrix (number_rows const row_dim, number_cols const col_dim) | |
Constructs the matrix by the given dimensions. | |
template<std::ranges::forward_range entries_t> requires (std::convertible_to<std::ranges::range_value_t<entries_t>, value_type>) | |
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. | |
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 only in what argument(s) it accepts. | |
template<typename other_value_t , typename other_allocator_t , matrix_major_order other_order> requires std::assignable_from<other_value_t &, value_t &> | |
constexpr | two_dimensional_matrix (two_dimensional_matrix< other_value_t, other_allocator_t, other_order > const &matrix) |
Explicit construction from the other major-order. | |
Iterators | |
Provides iterators to move in two-dimensional space. | |
constexpr iterator | begin () noexcept |
Returns an iterator pointing to the first element of the matrix. | |
constexpr const_iterator | begin () const noexcept |
Returns an iterator pointing to the first element of the matrix. | |
constexpr const_iterator | cbegin () const noexcept |
Returns an iterator pointing to the first element of the matrix. | |
constexpr iterator | end () noexcept |
Returns an iterator pointing behind-the-end of the matrix. | |
constexpr const_iterator | end () const noexcept |
Returns an iterator pointing behind-the-end of the matrix. | |
constexpr const_iterator | cend () const noexcept |
Returns an iterator pointing behind-the-end of the matrix. | |
Private Types | |
Auxiliary types | |
using | storage_type = std::vector< value_t, allocator_t > |
Private Attributes | |
size_type | col_dim |
The number of columns in the matrix. | |
size_type | row_dim |
The number of rows in the matrix. | |
storage_type | storage |
The matrix as a one-dimensional (flattened) vector of entries. | |
A two dimensional matrix used inside of alignment algorithms.
value_t | The value type to store. |
allocator_t | The allocator type used to allocate the storage; defaults to std::allocator. |
order | The matrix-major-order; defaults to seqan3::detail::matrix_major_order::row. |
This two dimensional matrix type is a base data structure for several alignment matrices. It can be customised over the value type, the allocator type and the major matrix order. The data is stored in a flat std::vector. Depending on the given order
, the element access on the underlying buffer follows a row-major-order or a column-major-order. Accordingly, it is cache friendly and thus more efficient to access the data in the row-major-order row by row instead of column by column and vice versa for the column-major-order.
using seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::const_iterator = basic_iterator<true> |
The const iterator type.
|
private |
The storage type.
|
inline |
Constructs the matrix by the given dimensions.
row_dim | The row dimension (number of rows). |
col_dim | The column dimension (number of columns). |
|
inline |
Constructs the matrix by the given dimensions and initialises it with the given range.
entries_t | Range of values that are convertible to value_type; must model std::ranges::forward_range |
[in] | row_dim | The row dimension (number of rows). |
[in] | col_dim | The column dimension (number of columns). |
[in] | entries | A range used to fill the underlying matrix. |
|
inlineexplicitconstexpr |
Explicit construction from the other major-order.
other_value_t | The target value type; must be assignable from value_t . |
other_allocator_t | The allocator type used for the target matrix. |
other_order | The other seqan3::detail::matrix_major_order. |
Copies the matrix cell by cell, rearranging the stored elements in the internal memory to represent the converted major-order.
Consider the following matrix:
0 1 2 3 4 5 6 7 8 9 10 11
In row-major-order the data is stored in a flat vector in the following way: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
Converting it to column-major-order will rearrange the elements: 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11
Note that the matrix is not transposed, so that the general layout as displayed above will remain the same. It only changes the matrix major order, i.e. data stored row wise is now stored column wise and vice versa.
|
inlineconstexpr |
A reference to the entry of the matrix at the given coordinate.
|
inlineconstexpr |
A reference to the entry of the matrix at the given coordinate.
|
inlineconstexprnoexcept |
Returns an iterator pointing to the first element of the matrix.
|
inlineconstexprnoexcept |
Returns an iterator pointing to the first element of the matrix.
|
inlineconstexprnoexcept |
Returns an iterator pointing behind-the-end of the matrix.
|
inlinenoexcept |
The number of columns in the matrix.
|
inlineconstexprnoexcept |
Returns an iterator pointing behind-the-end of the matrix.
|
inlineconstexprnoexcept |
Returns a reference to the element at the given coordinate.
[in] | coordinate | The two-dimensional coordinate to access. |
|
inlineconstexprnoexcept |
Returns a reference to the element at the given coordinate.
[in] | coordinate | The two-dimensional coordinate to access. |
|
inline |
Resizes the underlying matrix storage to the given matrix dimensions.
row_dim | The row dimension (row count). |
col_dim | The column dimension (column count). |
|
inlinenoexcept |
The number of rows in the matrix.
|
private |
The number of columns in the matrix.
|
private |
The number of rows in the matrix.