SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order > Class Template Reference

A two dimensional matrix used inside of alignment algorithms. More...

#include <seqan3/alignment/matrix/detail/two_dimensional_matrix.hpp>

+ Inheritance diagram for seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >:

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_matrixoperator= (two_dimensional_matrix const &)=default
 Defaulted.
 
two_dimensional_matrixoperator= (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.
 

Detailed Description

template<typename value_t, typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
class seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >

A two dimensional matrix used inside of alignment algorithms.

Template Parameters
value_tThe value type to store.
allocator_tThe allocator type used to allocate the storage; defaults to std::allocator.
orderThe 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.

Member Typedef Documentation

◆ const_iterator

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
using seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::const_iterator = basic_iterator<true>

The const iterator type.

◆ storage_type

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
using seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::storage_type = std::vector<value_t, allocator_t>
private

The storage type.

Constructor & Destructor Documentation

◆ two_dimensional_matrix() [1/3]

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::two_dimensional_matrix ( number_rows const  row_dim,
number_cols const  col_dim 
)
inline

Constructs the matrix by the given dimensions.

Parameters
row_dimThe row dimension (number of rows).
col_dimThe column dimension (number of columns).

◆ two_dimensional_matrix() [2/3]

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
template<std::ranges::forward_range entries_t>
requires (std::convertible_to<std::ranges::range_value_t<entries_t>, value_type>)
seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::two_dimensional_matrix ( number_rows const  row_dim,
number_cols const  col_dim,
entries_t  entries 
)
inline

Constructs the matrix by the given dimensions and initialises it with the given range.

Template Parameters
entries_tRange of values that are convertible to value_type; must model std::ranges::forward_range
Parameters
[in]row_dimThe row dimension (number of rows).
[in]col_dimThe column dimension (number of columns).
[in]entriesA range used to fill the underlying matrix.

◆ two_dimensional_matrix() [3/3]

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
template<typename other_value_t , typename other_allocator_t , matrix_major_order other_order>
requires std::assignable_from<other_value_t &, value_t &>
constexpr seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::two_dimensional_matrix ( two_dimensional_matrix< other_value_t, other_allocator_t, other_order > const &  matrix)
inlineexplicitconstexpr

Explicit construction from the other major-order.

Template Parameters
other_value_tThe target value type; must be assignable from value_t.
other_allocator_tThe allocator type used for the target matrix.
other_orderThe 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.

Member Function Documentation

◆ at() [1/2]

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
constexpr reference seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::at ( matrix_coordinate const &  coordinate)
inlineconstexpr

A reference to the entry of the matrix at the given coordinate.

◆ at() [2/2]

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
constexpr const_reference seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::at ( matrix_coordinate const &  coordinate) const
inlineconstexpr

A reference to the entry of the matrix at the given coordinate.

◆ begin()

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
constexpr const_iterator seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::begin ( ) const
inlineconstexprnoexcept

Returns an iterator pointing to the first element of the matrix.

◆ cbegin()

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
constexpr const_iterator seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::cbegin ( ) const
inlineconstexprnoexcept

Returns an iterator pointing to the first element of the matrix.

◆ cend()

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
constexpr const_iterator seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::cend ( ) const
inlineconstexprnoexcept

Returns an iterator pointing behind-the-end of the matrix.

◆ cols()

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
size_t seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::cols ( ) const
inlinenoexcept

The number of columns in the matrix.

◆ end()

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
constexpr const_iterator seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::end ( ) const
inlineconstexprnoexcept

Returns an iterator pointing behind-the-end of the matrix.

◆ operator[]() [1/2]

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
constexpr const_reference seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::operator[] ( matrix_coordinate const &  coordinate) const
inlineconstexprnoexcept

Returns a reference to the element at the given coordinate.

Parameters
[in]coordinateThe two-dimensional coordinate to access.

◆ operator[]() [2/2]

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
constexpr reference seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::operator[] ( matrix_coordinate const &  coordinate)
inlineconstexprnoexcept

Returns a reference to the element at the given coordinate.

Parameters
[in]coordinateThe two-dimensional coordinate to access.

◆ resize()

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
void seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::resize ( number_rows const  row_dim,
number_cols const  col_dim 
)
inline

Resizes the underlying matrix storage to the given matrix dimensions.

Parameters
row_dimThe row dimension (row count).
col_dimThe column dimension (column count).

◆ rows()

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
size_t seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::rows ( ) const
inlinenoexcept

The number of rows in the matrix.

Member Data Documentation

◆ col_dim

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
size_type seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::col_dim
private

The number of columns in the matrix.

◆ row_dim

template<typename value_t , typename allocator_t = std::allocator<value_t>, matrix_major_order order = matrix_major_order::row>
size_type seqan3::detail::two_dimensional_matrix< value_t, allocator_t, order >::row_dim
private

The number of rows in the matrix.


The documentation for this class was generated from the following file:
Hide me