Loading...
Searching...
No Matches
alignment_score_matrix_one_column.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 <iterator>
#include <ranges>
#include <span>
#include <seqan3/alignment/matrix/detail/alignment_matrix_column_major_range_base.hpp>
#include <seqan3/alignment/matrix/detail/alignment_score_matrix_one_column_base.hpp>
#include <seqan3/alignment/matrix/detail/alignment_score_matrix_proxy.hpp>
#include <seqan3/utility/concept.hpp>
#include <seqan3/utility/simd/concept.hpp>
namespace seqan3::detail
{
template <typename score_t>
class alignment_score_matrix_one_column :
protected alignment_score_matrix_one_column_base<score_t>,
public alignment_matrix_column_major_range_base<alignment_score_matrix_one_column<score_t>>
{
private:
static_assert(arithmetic<score_t> || simd_concept<score_t>,
"The score type must be either an arithmetic type or a simd vector type.");
using matrix_base_t = alignment_score_matrix_one_column_base<score_t>;
using range_base_t = alignment_matrix_column_major_range_base<alignment_score_matrix_one_column<score_t>>;
friend range_base_t;
protected:
using typename matrix_base_t::element_type;
using typename range_base_t::alignment_column_type;
using column_data_view_type = std::span<element_type>;
using matrix_base_t::num_cols;
public:
using value_type = alignment_score_matrix_proxy<score_t>;
using reference = value_type;
using iterator = typename range_base_t::iterator;
using sentinel = typename range_base_t::sentinel;
using typename matrix_base_t::size_type;
using typename matrix_base_t::underlying_type;
constexpr alignment_score_matrix_one_column() = default;
constexpr alignment_score_matrix_one_column(alignment_score_matrix_one_column const &) = default;
constexpr alignment_score_matrix_one_column(alignment_score_matrix_one_column &&) = default;
constexpr alignment_score_matrix_one_column & operator=(alignment_score_matrix_one_column const &) = default;
constexpr alignment_score_matrix_one_column & operator=(alignment_score_matrix_one_column &&) = default;
~alignment_score_matrix_one_column() = default;
template <std::ranges::forward_range first_sequence_t, std::ranges::forward_range second_sequence_t>
constexpr alignment_score_matrix_one_column(first_sequence_t && first,
second_sequence_t && second,
score_t const initial_value = score_t{})
{
matrix_base_t::num_cols = static_cast<size_type>(std::ranges::distance(first) + 1);
matrix_base_t::num_rows = static_cast<size_type>(std::ranges::distance(second) + 1);
matrix_base_t::pool.resize(matrix_base_t::num_rows + 1, element_type{initial_value, initial_value});
}
private:
constexpr alignment_column_type initialise_column(size_type const SEQAN3_DOXYGEN_ONLY(column_index)) noexcept
{
return alignment_column_type{
*this,
column_data_view_type{std::addressof(matrix_base_t::pool[0]), matrix_base_t::num_rows}};
}
template <std::random_access_iterator iter_t>
constexpr value_type make_proxy(iter_t host_iter) noexcept
{
return {std::get<0>(*host_iter), // current
std::get<0>(matrix_base_t::cache), // last diagonal
std::get<1>(*host_iter), // last left (read)
std::get<1>(*host_iter), // next left (write)
std::get<2>(matrix_base_t::cache)}; // last up
}
template <std::random_access_iterator iter_t>
constexpr void on_column_iterator_creation(iter_t host_iter) noexcept
{
// Cache the next diagonal value.
std::get<1>(matrix_base_t::cache) = std::get<0>(*host_iter);
}
template <std::random_access_iterator iter_t>
constexpr void before_column_iterator_increment(iter_t SEQAN3_DOXYGEN_ONLY(host_iter)) noexcept
{
// Update the last diagonal value.
std::get<0>(matrix_base_t::cache) = std::move(std::get<1>(matrix_base_t::cache));
}
template <std::random_access_iterator iter_t>
constexpr void after_column_iterator_increment(iter_t host_iter) noexcept
{
// Cache the next diagonal value.
std::get<1>(matrix_base_t::cache) = std::move(std::get<0>(*host_iter));
}
};
} // namespace seqan3::detail
std::addressof
T addressof(T... args)
alignment_matrix_column_major_range_base.hpp
Provides seqan3::detail::alignment_matrix_column_major_range_base.
alignment_score_matrix_one_column_base.hpp
Provides seqan3::detail::alignment_score_matrix_one_column_base.
alignment_score_matrix_proxy.hpp
Provides seqan3::detail::alignment_score_matrix_proxy.
iterator
concept.hpp
Provides concepts that do not have equivalents in C++20.
Hide me