SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
matrix_concept.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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 
21 namespace seqan3::detail
22 {
23 
26 template <typename score_type>
27 constexpr score_type matrix_inf = std::numeric_limits<score_type>::max();
28 
39 template <typename matrix_t>
41 SEQAN3_CONCEPT matrix = requires(std::remove_cvref_t<matrix_t> m)
42 {
44 
57 
64 
71 
75  SEQAN3_RETURN_TYPE_CONSTRAINT(m.at(matrix_coordinate{}),
77  std::same_as, typename std::remove_cvref_t<matrix_t>::reference);
79 
81 };
84 
96 template <matrix matrix1_t, matrix matrix2_t>
98  requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
100 inline 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 
122 template <matrix matrix1_t, matrix matrix2_t>
124  requires std::equality_comparable_with<typename matrix1_t::reference, typename matrix2_t::reference>
126 inline bool operator!=(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
127 {
128  return !(lhs == rhs);
129 }
131 
132 } // namespace seqan3::detail
matrix_coordinate.hpp
Provides seqan3::detail::alignment_coordinate and associated strong types.
std::rel_ops::operator!=
T operator!=(T... args)
concepts
The Concepts library.
cstddef
SEQAN3_RETURN_TYPE_CONSTRAINT
#define SEQAN3_RETURN_TYPE_CONSTRAINT(expression, concept_name,...)
Same as writing {expression} -> concept_name<type1[, ...]> in a concept definition.
Definition: platform.hpp:57
limits
std::remove_cvref_t
std::numeric_limits::max
T max(T... args)