SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
trace_iterator_banded.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
13
14namespace seqan3::detail
15{
16
28template <two_dimensional_matrix_iterator matrix_iter_t>
29class trace_iterator_banded : public trace_iterator_base<trace_iterator_banded<matrix_iter_t>, matrix_iter_t>
30{
31private:
32 static_assert(std::same_as<std::iter_value_t<matrix_iter_t>, trace_directions>,
33 "Value type of the underlying iterator must be trace_directions.");
34
36 using base_t = trace_iterator_base<trace_iterator_banded<matrix_iter_t>, matrix_iter_t>;
37
39 friend base_t;
40
41public:
45 constexpr trace_iterator_banded() = default;
46 constexpr trace_iterator_banded(trace_iterator_banded const &) = default;
47 constexpr trace_iterator_banded(trace_iterator_banded &&) = default;
48 constexpr trace_iterator_banded & operator=(trace_iterator_banded const &) = default;
49 constexpr trace_iterator_banded & operator=(trace_iterator_banded &&) = default;
50 ~trace_iterator_banded() = default;
51
57 template <typename index_t>
58 constexpr trace_iterator_banded(matrix_iter_t const matrix_iter,
59 column_index_type<index_t> const & pivot_column) noexcept :
60 base_t{matrix_iter},
61 pivot_column{static_cast<size_t>(pivot_column.get())}
62 {}
63
73 template <two_dimensional_matrix_iterator other_matrix_iter_t>
74 requires std::constructible_from<matrix_iter_t, other_matrix_iter_t>
75 constexpr trace_iterator_banded(trace_iterator_banded<other_matrix_iter_t> const other) noexcept : base_t{other}
76 {}
78
80 [[nodiscard]] constexpr matrix_coordinate coordinate() const noexcept
81 {
82 auto coord = base_t::coordinate();
83 coord.row += static_cast<int32_t>(coord.col - pivot_column);
84 return coord;
85 }
86
87private:
89 constexpr void go_left(matrix_iter_t & iter) const noexcept
90 {
91 // Note, in the banded matrix, the columns are virtually shifted by one cell.
92 // So going left means go to the previous column and then one row down.
93 iter -= matrix_offset{row_index_type{-1}, column_index_type{1}};
94 }
95
97 constexpr void go_diagonal(matrix_iter_t & iter) const noexcept
98 {
99 // Note, in the banded matrix, the columns are virtually shifted by one cell.
100 // So going diagonal means go to the previous column and stay in the same row.
101 iter -= matrix_offset{row_index_type{0}, column_index_type{1}};
102 }
103
104 size_t pivot_column{};
105};
106
107} // namespace seqan3::detail
Provides seqan3::detail::trace_iterator_base.
Hide me