tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
new_extractor.hpp
Go to the documentation of this file.
1#ifndef TATAMI_NEW_EXTRACTOR_HPP
2#define TATAMI_NEW_EXTRACTOR_HPP
3
4#include "../base/Matrix.hpp"
5
11namespace tatami {
12
19template<bool oracle_, typename Index_>
20using MaybeOracle = typename std::conditional<oracle_, std::shared_ptr<const Oracle<Index_> >, bool>::type;
21
41template<bool sparse_, bool oracle_, typename Value_, typename Index_, typename ... Args_>
43 // We could use 'sparse()' and 'dense()' directly here, but that assumes
44 // that 'opt' is always supplied at the end of 'args', which might not be
45 // the case... so we just spell it out and save ourselves the trouble
46 // of implementing default option methods for 'sparse()' and 'dense()'.
47 if constexpr(sparse_) {
48 if constexpr(oracle_) {
49 if (row) {
50 return ptr->sparse_row(std::move(oracle), std::forward<Args_>(args)...);
51 } else {
52 return ptr->sparse_column(std::move(oracle), std::forward<Args_>(args)...);
53 }
54 } else {
55 if (row) {
56 return ptr->sparse_row(std::forward<Args_>(args)...);
57 } else {
58 return ptr->sparse_column(std::forward<Args_>(args)...);
59 }
60 }
61 } else {
62 if constexpr(oracle_) {
63 if (row) {
64 return ptr->dense_row(std::move(oracle), std::forward<Args_>(args)...);
65 } else {
66 return ptr->dense_column(std::move(oracle), std::forward<Args_>(args)...);
67 }
68 } else {
69 if (row) {
70 return ptr->dense_row(std::forward<Args_>(args)...);
71 } else {
72 return ptr->dense_column(std::forward<Args_>(args)...);
73 }
74 }
75 }
76}
77
81// Provided for back-compatibility only.
82template<bool row_, bool sparse_, typename Value_, typename Index_>
83auto new_extractor(const Matrix<Value_, Index_>* ptr) {
85}
86
87template<bool row_, bool sparse_, typename Value_, typename Index_>
88auto new_extractor(const Matrix<Value_, Index_>* ptr, const Options& opt) {
90}
91
92template<bool row_, bool sparse_, typename Value_, typename Index_, typename ... Args_>
93auto new_extractor(const Matrix<Value_, Index_>* ptr, Index_ start, Index_ len, Args_&&... args) {
94 return new_extractor<sparse_, false, Value_, Index_>(ptr, row_, false, start, len, std::forward<Args_>(args)...);
95}
96
97template<bool row_, bool sparse_, typename Value_, typename Index_, typename ... Args_>
98auto new_extractor(const Matrix<Value_, Index_>* ptr, std::vector<Index_> i, Args_&&... args) {
99 return new_extractor<sparse_, false, Value_, Index_>(ptr, row_, false, std::move(i), std::forward<Args_>(args)...);
100}
105}
106
107#endif
Virtual class for a matrix.
Definition Matrix.hpp:59
Flexible representations for matrix data.
Definition Extractor.hpp:15
typename std::conditional< oracle_, std::shared_ptr< const Oracle< Index_ > >, bool >::type MaybeOracle
Definition new_extractor.hpp:20
auto new_extractor(const Matrix< Value_, Index_ > *ptr, bool row, MaybeOracle< oracle_, Index_ > oracle, Args_ &&... args)
Definition new_extractor.hpp:42
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35