Loading...
Searching...
No Matches
matrix_concept.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 <concepts>
#include <cstddef>
#include <limits>
#include <seqan3/alignment/matrix/detail/matrix_coordinate.hpp>
namespace seqan3::detail
{
template <typename score_type>
constexpr score_type matrix_inf = std::numeric_limits<score_type>::max();
template <typename matrix_t>
concept matrix = requires (std::remove_cvref_t<matrix_t> m) {
typename std::remove_cvref_t<matrix_t>::value_type;
typename std::remove_cvref_t<matrix_t>::reference;
typename std::remove_cvref_t<matrix_t>::size_type;
{ m.cols() } -> std::same_as<typename std::remove_cvref_t<matrix_t>::size_type>;
{ m.rows() } -> std::same_as<typename std::remove_cvref_t<matrix_t>::size_type>;
{ m.at(matrix_coordinate{}) } -> std::same_as<typename std::remove_cvref_t<matrix_t>::reference>;
};
// Workaround for https://github.com/doxygen/doxygen/issues/9379
#if SEQAN3_DOXYGEN_ONLY(1) 0
template <typename matrix_t>
class matrix
{};
#endif
template <matrix matrix1_t, matrix matrix2_t>
requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
inline bool operator==(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
{
if (lhs.rows() != rhs.rows())
return false;
if (lhs.cols() != rhs.cols())
return false;
for (size_t row = 0u; row < lhs.rows(); ++row)
for (size_t col = 0u; col < lhs.cols(); ++col)
if (matrix_coordinate co{row_index_type{row}, column_index_type{col}}; lhs.at(co) != rhs.at(co))
return false;
return true;
}
template <matrix matrix1_t, matrix matrix2_t>
requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
inline bool operator!=(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
{
return !(lhs == rhs);
}
} // namespace seqan3::detail
cstddef
limits
matrix_coordinate.hpp
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
std::numeric_limits::max
T max(T... args)
Hide me