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 {
41 m.cols()
42 } -> std::same_as<typename std::remove_cvref_t<matrix_t>::size_type>;
43
44 {
45 m.rows()
46 } -> std::same_as<typename std::remove_cvref_t<matrix_t>::size_type>;
47
48 {
49 m.at(matrix_coordinate{})
50 } -> std::same_as<typename std::remove_cvref_t<matrix_t>::reference>;
51 };
53
54// Workaround for https://github.com/doxygen/doxygen/issues/9379
55#if SEQAN3_DOXYGEN_ONLY(1) 0
56template <typename matrix_t>
57class matrix
58{};
59#endif
60
87
99template <matrix matrix1_t, matrix matrix2_t>
100 requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
101inline bool operator==(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
102{
103 if (lhs.rows() != rhs.rows())
104 return false;
105
106 if (lhs.cols() != rhs.cols())
107 return false;
108
109 for (size_t row = 0u; row < lhs.rows(); ++row)
110 for (size_t col = 0u; col < lhs.cols(); ++col)
111 if (matrix_coordinate co{row_index_type{row}, column_index_type{col}}; lhs.at(co) != rhs.at(co))
112 return false;
113
114 return true;
115}
116
123template <matrix matrix1_t, matrix matrix2_t>
124 requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
125inline bool operator!=(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
126{
127 return !(lhs == rhs);
128}
130
131} // 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