Loading...
Searching...
No Matches
trace_iterator_banded.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <seqan3/alignment/matrix/detail/trace_iterator_base.hpp>
namespace seqan3::detail
{
template <two_dimensional_matrix_iterator matrix_iter_t>
class trace_iterator_banded : public trace_iterator_base<trace_iterator_banded<matrix_iter_t>, matrix_iter_t>
{
private:
static_assert(std::same_as<std::iter_value_t<matrix_iter_t>, trace_directions>,
"Value type of the underlying iterator must be trace_directions.");
using base_t = trace_iterator_base<trace_iterator_banded<matrix_iter_t>, matrix_iter_t>;
friend base_t;
public:
constexpr trace_iterator_banded() = default;
constexpr trace_iterator_banded(trace_iterator_banded const &) = default;
constexpr trace_iterator_banded(trace_iterator_banded &&) = default;
constexpr trace_iterator_banded & operator=(trace_iterator_banded const &) = default;
constexpr trace_iterator_banded & operator=(trace_iterator_banded &&) = default;
~trace_iterator_banded() = default;
template <typename index_t>
constexpr trace_iterator_banded(matrix_iter_t const matrix_iter,
column_index_type<index_t> const & pivot_column) noexcept :
base_t{matrix_iter},
pivot_column{static_cast<size_t>(pivot_column.get())}
{}
template <two_dimensional_matrix_iterator other_matrix_iter_t>
requires std::constructible_from<matrix_iter_t, other_matrix_iter_t>
constexpr trace_iterator_banded(trace_iterator_banded<other_matrix_iter_t> const other) noexcept : base_t{other}
{}
[[nodiscard]] constexpr matrix_coordinate coordinate() const noexcept
{
auto coord = base_t::coordinate();
coord.row += static_cast<int32_t>(coord.col - pivot_column);
return coord;
}
private:
constexpr void go_left(matrix_iter_t & iter) const noexcept
{
// Note, in the banded matrix, the columns are virtually shifted by one cell.
// So going left means go to the previous column and then one row down.
iter -= matrix_offset{row_index_type{-1}, column_index_type{1}};
}
constexpr void go_diagonal(matrix_iter_t & iter) const noexcept
{
// Note, in the banded matrix, the columns are virtually shifted by one cell.
// So going diagonal means go to the previous column and stay in the same row.
iter -= matrix_offset{row_index_type{0}, column_index_type{1}};
}
size_t pivot_column{};
};
} // namespace seqan3::detail
trace_iterator_base.hpp
Provides seqan3::detail::trace_iterator_base.
Hide me