SeqAn3
The Modern C++ library for sequence analysis.
matrix_concept.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, 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 
18 #include <seqan3/std/concepts>
19 
20 namespace seqan3::detail
21 {
22 
25 template <typename score_type>
26 constexpr score_type matrix_inf = std::numeric_limits<score_type>::max();
27 
38 template <typename matrix_t>
40 SEQAN3_CONCEPT Matrix = requires(matrix_t m)
41 {
43 
48 
52  { m.cols() } -> size_t;
53 
57  { m.rows() } -> size_t;
58 
62  { m.at(size_t{0u}, size_t{0u}) } -> typename std::remove_reference_t<matrix_t>::entry_type;
64 };
67 
79 template <Matrix matrix1_t, Matrix matrix2_t>
83 inline bool operator==(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
84 {
85  if (lhs.rows() != rhs.rows())
86  return false;
87 
88  if (lhs.cols() != rhs.cols())
89  return false;
90 
91  for (size_t row = 0u; row < lhs.rows(); ++row)
92  for (size_t col = 0u; col < lhs.cols(); ++col)
93  if (lhs.at(row, col) != rhs.at(row, col))
94  return false;
95 
96  return true;
97 }
98 
105 template <Matrix matrix1_t, Matrix matrix2_t>
109 inline bool operator!=(matrix1_t const & lhs, matrix2_t const & rhs) noexcept
110 {
111  return !(lhs == rhs);
112 }
114 
115 } // namespace seqan3::detail
T operator!=(T... args)
The Concepts library.
T max(T... args)
Definition: aligned_sequence_concept.hpp:35
Requires std::detail::WeaklyEqualityComparableWitht<t1,t2>, but also that t1 and t2, as well as their common_reference_t satisfy std::EqualityComparable.