tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
make_Extractor.hpp
Go to the documentation of this file.
1#ifndef TATAMI_NEW_EXTRACTOR_HPP
2#define TATAMI_NEW_EXTRACTOR_HPP
3
4#include <memory>
5#include <type_traits>
6
7#include "../base/Matrix.hpp"
8
14namespace tatami {
15
22template<bool oracle_, typename Index_>
23using MaybeOracle = typename std::conditional<oracle_, std::shared_ptr<const Oracle<Index_> >, bool>::type;
24
28template<bool sparse_, bool oracle_, typename Value_, typename Index_, typename ... Args_>
29std::unique_ptr<Extractor<sparse_, oracle_, Value_, Index_> > make_Extractor_base(
30 const Matrix<Value_, Index_>& matrix,
31 const bool row, MaybeOracle<oracle_, Index_> oracle,
32 Args_&&... args
33) {
34 if constexpr(sparse_) {
35 if constexpr(oracle_) {
36 return matrix.sparse(row, std::move(oracle), std::forward<Args_>(args)...);
37 } else {
38 return matrix.sparse(row, std::forward<Args_>(args)...);
39 }
40 } else {
41 if constexpr(oracle_) {
42 return matrix.dense(row, std::move(oracle), std::forward<Args_>(args)...);
43 } else {
44 return matrix.dense(row, std::forward<Args_>(args)...);
45 }
46 }
47}
68template<bool sparse_, bool oracle_, typename Value_, typename Index_>
69std::unique_ptr<Extractor<sparse_, oracle_, Value_, Index_> > make_Extractor(
70 const Matrix<Value_, Index_>& matrix,
71 const bool row,
73 const tatami::Options& opt
74) {
75 return make_Extractor_base<sparse_, oracle_>(matrix, row, std::move(oracle), opt);
76}
77
94template<bool sparse_, bool oracle_, typename Value_, typename Index_>
95std::unique_ptr<Extractor<sparse_, oracle_, Value_, Index_> > make_Extractor(
96 const Matrix<Value_, Index_>& matrix,
97 const bool row,
99 Index_ block_start,
100 Index_ block_length,
101 const tatami::Options& opt
102) {
103 return make_Extractor_base<sparse_, oracle_>(matrix, row, std::move(oracle), block_start, block_length, opt);
104}
105
122template<bool sparse_, bool oracle_, typename Value_, typename Index_>
123std::unique_ptr<Extractor<sparse_, oracle_, Value_, Index_> > make_Extractor(
124 const Matrix<Value_, Index_>& matrix,
125 const bool row,
127 VectorPtr<Index_> indices_ptr,
128 const tatami::Options& opt
129) {
130 return make_Extractor_base<sparse_, oracle_>(matrix, row, std::move(oracle), std::move(indices_ptr), opt);
131}
132
136template<bool sparse_, bool oracle_, typename Value_, typename Index_, typename ... Args_>
137[[deprecated("use 'make_Extractor()' instead")]]
138auto new_extractor(const Matrix<Value_, Index_>& matrix, const bool row, MaybeOracle<oracle_, Index_> oracle, Args_&&... args) {
139 return make_Extractor(matrix, row, std::move(oracle), std::forward<Args_>(args)...);
140}
141
142template<bool sparse_, bool oracle_, typename Value_, typename Index_, typename ... Args_>
143[[deprecated("use 'make_Extractor()' instead")]]
144auto new_extractor(const Matrix<Value_, Index_>* ptr, bool row, tatami::MaybeOracle<oracle_, Index_> oracle, Args_&&... args) {
145 return new_extractor<sparse_, oracle_, Value_, Index_>(*ptr, row, std::move(oracle), std::forward<Args_>(args)...);
146}
151}
152
153#endif
Virtual class for a matrix of some numeric type.
Virtual class for a matrix.
Definition Matrix.hpp:59
virtual std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > dense(bool row, const Options &opt) const =0
virtual std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > sparse(bool row, const Options &opt) const =0
Flexible representations for matrix data.
Definition Extractor.hpp:15
std::shared_ptr< const std::vector< Index_ > > VectorPtr
Definition Matrix.hpp:26
typename std::conditional< oracle_, std::shared_ptr< const Oracle< Index_ > >, bool >::type MaybeOracle
Definition make_Extractor.hpp:23
std::unique_ptr< Extractor< sparse_, oracle_, Value_, Index_ > > make_Extractor(const Matrix< Value_, Index_ > &matrix, const bool row, MaybeOracle< oracle_, Index_ > oracle, const tatami::Options &opt)
Definition make_Extractor.hpp:69
Options for accessing data from a Matrix instance.
Definition Options.hpp:30