SeqAn3 3.1.0
The Modern C++ library for sequence analysis.
matrix_concept.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, 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 <cstddef>
16#include <limits>
17
19#include <seqan3/std/concepts>
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>
41SEQAN3_CONCEPT matrix = requires(std::remove_cvref_t<matrix_t> m)
42{
44
57
64
71
76 SEQAN3_RETURN_TYPE_CONSTRAINT(m.at(matrix_coordinate{}),
77 std::same_as, typename std::remove_cvref_t<matrix_t>::reference);
79
81};
84
96template <matrix matrix1_t, matrix matrix2_t>
98 requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
100inline bool operator==(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
101{
102 if (lhs.rows() != rhs.rows())
103 return false;
104
105 if (lhs.cols() != rhs.cols())
106 return false;
107
108 for (size_t row = 0u; row < lhs.rows(); ++row)
109 for (size_t col = 0u; col < lhs.cols(); ++col)
110 if (matrix_coordinate co{row_index_type{row}, column_index_type{col}}; lhs.at(co) != rhs.at(co))
111 return false;
112
113 return true;
114}
115
122template <matrix matrix1_t, matrix matrix2_t>
124 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
The <concepts> header from C++20's standard library.
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
T max(T... args)
T operator!=(T... args)
#define SEQAN3_RETURN_TYPE_CONSTRAINT(expression, concept_name,...)
Same as writing {expression} -> concept_name<type1[, ...]> in a concept definition.
Definition: platform.hpp:57