SeqAn3 3.2.0
The Modern C++ library for sequence analysis.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
matrix_concept.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
13#pragma once
14
15#include <concepts>
16#include <cstddef>
17#include <limits>
18
20
21namespace seqan3::detail
22{
23
26template <typename score_type>
27constexpr score_type matrix_inf = std::numeric_limits<score_type>::max();
28
40template <typename matrix_t>
41concept matrix = requires (std::remove_cvref_t<matrix_t> m) {
43
56
61 {
62 m.cols()
63 } -> std::same_as<typename std::remove_cvref_t<matrix_t>::size_type>;
65
70 {
71 m.rows()
72 } -> std::same_as<typename std::remove_cvref_t<matrix_t>::size_type>;
74
79 {
80 m.at(matrix_coordinate{})
81 } -> std::same_as<typename std::remove_cvref_t<matrix_t>::reference>;
83
85 };
88
100template <matrix matrix1_t, matrix matrix2_t>
101 requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
102inline bool operator==(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
103{
104 if (lhs.rows() != rhs.rows())
105 return false;
106
107 if (lhs.cols() != rhs.cols())
108 return false;
109
110 for (size_t row = 0u; row < lhs.rows(); ++row)
111 for (size_t col = 0u; col < lhs.cols(); ++col)
112 if (matrix_coordinate co{row_index_type{row}, column_index_type{col}}; lhs.at(co) != rhs.at(co))
113 return false;
114
115 return true;
116}
117
124template <matrix matrix1_t, matrix matrix2_t>
125 requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
126inline bool operator!=(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
127{
128 return !(lhs == rhs);
129}
131
132} // namespace seqan3::detail
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
T max(T... args)
T operator!=(T... args)