tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
FixedOracle.hpp
Go to the documentation of this file.
1#ifndef TATAMI_FIXED_ORACLE_HPP
2#define TATAMI_FIXED_ORACLE_HPP
3
4#include "../base/Oracle.hpp"
5#include <numeric>
6
13namespace tatami {
14
20template<typename Index_>
21class FixedViewOracle : public Oracle<Index_> {
22public:
28 FixedViewOracle(const Index_* ptr, size_t number) : my_reference(ptr), my_length(number) {}
29
30 size_t total() const {
31 return my_length;
32 }
33
34 Index_ get(size_t i) const {
35 return my_reference[i];
36 }
37
38private:
39 const Index_* my_reference;
40 size_t my_length;
41};
42
48template<typename Index_>
49class FixedVectorOracle : public Oracle<Index_> {
50public:
54 FixedVectorOracle(std::vector<Index_> vector) : my_sequence(std::move(vector)) {}
55
56 size_t total() const {
57 return my_sequence.size();
58 }
59
60 Index_ get(size_t i) const {
61 return my_sequence[i];
62 }
63
64private:
65 std::vector<Index_> my_sequence;
66};
67
68}
69
70#endif
Predict future accesses from a vector containing a fixed sequence.
Definition FixedOracle.hpp:49
FixedVectorOracle(std::vector< Index_ > vector)
Definition FixedOracle.hpp:54
Index_ get(size_t i) const
Definition FixedOracle.hpp:60
size_t total() const
Definition FixedOracle.hpp:56
Predict future accesses from a view on a fixed sequence.
Definition FixedOracle.hpp:21
Index_ get(size_t i) const
Definition FixedOracle.hpp:34
FixedViewOracle(const Index_ *ptr, size_t number)
Definition FixedOracle.hpp:28
size_t total() const
Definition FixedOracle.hpp:30
Predict future access requests on the target dimension.
Definition Oracle.hpp:21
Flexible representations for matrix data.
Definition Extractor.hpp:15
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35