SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
matrix_concept.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
12#include <concepts>
13#include <cstddef>
14#include <limits>
15
17
18namespace seqan3::detail
19{
20
23template <typename score_type>
24constexpr score_type matrix_inf = std::numeric_limits<score_type>::max();
25
32template <typename matrix_t>
33concept matrix = requires (std::remove_cvref_t<matrix_t> m) {
35
37
39
40 { m.cols() } -> std::same_as<typename std::remove_cvref_t<matrix_t>::size_type>;
41
42 { m.rows() } -> std::same_as<typename std::remove_cvref_t<matrix_t>::size_type>;
43
44 { m.at(matrix_coordinate{}) } -> std::same_as<typename std::remove_cvref_t<matrix_t>::reference>;
45};
47
48// Workaround for https://github.com/doxygen/doxygen/issues/9379
49#if SEQAN3_DOXYGEN_ONLY(1) 0
50template <typename matrix_t>
51class matrix
52{};
53#endif
54
81
93template <matrix matrix1_t, matrix matrix2_t>
94 requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
95inline bool operator==(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
96{
97 if (lhs.rows() != rhs.rows())
98 return false;
99
100 if (lhs.cols() != rhs.cols())
101 return false;
102
103 for (size_t row = 0u; row < lhs.rows(); ++row)
104 for (size_t col = 0u; col < lhs.cols(); ++col)
105 if (matrix_coordinate co{row_index_type{row}, column_index_type{col}}; lhs.at(co) != rhs.at(co))
106 return false;
107
108 return true;
109}
110
117template <matrix matrix1_t, matrix matrix2_t>
118 requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
119inline bool operator!=(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
120{
121 return !(lhs == rhs);
122}
124
125} // namespace seqan3::detail
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
T max(T... args)
T operator!=(T... args)
Hide me