tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
DelayedSubset.hpp
Go to the documentation of this file.
1#ifndef TATAMI_DELAYED_SUBSET_HPP
2#define TATAMI_DELAYED_SUBSET_HPP
3
4#include "utils.hpp"
5#include <algorithm>
6#include <memory>
7#include <cstddef>
8
17namespace tatami {
18
22namespace DelayedSubset_internal {
23
24template<typename Index_>
25struct DenseParallelResults {
26 std::vector<Index_> collapsed;
27 std::vector<Index_> reindex;
28};
29
30template<typename Index_, class SubsetStorage_, class ToIndex_>
31DenseParallelResults<Index_> format_dense_parallel_base(const SubsetStorage_& subset, Index_ len, ToIndex_ to_index) {
32 std::vector<std::pair<Index_, Index_> > collected;
33 collected.reserve(len);
34 for (Index_ i = 0; i < len; ++i) {
35 collected.emplace_back(subset[to_index(i)], i);
36 }
37 std::sort(collected.begin(), collected.end());
38
39 DenseParallelResults<Index_> output;
40 if (collected.size()) {
41 output.collapsed.reserve(len);
42 output.reindex.resize(len);
43
44 Index_ last = collected.front().first;
45 output.collapsed.push_back(last);
46 output.reindex[collected.front().second] = 0;
47
48 Index_ counter = 0;
49 for (Index_ i = 1; i < len; ++i) {
50 const auto& pp = collected[i];
51 if (pp.first != last) {
52 last = pp.first;
53 output.collapsed.push_back(last);
54 ++counter;
55 }
56 output.reindex[pp.second] = counter;
57 }
58 }
59
60 return output;
61}
62
63template<bool oracle_, typename Value_, typename Index_>
64class ParallelDense final : public DenseExtractor<oracle_, Value_, Index_> {
65public:
66 template<class SubsetStorage_>
67 ParallelDense(const Matrix<Value_, Index_>* matrix, const SubsetStorage_& subset, bool row, MaybeOracle<oracle_, Index_> oracle, const Options& opt) {
68 auto processed = format_dense_parallel_base<Index_>(subset, subset.size(), [&](Index_ i) -> Index_ { return i; });
69 initialize(matrix, std::move(processed), row, std::move(oracle), opt);
70 }
71
72 template<class SubsetStorage_>
73 ParallelDense(const Matrix<Value_, Index_>* matrix, const SubsetStorage_& subset, bool row, MaybeOracle<oracle_, Index_> oracle, Index_ block_start, Index_ block_length, const Options& opt) {
74 auto processed = format_dense_parallel_base<Index_>(subset, block_length, [&](Index_ i) -> Index_ { return i + block_start; });
75 initialize(matrix, std::move(processed), row, std::move(oracle), opt);
76 }
77
78 template<class SubsetStorage_>
79 ParallelDense(const Matrix<Value_, Index_>* matrix, const SubsetStorage_& subset, bool row, MaybeOracle<oracle_, Index_> oracle, VectorPtr<Index_> indices_ptr, const Options& opt) {
80 const auto& indices = *indices_ptr;
81 auto processed = format_dense_parallel_base<Index_>(subset, indices.size(), [&](Index_ i) -> Index_ { return indices[i]; });
82 initialize(matrix, std::move(processed), row, std::move(oracle), opt);
83 }
84
85private:
86 void initialize(const Matrix<Value_, Index_>* matrix, DenseParallelResults<Index_> processed, bool row, MaybeOracle<oracle_, Index_> oracle, const Options& opt) {
87 my_holding_vbuffer.resize(processed.collapsed.size());
88 my_ext = new_extractor<false, oracle_>(matrix, row, std::move(oracle), std::move(processed.collapsed), opt);
89 my_reindex.swap(processed.reindex);
90 }
91
92public:
93 const Value_* fetch(Index_ i, Value_* buffer) {
94 auto src = my_ext->fetch(i, my_holding_vbuffer.data());
95
96 // 'src' and 'buffer' should not point to the same array.
97 auto copy = buffer;
98 for (auto p : my_reindex) {
99 *copy= src[p];
100 ++copy;
101 }
102
103 return buffer;
104 }
105
106private:
107 std::unique_ptr<DenseExtractor<oracle_, Value_, Index_> > my_ext;
108 std::vector<Value_> my_holding_vbuffer;
109 std::vector<Index_> my_reindex;
110};
111
112template<typename Index_>
113struct SparseParallelReindex {
114 // This is a bit complicated to explain.
115 // Let 'x = pool_ptrs[i - offset]'.
116 // Let 'y = pool_ptrs[i - offset + 1]'.
117 // Let 'z' denote any integer in '[x, y)'.
118 // In which case, 'indices[pool_indices[z]]' is equal to 'i'.
119 // The general idea is that 'pool_indices[z]' can be used to fill the 'SparseRange::index' on output.
120 std::vector<Index_> pool_ptrs;
121 std::vector<Index_> pool_indices;
122 Index_ offset;
123};
124
125template<typename Index_>
126struct SparseParallelResults {
127 std::vector<Index_> collapsed;
128 SparseParallelReindex<Index_> reindex;
129};
130
131template<typename Index_, class SubsetStorage_, class ToIndex_>
132SparseParallelResults<Index_> format_sparse_parallel_base(const SubsetStorage_& indices, Index_ len, ToIndex_ to_index) {
133 std::vector<std::pair<Index_, Index_> > collected;
134 collected.reserve(len);
135 for (Index_ i = 0; i < len; ++i) {
136 auto curdex = to_index(i);
137 collected.emplace_back(indices[curdex], curdex);
138 }
139 std::sort(collected.begin(), collected.end());
140
141 SparseParallelResults<Index_> output;
142
143 if (collected.size()) {
144 output.collapsed.reserve(len);
145 output.reindex.pool_indices.reserve(len);
146 Index_ first = collected.front().first;
147
148 // 'pool_ptrs' is a vector that enables look-up according to the
149 // indices of the underlying array. to avoid the need to allocate a
150 // vector of length equal to the underlying array's dimension, we only
151 // consider the extremes of 'indices'; we allocate 'pool_ptrs' to have
152 // length equal to the range of 'indices' (plus 1, as we're storing
153 // cumulative pointers). 'offset' defines the lower bound that must be
154 // subtracted from the array indices to get an index into 'pool_ptrs'.
155 output.reindex.offset = first;
156 auto allocation = collected.back().first - output.reindex.offset + 1;
157 output.reindex.pool_ptrs.resize(allocation + 1);
158
159 Index_ counter = 0;
160 output.reindex.pool_ptrs[counter] = 0;
161 ++counter;
162 output.reindex.pool_indices.push_back(collected.front().second);
163 output.reindex.pool_ptrs[counter] = 1;
164 output.collapsed.push_back(first);
165 auto last = first;
166
167 for (Index_ i = 1; i < len; ++i) {
168 const auto& pp = collected[i];
169 auto current = pp.first;
170 if (current == last) {
171 output.reindex.pool_indices.push_back(pp.second);
172 ++(output.reindex.pool_ptrs[counter]);
173 continue;
174 }
175
176 Index_ pool_size = output.reindex.pool_indices.size();
177 counter = current - output.reindex.offset;
178 output.reindex.pool_ptrs[counter] = pool_size; // any overwrite is safe as the value is unchanged.
179 ++counter;
180 output.reindex.pool_indices.push_back(pp.second);
181 output.reindex.pool_ptrs[counter] = pool_size + 1;
182 output.collapsed.push_back(current);
183 last = current;
184 }
185 }
186
187 return output;
188}
189
190template<bool oracle_, typename Value_, typename Index_>
191class ParallelSparse final : public SparseExtractor<oracle_, Value_, Index_> {
192public:
193 template<class SubsetStorage_>
194 ParallelSparse(const Matrix<Value_, Index_>* mat, const SubsetStorage_& subset, bool row, MaybeOracle<oracle_, Index_> oracle, const Options& opt) {
195 auto processed = format_sparse_parallel_base<Index_>(subset, subset.size(), [](Index_ i) -> Index_ { return i; });
196 initialize(mat, std::move(processed), subset.size(), row, std::move(oracle), opt);
197 }
198
199 template<class SubsetStorage_>
200 ParallelSparse(const Matrix<Value_, Index_>* mat, const SubsetStorage_& subset, bool row, MaybeOracle<oracle_, Index_> oracle, Index_ block_start, Index_ block_length, const Options& opt) {
201 auto processed = format_sparse_parallel_base<Index_>(subset, block_length, [&](Index_ i) -> Index_ { return i + block_start; });
202 initialize(mat, std::move(processed), block_length, row, std::move(oracle), opt);
203 }
204
205 template<class SubsetStorage_>
206 ParallelSparse(const Matrix<Value_, Index_>* mat, const SubsetStorage_& subset, bool row, MaybeOracle<oracle_, Index_> oracle, VectorPtr<Index_> indices_ptr, const Options& opt) {
207 const auto& indices = *indices_ptr;
208 auto processed = format_sparse_parallel_base<Index_>(subset, indices.size(), [&](Index_ i) -> Index_ { return indices[i]; });
209 initialize(mat, std::move(processed), indices.size(), row, std::move(oracle), opt);
210 }
211
212private:
213 void initialize(const Matrix<Value_, Index_>* mat, SparseParallelResults<Index_> processed, std::size_t extent, bool row, MaybeOracle<oracle_, Index_> oracle, Options opt) {
214 my_shift = extent - processed.collapsed.size();
215
216 my_needs_value = opt.sparse_extract_value;
217 my_needs_index = opt.sparse_extract_index;
218 my_needs_sort = opt.sparse_ordered_index;
219
220 if (my_needs_sort && my_needs_value) {
221 my_sortspace.reserve(extent);
222 }
223
224 // We need to extract indices for sorting and expansion purposes, even
225 // if they weren't actually requested.
226 opt.sparse_extract_index = true;
227 if (!my_needs_index) {
228 my_holding_ibuffer.resize(processed.collapsed.size());
229 }
230
231 my_ext = new_extractor<true, oracle_>(mat, row, std::move(oracle), std::move(processed.collapsed), opt);
232 my_reindex = std::move(processed.reindex);
233 }
234
235public:
236 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* ibuffer) {
237 auto vinit = (my_needs_value ? vbuffer + my_shift : NULL);
238 auto iinit = (my_needs_index ? ibuffer + my_shift : my_holding_ibuffer.data());
239 auto input = my_ext->fetch(i, vinit, iinit);
240
241 if (!my_needs_sort) {
242 // Pointers in 'input' and the two 'buffer' pointers may optionally point
243 // to overlapping arrays as long as each 'buffer' pointer precedes its
244 // corresponding pointer in 'input'. The idea is that the expansion of
245 // values into, e.g., 'vbuffer' will cause it to catch up to 'input.value'
246 // without clobbering any values in the latter. This assumes that
247 // 'input.value' has been shifted enough to make space for expansion; the
248 // required shift depends on the number of duplicates.
249 Index_ count = 0;
250 auto vcopy = vbuffer;
251 auto icopy = ibuffer;
252
253 auto vsrc = input.value;
254 bool replace_value = my_needs_value && vsrc != vcopy;
255
256 for (Index_ i = 0; i < input.number; ++i) {
257 auto lookup = input.index[i] - my_reindex.offset;
258 auto start = my_reindex.pool_ptrs[lookup];
259 auto num = my_reindex.pool_ptrs[lookup + 1] - start;
260 count += num;
261
262 if (replace_value) {
263 auto val = *vsrc; // make a copy just in case 'vcopy' and 'input.value' overlap.
264 std::fill_n(vcopy, num, val);
265 vcopy += num;
266 ++vsrc;
267 replace_value = (vcopy != vsrc); // if we've caught up, there no need to do this replacement.
268 }
269
270 if (my_needs_index) {
271 // Again, 'icopy' will eventually catch up to 'input.index' if
272 // they point to overlapping arrays. But we still need to
273 // replace values once we've managed to catch up, so we can't
274 // short-circuit like we did with 'replace_value'.
275 std::copy_n(my_reindex.pool_indices.begin() + start, num, icopy);
276 icopy += num;
277 }
278 }
279
280 input.number = count;
281 if (my_needs_value) {
282 input.value = vbuffer;
283 }
284 if (my_needs_index) {
285 input.index = ibuffer;
286 } else {
287 input.index = NULL;
288 }
289
290 } else if (my_needs_value) {
291 // This does not require any careful consideration of the overlaps
292 // between 'input' and 'buffers', as we're copying things into
293 // 'my_sortspace' anyway before copying them back into 'buffer'.
294 my_sortspace.clear();
295 for (Index_ i = 0; i < input.number; ++i) {
296 auto val = input.value[i];
297 auto lookup = input.index[i] - my_reindex.offset;
298 auto start = my_reindex.pool_ptrs[lookup];
299 auto end = my_reindex.pool_ptrs[lookup + 1];
300 for (Index_ j = start; j < end; ++j) {
301 my_sortspace.emplace_back(my_reindex.pool_indices[j], val);
302 }
303 }
304 std::sort(my_sortspace.begin(), my_sortspace.end());
305 input.number = my_sortspace.size();
306
307 auto vcopy = vbuffer;
308 for (const auto& ss : my_sortspace) {
309 *vcopy = ss.second;
310 ++vcopy;
311 }
312 input.value = vbuffer;
313
314 if (my_needs_index) {
315 auto icopy = ibuffer;
316 for (const auto& ss : my_sortspace) {
317 *icopy = ss.first;
318 ++icopy;
319 }
320 input.index = ibuffer;
321 } else {
322 input.index = NULL;
323 }
324
325 } else {
326 // Again, 'input.index' and 'ibuffer' may point to overlapping arrays,
327 // as long as the latter precedes the former; expansion into the latter
328 // will allow it to catch up to the former without clobbering, assuming
329 // that the latter was shifted back to provide enough space.
330 Index_ count = 0;
331 auto icopy = ibuffer;
332
333 for (Index_ i = 0; i < input.number; ++i) {
334 auto lookup = input.index[i] - my_reindex.offset;
335 auto start = my_reindex.pool_ptrs[lookup];
336 auto num = my_reindex.pool_ptrs[lookup + 1] - start;
337 count += num;
338
339 if (my_needs_index) {
340 std::copy_n(my_reindex.pool_indices.begin() + start, num, icopy);
341 icopy += num;
342 }
343 }
344
345 input.number = count;
346 if (my_needs_index) {
347 std::sort(ibuffer, ibuffer + count);
348 input.index = ibuffer;
349 } else {
350 input.index = NULL;
351 }
352 }
353
354 return input;
355 }
356
357private:
358 std::unique_ptr<SparseExtractor<oracle_, Value_, Index_> > my_ext;
359 bool my_needs_value, my_needs_index, my_needs_sort;
360 SparseParallelReindex<Index_> my_reindex;
361 std::vector<std::pair<Index_, Value_> > my_sortspace;
362 std::vector<Index_> my_holding_ibuffer;
363 std::size_t my_shift;
364};
365
366}
382template<typename Value_, typename Index_, class SubsetStorage_>
383class DelayedSubset final : public Matrix<Value_, Index_> {
384public:
392 DelayedSubset(std::shared_ptr<const Matrix<Value_, Index_> > matrix, SubsetStorage_ subset, bool by_row) :
393 my_matrix(std::move(matrix)), my_subset(std::move(subset)), my_by_row(by_row) {}
394
395private:
396 std::shared_ptr<const Matrix<Value_, Index_> > my_matrix;
397 SubsetStorage_ my_subset;
398 bool my_by_row;
399
400public:
401 Index_ nrow() const {
402 if (my_by_row) {
403 return my_subset.size();
404 } else {
405 return my_matrix->nrow();
406 }
407 }
408
409 Index_ ncol() const {
410 if (my_by_row) {
411 return my_matrix->ncol();
412 } else {
413 return my_subset.size();
414 }
415 }
416
417 bool is_sparse() const {
418 return my_matrix->is_sparse();
419 }
420
421 double is_sparse_proportion() const {
422 return my_matrix->is_sparse_proportion();
423 }
424
425 bool prefer_rows() const {
426 return my_matrix->prefer_rows();
427 }
428
429 double prefer_rows_proportion() const {
430 return my_matrix->prefer_rows_proportion();
431 }
432
433 bool uses_oracle(bool row) const {
434 return my_matrix->uses_oracle(row);
435 }
436
437 using Matrix<Value_, Index_>::dense;
438
439 using Matrix<Value_, Index_>::sparse;
440
441 /********************
442 *** Myopic dense ***
443 ********************/
444private:
445 template<typename ... Args_>
446 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > populate_myopic_dense(bool row, Args_&& ... args) const {
447 if (row == my_by_row) {
448 return std::make_unique<subset_utils::MyopicPerpendicularDense<Value_, Index_, SubsetStorage_> >(my_matrix.get(), my_subset, row, std::forward<Args_>(args)...);
449 } else {
450 return std::make_unique<DelayedSubset_internal::ParallelDense<false, Value_, Index_> >(my_matrix.get(), my_subset, row, false, std::forward<Args_>(args)...);
451 }
452 }
453
454public:
455 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(bool row, const Options& opt) const {
456 return populate_myopic_dense(row, opt);
457 }
458
459 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(bool row, Index_ block_start, Index_ block_length, const Options& opt) const {
460 return populate_myopic_dense(row, block_start, block_length, opt);
461 }
462
463 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(bool row, VectorPtr<Index_> my_subset_ptr, const Options& opt) const {
464 return populate_myopic_dense(row, std::move(my_subset_ptr), opt);
465 }
466
467 /*********************
468 *** Myopic sparse ***
469 *********************/
470private:
471 template<typename ... Args_>
472 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > populate_myopic_sparse(bool row, Args_&& ... args) const {
473 if (row == my_by_row) {
474 return std::make_unique<subset_utils::MyopicPerpendicularSparse<Value_, Index_, SubsetStorage_> >(my_matrix.get(), my_subset, row, std::forward<Args_>(args)...);
475 } else {
476 return std::make_unique<DelayedSubset_internal::ParallelSparse<false, Value_, Index_> >(my_matrix.get(), my_subset, row, false, std::forward<Args_>(args)...);
477 }
478 }
479
480public:
481 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(bool row, const Options& opt) const {
482 return populate_myopic_sparse(row, opt);
483 }
484
485 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(bool row, Index_ block_start, Index_ block_length, const Options& opt) const {
486 return populate_myopic_sparse(row, block_start, block_length, opt);
487 }
488
489 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(bool row, VectorPtr<Index_> my_subset_ptr, const Options& opt) const {
490 return populate_myopic_sparse(row, std::move(my_subset_ptr), opt);
491 }
492
493 /**********************
494 *** Oracular dense ***
495 **********************/
496private:
497 template<typename ... Args_>
498 std::unique_ptr<OracularDenseExtractor<Value_, Index_> > populate_oracular_dense(bool row, std::shared_ptr<const Oracle<Index_> > oracle, Args_&& ... args) const {
499 if (row == my_by_row) {
500 return std::make_unique<subset_utils::OracularPerpendicularDense<Value_, Index_> >(my_matrix.get(), my_subset, row, std::move(oracle), std::forward<Args_>(args)...);
501 } else {
502 return std::make_unique<DelayedSubset_internal::ParallelDense<true, Value_, Index_> >(my_matrix.get(), my_subset, row, std::move(oracle), std::forward<Args_>(args)...);
503 }
504 }
505
506public:
507 std::unique_ptr<OracularDenseExtractor<Value_, Index_> > dense(bool row, std::shared_ptr<const Oracle<Index_> > oracle, const Options& opt) const {
508 return populate_oracular_dense(row, std::move(oracle), opt);
509 }
510
511 std::unique_ptr<OracularDenseExtractor<Value_, Index_> > dense(bool row, std::shared_ptr<const Oracle<Index_> > oracle, Index_ block_start, Index_ block_length, const Options& opt) const {
512 return populate_oracular_dense(row, std::move(oracle), block_start, block_length, opt);
513 }
514
515 std::unique_ptr<OracularDenseExtractor<Value_, Index_> > dense(bool row, std::shared_ptr<const Oracle<Index_> > oracle, VectorPtr<Index_> my_subset_ptr, const Options& opt) const {
516 return populate_oracular_dense(row, std::move(oracle), std::move(my_subset_ptr), opt);
517 }
518
519 /***********************
520 *** Oracular sparse ***
521 ***********************/
522private:
523 template<typename ... Args_>
524 std::unique_ptr<OracularSparseExtractor<Value_, Index_> > populate_oracular_sparse(bool row, std::shared_ptr<const Oracle<Index_> > oracle, Args_&& ... args) const {
525 if (row == my_by_row) {
526 return std::make_unique<subset_utils::OracularPerpendicularSparse<Value_, Index_> >(my_matrix.get(), my_subset, row, std::move(oracle), std::forward<Args_>(args)...);
527 } else {
528 return std::make_unique<DelayedSubset_internal::ParallelSparse<true, Value_, Index_> >(my_matrix.get(), my_subset, row, std::move(oracle), std::forward<Args_>(args)...);
529 }
530 }
531
532public:
533 std::unique_ptr<OracularSparseExtractor<Value_, Index_> > sparse(bool row, std::shared_ptr<const Oracle<Index_> > oracle, const Options& opt) const {
534 return populate_oracular_sparse(row, std::move(oracle), opt);
535 }
536
537 std::unique_ptr<OracularSparseExtractor<Value_, Index_> > sparse(bool row, std::shared_ptr<const Oracle<Index_> > oracle, Index_ block_start, Index_ block_length, const Options& opt) const {
538 return populate_oracular_sparse(row, std::move(oracle), block_start, block_length, opt);
539 }
540
541 std::unique_ptr<OracularSparseExtractor<Value_, Index_> > sparse(bool row, std::shared_ptr<const Oracle<Index_> > oracle, VectorPtr<Index_> my_subset_ptr, const Options& opt) const {
542 return populate_oracular_sparse(row, std::move(oracle), std::move(my_subset_ptr), opt);
543 }
544};
545
546}
547
548#endif
Delayed subsetting of a matrix with general indices.
Definition DelayedSubset.hpp:383
bool uses_oracle(bool row) const
Definition DelayedSubset.hpp:433
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > my_subset_ptr, const Options &opt) const
Definition DelayedSubset.hpp:541
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > dense(bool row, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedSubset.hpp:459
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > sparse(bool row, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedSubset.hpp:485
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedSubset.hpp:533
Index_ ncol() const
Definition DelayedSubset.hpp:409
bool prefer_rows() const
Definition DelayedSubset.hpp:425
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedSubset.hpp:511
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > sparse(bool row, VectorPtr< Index_ > my_subset_ptr, const Options &opt) const
Definition DelayedSubset.hpp:489
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > sparse(bool row, const Options &opt) const
Definition DelayedSubset.hpp:481
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedSubset.hpp:507
DelayedSubset(std::shared_ptr< const Matrix< Value_, Index_ > > matrix, SubsetStorage_ subset, bool by_row)
Definition DelayedSubset.hpp:392
double prefer_rows_proportion() const
Definition DelayedSubset.hpp:429
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > my_subset_ptr, const Options &opt) const
Definition DelayedSubset.hpp:515
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > dense(bool row, const Options &opt) const
Definition DelayedSubset.hpp:455
Index_ nrow() const
Definition DelayedSubset.hpp:401
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedSubset.hpp:537
bool is_sparse() const
Definition DelayedSubset.hpp:417
double is_sparse_proportion() const
Definition DelayedSubset.hpp:421
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > dense(bool row, VectorPtr< Index_ > my_subset_ptr, const Options &opt) const
Definition DelayedSubset.hpp:463
Virtual class for a matrix.
Definition Matrix.hpp:59
Predict future access requests on the target dimension.
Definition Oracle.hpp:23
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_, OracularDenseExtractor< Value_, Index_ >, MyopicDenseExtractor< Value_, Index_ > >::type DenseExtractor
Definition Extractor.hpp:273
Options for accessing data from a Matrix instance.
Definition Options.hpp:30