SeqAn3
The Modern C++ library for sequence analysis.
row_wise_matrix.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 <vector>
16 #include <seqan3/core/platform.hpp>
17 
18 namespace seqan3::detail
19 {
20 
32 template <typename entry_t>
33 class row_wise_matrix
34 {
35 public:
37  using entry_type = entry_t;
38 
42  row_wise_matrix() = default;
43  row_wise_matrix(row_wise_matrix const &) = default;
44  row_wise_matrix(row_wise_matrix &&) = default;
45  row_wise_matrix & operator=(row_wise_matrix const &) = default;
46  row_wise_matrix & operator=(row_wise_matrix &&) = default;
47  ~row_wise_matrix() = default;
48 
54  row_wise_matrix(std::vector<entry_type> entries, size_t const rows, size_t const cols)
55  : _entries{std::move(entries)}, _rows{rows}, _cols{cols}
56  {}
58 
60  size_t rows() const noexcept
61  {
62  return _rows;
63  }
64 
66  size_t cols() const noexcept
67  {
68  return _cols;
69  }
70 
72  entry_type at(size_t const row, size_t const col) const noexcept
73  {
74  assert(row < rows() && col < cols());
75  return _entries[row * cols() + col];
76  }
77 
78 private:
81  std::vector<entry_type> _entries;
82 
84  size_t _rows;
85 
87  size_t _cols;
88 };
89 
90 } // namespace seqan3::detail
Provides platform and dependency checks.
Definition: aligned_sequence_concept.hpp:35