SeqAn3  3.0.1
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(remove_cvref_t<matrix_t> m)
42 {
44 
48  typename remove_cvref_t<matrix_t>::value_type;
52  typename remove_cvref_t<matrix_t>::reference;
56  typename remove_cvref_t<matrix_t>::size_type;
57 
61  { m.cols() } -> typename remove_cvref_t<matrix_t>::size_type;
62 
66  { m.rows() } -> typename remove_cvref_t<matrix_t>::size_type;
67 
71  { m.at(matrix_coordinate{}) } -> typename remove_cvref_t<matrix_t>::reference;
72 
74 };
77 
89 template <matrix matrix1_t, matrix matrix2_t>
93 inline bool operator==(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
94 {
95  if (lhs.rows() != rhs.rows())
96  return false;
97 
98  if (lhs.cols() != rhs.cols())
99  return false;
100 
101  for (size_t row = 0u; row < lhs.rows(); ++row)
102  for (size_t col = 0u; col < lhs.cols(); ++col)
103  if (matrix_coordinate co{row_index_type{row}, column_index_type{col}}; lhs.at(co) != rhs.at(co))
104  return false;
105 
106  return true;
107 }
108 
115 template <matrix matrix1_t, matrix matrix2_t>
119 inline bool operator!=(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
120 {
121  return !(lhs == rhs);
122 }
124 
125 } // 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
limits
equality_comparable_with
Requires seqan3::detail::weakly_equality_comparable_witht<t1,t2>, but also that t1 and t2,...
std::numeric_limits::max
T max(T... args)