29namespace seqan3::detail
50template <
typename trace_t>
51 requires std::same_as<trace_t, trace_directions>
52class trace_matrix_full
57 two_dimensional_matrix<trace_t, aligned_allocator<trace_t,
sizeof(trace_t)>, matrix_major_order::column>;
66 matrix_t complete_matrix{};
68 physical_column_t horizontal_column{};
70 virtual_column_t vertical_column{};
72 size_t column_count{};
80 trace_matrix_full() =
default;
81 trace_matrix_full(trace_matrix_full
const &) =
default;
82 trace_matrix_full(trace_matrix_full &&) =
default;
83 trace_matrix_full & operator=(trace_matrix_full
const &) =
default;
84 trace_matrix_full & operator=(trace_matrix_full &&) =
default;
85 ~trace_matrix_full() =
default;
111 template <std::
integral column_index_t, std::
integral row_index_t>
112 void resize(column_index_type<column_index_t>
const column_count, row_index_type<row_index_t>
const row_count)
114 this->column_count = column_count.get();
115 this->row_count = row_count.get();
116 complete_matrix.
resize(number_rows{this->row_count}, number_cols{this->column_count});
117 horizontal_column.resize(this->row_count);
127 auto trace_path(matrix_coordinate
const & trace_begin)
const
129 using matrix_iter_t = std::ranges::iterator_t<matrix_t const>;
130 using trace_iterator_t = trace_iterator<matrix_iter_t>;
131 using path_t = std::ranges::subrange<trace_iterator_t, std::default_sentinel_t>;
133 if (trace_begin.row >= row_count || trace_begin.col >= column_count)
134 throw std::invalid_argument{
"The given coordinate exceeds the matrix in vertical or horizontal direction."};
136 return path_t{trace_iterator_t{complete_matrix.begin() + matrix_offset{trace_begin}}, std::default_sentinel};
145 return iterator{*
this, 0u};
149 iterator
begin()
const =
delete;
154 return iterator{*
this, column_count};
158 iterator
end()
const =
delete;
171template <
typename trace_t>
172 requires std::same_as<trace_t, trace_directions>
173class trace_matrix_full<trace_t>::iterator
179 using matrix_column_type =
decltype(
views::zip(std::declval<single_trace_column_type>(),
180 std::declval<physical_column_t &>(),
181 std::declval<virtual_column_t &>()));
189 trace_matrix_full * host_ptr{
nullptr};
191 size_t current_column_id{};
198 using value_type = matrix_column_value_t;
200 using reference = column_proxy;
202 using pointer = void;
212 iterator() noexcept = default;
213 iterator(iterator const &) noexcept = default;
214 iterator(iterator &&) noexcept = default;
215 iterator & operator=(iterator const &) noexcept = default;
216 iterator & operator=(iterator &&) noexcept = default;
217 ~iterator() = default;
224 explicit iterator(trace_matrix_full & host_matrix,
size_t const initial_column_id) noexcept :
226 current_column_id{initial_column_id}
234 reference operator*()
const
236 auto column_begin = host_ptr->complete_matrix.data() + current_column_id * host_ptr->row_count;
237 single_trace_column_type single_trace_column{column_begin, column_begin + host_ptr->row_count};
240 views::zip(std::move(single_trace_column), host_ptr->horizontal_column, host_ptr->vertical_column)};
248 iterator & operator++()
265 friend bool operator==(iterator
const & lhs, iterator
const & rhs)
noexcept
267 return lhs.current_column_id == rhs.current_column_id;
271 friend bool operator!=(iterator
const & lhs, iterator
const & rhs)
noexcept
273 return !(lhs == rhs);
286template <
typename trace_t>
287 requires std::same_as<trace_t, trace_directions>
288class trace_matrix_full<trace_t>::iterator::column_proxy :
public std::ranges::view_interface<column_proxy>
292 matrix_column_type column{};
298 column_proxy() =
default;
299 column_proxy(column_proxy
const &) =
default;
300 column_proxy(column_proxy &&) =
default;
301 column_proxy & operator=(column_proxy
const &) =
default;
302 column_proxy & operator=(column_proxy &&) =
default;
303 ~column_proxy() =
default;
309 explicit column_proxy(matrix_column_type && column) noexcept : column{std::move(column)}
317 std::ranges::iterator_t<matrix_column_type>
begin()
319 return column.begin();
322 std::ranges::iterator_t<matrix_column_type>
begin()
const =
delete;
325 std::ranges::sentinel_t<matrix_column_type>
end()
331 std::ranges::sentinel_t<matrix_column_type>
end()
const =
delete;
335 constexpr operator matrix_column_value_t()
const
337 matrix_column_value_t target{};
Provides seqan3::aligned_allocator.
T back_inserter(T... args)
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:91
seqan::std::views::zip zip
A view adaptor that takes several views and returns tuple-like values from every i-th element of each...
Definition: zip.hpp:27
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
Provides seqan3::views::repeat_n.
Provides type traits for working with templates.
Provides the declaration of seqan3::detail::trace_directions.
Provides seqan3::detail::trace_iterator.
Provides seqan3::detail::two_dimensional_matrix.
Provides concepts that do not have equivalents in C++20.
Provides seqan3::views::zip.