1#ifndef TATAMI_FRAGMENTED_SPARSE_MATRIX_H
2#define TATAMI_FRAGMENTED_SPARSE_MATRIX_H
5#include "primary_extraction.hpp"
6#include "secondary_extraction.hpp"
27namespace FragmentedSparseMatrix_internal {
33template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
34class PrimaryMyopicFullDense :
public MyopicDenseExtractor<Value_, Index_> {
36 PrimaryMyopicFullDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary) :
37 my_values(values), my_indices(indices), my_secondary(secondary) {}
39 const Value_* fetch(Index_ i, Value_* buffer) {
40 const auto& curv = my_values[i];
41 const auto& curi = my_indices[i];
43 std::fill_n(buffer, my_secondary,
static_cast<Value_
>(0));
44 size_t end = curv.size();
45 for (
size_t x = 0; x < end; ++x) {
46 buffer[curi[x]] = curv[x];
52 const ValueVectorStorage_& my_values;
53 const IndexVectorStorage_& my_indices;
57template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
58class PrimaryMyopicFullSparse :
public MyopicSparseExtractor<Value_, Index_> {
60 PrimaryMyopicFullSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, [[maybe_unused]] Index_ secondary ,
const Options& opt) :
61 my_values(values), my_indices(indices), my_needs_value(opt.sparse_extract_value), my_needs_index(opt.sparse_extract_index) {}
63 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
64 const auto& curv = my_values[i];
65 const auto& curi = my_indices[i];
67 SparseRange<Value_, Index_> output(curv.size(), NULL, NULL);
69 output.value = sparse_utils::extract_primary_vector(curv,
static_cast<size_t>(0), curv.size(), vbuffer);
72 output.index = sparse_utils::extract_primary_vector(curi,
static_cast<size_t>(0), curi.size(), index_buffer);
78 const ValueVectorStorage_& my_values;
79 const IndexVectorStorage_& my_indices;
80 bool my_needs_value, my_needs_index;
87template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
88class PrimaryMyopicBlockDense :
public MyopicDenseExtractor<Value_, Index_> {
90 PrimaryMyopicBlockDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length) :
91 my_values(values), my_indices(indices), my_secondary(secondary), my_block_start(block_start), my_block_length(block_length) {}
93 const Value_* fetch(Index_ i, Value_* buffer) {
94 const auto& curi = my_indices[i];
95 const auto& curv = my_values[i];
97 auto iStart = curi.begin();
98 auto iEnd = curi.end();
99 sparse_utils::refine_primary_block_limits(iStart, iEnd, my_secondary, my_block_start, my_block_length);
100 size_t offset = (iStart - curi.begin());
101 size_t number = iEnd - iStart;
103 std::fill_n(buffer, my_block_length,
static_cast<Value_
>(0));
104 for (
size_t i = 0; i < number; ++i) {
105 auto cur_offset = offset + i;
106 buffer[curi[cur_offset] - my_block_start] = curv[cur_offset];
112 const ValueVectorStorage_& my_values;
113 const IndexVectorStorage_& my_indices;
115 Index_ my_block_start, my_block_length;
118template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
119class PrimaryMyopicBlockSparse :
public MyopicSparseExtractor<Value_, Index_> {
121 PrimaryMyopicBlockSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length,
const Options& opt) :
124 my_secondary(secondary),
125 my_block_start(block_start),
126 my_block_length(block_length),
127 my_needs_value(opt.sparse_extract_value),
128 my_needs_index(opt.sparse_extract_index)
131 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
132 const auto& curi = my_indices[i];
133 auto iStart = curi.begin();
134 auto iEnd = curi.end();
135 sparse_utils::refine_primary_block_limits(iStart, iEnd, my_secondary, my_block_start, my_block_length);
136 size_t offset = iStart - curi.begin();
137 size_t delta = iEnd - iStart;
139 SparseRange<Value_, Index_> output(delta, NULL, NULL);
140 if (my_needs_value) {
141 output.value = sparse_utils::extract_primary_vector(my_values[i], offset, delta, vbuffer);
143 if (my_needs_index) {
144 output.index = sparse_utils::extract_primary_vector(curi, offset, delta, index_buffer);
150 const ValueVectorStorage_& my_values;
151 const IndexVectorStorage_& my_indices;
153 Index_ my_block_start, my_block_length;
154 bool my_needs_value, my_needs_index;
161template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
162class PrimaryMyopicIndexDense :
public MyopicDenseExtractor<Value_, Index_> {
164 PrimaryMyopicIndexDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr) :
165 my_values(values), my_indices(indices), my_retriever(*indices_ptr, secondary), my_num_indices(indices_ptr->size()) {}
167 const Value_* fetch(Index_ i, Value_* buffer) {
168 const auto& curi = my_indices[i];
169 const auto& curv = my_values[i];
170 std::fill_n(buffer, my_num_indices,
static_cast<Value_
>(0));
171 my_retriever.populate(
174 [&](
size_t s,
size_t offset) ->
void {
175 buffer[s] = curv[offset];
182 const ValueVectorStorage_& my_values;
183 const IndexVectorStorage_& my_indices;
184 sparse_utils::RetrievePrimarySubsetDense<Index_> my_retriever;
185 size_t my_num_indices;
188template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
189class PrimaryMyopicIndexSparse :
public MyopicSparseExtractor<Value_, Index_> {
191 PrimaryMyopicIndexSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr,
const Options& opt) :
192 my_values(values), my_indices(indices), my_retriever(*indices_ptr, secondary), my_needs_value(opt.sparse_extract_value), my_needs_index(opt.sparse_extract_index) {}
194 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
195 const auto& curi = my_indices[i];
196 const auto& curv = my_values[i];
198 auto vcopy = vbuffer;
199 auto icopy = index_buffer;
201 my_retriever.populate(
204 [&](
size_t offset, Index_ ix) ->
void {
206 if (my_needs_value) {
207 *vcopy = curv[offset];
210 if (my_needs_index) {
217 return SparseRange<Value_, Index_>(count, my_needs_value ? vbuffer : NULL, my_needs_index ? index_buffer : NULL);
221 const ValueVectorStorage_& my_values;
222 const IndexVectorStorage_& my_indices;
223 sparse_utils::RetrievePrimarySubsetSparse<Index_> my_retriever;
224 bool my_needs_value, my_needs_index;
231template<
typename Index_,
class IndexVectorStorage_>
234 ServeIndices(
const IndexVectorStorage_& indices) : my_indices(indices) {}
237 const IndexVectorStorage_& my_indices;
240 typedef size_t pointer_type;
242 pointer_type start_offset(Index_)
const {
246 pointer_type end_offset(Index_ primary)
const {
247 return my_indices[primary].size();
250 auto raw(Index_ primary)
const {
251 return my_indices[primary].begin();
255template<
typename Index_,
class IndexVectorStorage_>
256auto make_ServeIndices(
const IndexVectorStorage_& i) {
257 return ServeIndices<Index_, IndexVectorStorage_>(i);
260template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
261class SecondaryMyopicFullDense :
public MyopicDenseExtractor<Value_, Index_> {
263 SecondaryMyopicFullDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary) :
264 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, indices.size()) {}
266 const Value_* fetch(Index_ i, Value_* buffer) {
267 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
270 [&](Index_ primary, Index_ index_primary,
size_t ptr) ->
void {
271 buffer[index_primary] = my_values[primary][ptr];
278 const ValueVectorStorage_& my_values;
279 sparse_utils::FullSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
282template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
283class SecondaryMyopicFullSparse :
public MyopicSparseExtractor<Value_, Index_> {
285 SecondaryMyopicFullSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary,
const Options& opt) :
286 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, indices.size()), my_needs_value(opt.sparse_extract_value), my_needs_index(opt.sparse_extract_index) {}
288 SparseRange<Value_, Index_> fetch(Index_ i, Value_* value_buffer, Index_* index_buffer) {
292 [&](Index_ primary, Index_,
size_t ptr) ->
void {
293 if (my_needs_value) {
294 value_buffer[count] = my_values[primary][ptr];
296 if (my_needs_index) {
297 index_buffer[count] = primary;
302 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
306 const ValueVectorStorage_& my_values;
307 sparse_utils::FullSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
308 bool my_needs_value, my_needs_index;
315template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
316class SecondaryMyopicBlockDense :
public MyopicDenseExtractor<Value_, Index_> {
318 SecondaryMyopicBlockDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length) :
319 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, block_start, block_length) {}
321 const Value_* fetch(Index_ i, Value_* buffer) {
322 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
325 [&](Index_ primary, Index_ index_primary,
size_t ptr) ->
void {
326 buffer[index_primary] = my_values[primary][ptr];
333 const ValueVectorStorage_& my_values;
334 sparse_utils::BlockSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
337template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
338class SecondaryMyopicBlockSparse :
public MyopicSparseExtractor<Value_, Index_> {
340 SecondaryMyopicBlockSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length,
const Options& opt) :
341 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, block_start, block_length), my_needs_value(opt.sparse_extract_value), my_needs_index(opt.sparse_extract_index) {}
343 SparseRange<Value_, Index_> fetch(Index_ i, Value_* value_buffer, Index_* index_buffer) {
347 [&](Index_ primary, Index_,
size_t ptr) ->
void {
348 if (my_needs_value) {
349 value_buffer[count] = my_values[primary][ptr];
351 if (my_needs_index) {
352 index_buffer[count] = primary;
357 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
361 const ValueVectorStorage_& my_values;
362 sparse_utils::BlockSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
363 bool my_needs_value, my_needs_index;
370template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
371class SecondaryMyopicIndexDense :
public MyopicDenseExtractor<Value_, Index_> {
373 SecondaryMyopicIndexDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr) :
374 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, std::move(indices_ptr)) {}
376 const Value_* fetch(Index_ i, Value_* buffer) {
377 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
380 [&](Index_ primary, Index_ index_primary,
size_t ptr) ->
void {
381 buffer[index_primary] = my_values[primary][ptr];
388 const ValueVectorStorage_& my_values;
389 sparse_utils::IndexSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
392template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
393class SecondaryMyopicIndexSparse :
public MyopicSparseExtractor<Value_, Index_> {
395 SecondaryMyopicIndexSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr,
const Options& opt) :
396 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, std::move(indices_ptr)), my_needs_value(opt.sparse_extract_value), my_needs_index(opt.sparse_extract_index) {}
398 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
402 [&](Index_ primary, Index_,
size_t ptr) ->
void {
403 if (my_needs_value) {
404 vbuffer[count] = my_values[primary][ptr];
406 if (my_needs_index) {
407 index_buffer[count] = primary;
412 return SparseRange<Value_, Index_>(count, my_needs_value ? vbuffer : NULL, my_needs_index ? index_buffer : NULL);
416 const ValueVectorStorage_& my_values;
417 sparse_utils::IndexSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
418 bool my_needs_value, my_needs_index;
450 class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
451 class IndexVectorStorage_ = std::vector<std::vector<Index_> >
468 FragmentedSparseMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices,
bool row_sparse,
bool check =
true) :
469 my_nrow(nrow), my_ncol(ncol), my_values(std::move(values)), my_indices(std::move(indices)), my_row_sparse(row_sparse)
472 if (my_values.size() != my_indices.size()) {
473 throw std::runtime_error(
"'values' and 'indices' should be of the same length");
477 if (my_indices.size() !=
static_cast<size_t>(my_nrow)) {
478 throw std::runtime_error(
"length of 'indices' should be equal to number of rows'");
481 if (my_indices.size() !=
static_cast<size_t>(my_ncol)) {
482 throw std::runtime_error(
"length of 'indices' should be equal to number of columns");
487 for (
size_t i = 0, end = my_indices.size(); i < end; ++i) {
488 const auto& curv = my_values[i];
489 const auto& curi = my_indices[i];
490 if (curv.size() != curi.size()) {
491 throw std::runtime_error(
"corresponding elements of 'values' and 'indices' should have the same length");
494 for (
auto x : curi) {
495 if (x < 0 || x >= max_index) {
496 throw std::runtime_error(
"'indices' should contain non-negative integers less than the number of " + (my_row_sparse ? std::string(
"columns") : std::string(
"rows")));
500 for (
size_t j = 1, jend = curi.size(); j < jend; ++j) {
501 if (curi[j] <= curi[j - 1]) {
502 throw std::runtime_error(
"my_indices should be strictly increasing within each element of 'indices'");
510 Index_ my_nrow, my_ncol;
511 ValueVectorStorage_ my_values;
512 IndexVectorStorage_ my_indices;
516 Index_
nrow()
const {
return my_nrow; }
518 Index_
ncol()
const {
return my_ncol; }
530 using Matrix<Value_, Index_>::dense;
532 using Matrix<Value_, Index_>::sparse;
535 Index_ secondary()
const {
547 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
bool row,
const Options&)
const {
548 if (my_row_sparse == row) {
549 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicFullDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
550 my_values, my_indices, secondary()
553 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicFullDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
554 my_values, my_indices, secondary()
559 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
bool row, Index_ block_start, Index_ block_end,
const Options&)
const {
560 if (my_row_sparse == row) {
561 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicBlockDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
562 my_values, my_indices, secondary(), block_start, block_end
565 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicBlockDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
566 my_values, my_indices, secondary(), block_start, block_end
571 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
bool row, VectorPtr<Index_> subset_ptr,
const Options&)
const {
572 if (my_row_sparse == row) {
573 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicIndexDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
574 my_values, my_indices, secondary(), std::move(subset_ptr)
577 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicIndexDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
578 my_values, my_indices, secondary(), std::move(subset_ptr)
587 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
bool row,
const Options& opt)
const {
588 if (my_row_sparse == row) {
589 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicFullSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
590 my_values, my_indices, secondary(), opt
593 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicFullSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
594 my_values, my_indices, secondary(), opt
599 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
bool row, Index_ block_start, Index_ block_end,
const Options& opt)
const {
600 if (my_row_sparse == row) {
601 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicBlockSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
602 my_values, my_indices, secondary(), block_start, block_end, opt
605 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicBlockSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
606 my_values, my_indices, secondary(), block_start, block_end, opt
611 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
bool row, VectorPtr<Index_> subset_ptr,
const Options& opt)
const {
612 if (my_row_sparse == row) {
613 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicIndexSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
614 my_values, my_indices, secondary(), std::move(subset_ptr), opt
617 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicIndexSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
618 my_values, my_indices, secondary(), std::move(subset_ptr), opt
627 std::unique_ptr<OracularDenseExtractor<Value_, Index_> >
dense(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
628 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, opt));
631 std::unique_ptr<OracularDenseExtractor<Value_, Index_> >
dense(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle, Index_ block_start, Index_ block_end,
const Options& opt)
const {
632 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, block_start, block_end, opt));
636 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, std::move(subset_ptr), opt));
643 std::unique_ptr<OracularSparseExtractor<Value_, Index_> >
sparse(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
644 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, opt));
647 std::unique_ptr<OracularSparseExtractor<Value_, Index_> >
sparse(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle, Index_ block_start, Index_ block_end,
const Options& opt)
const {
648 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, block_start, block_end, opt));
652 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, std::move(subset_ptr), opt));
661template<
typename Value_,
typename Index_,
class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
class IndexVectorStorage_ = std::vector<std::vector<Index_> > >
672 FragmentedSparseMatrix<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_>(nrow, ncol, std::move(values), std::move(indices), false, check) {}
680template<
typename Value_,
typename Index_,
class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
class IndexVectorStorage_ = std::vector<std::vector<Index_> > >
691 FragmentedSparseMatrix<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_>(nrow, ncol, std::move(values), std::move(indices), true, check) {}
Get type of elements in an array.
Virtual class for a matrix of some numeric type.
Fragmented sparse column matrix.
Definition FragmentedSparseMatrix.hpp:662
FragmentedSparseColumnMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool check=true)
Definition FragmentedSparseMatrix.hpp:671
Fragmented sparse matrix representation.
Definition FragmentedSparseMatrix.hpp:453
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:627
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > subset_ptr, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:651
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:643
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_end, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:647
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_end, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:631
Index_ ncol() const
Definition FragmentedSparseMatrix.hpp:518
double prefer_rows_proportion() const
Definition FragmentedSparseMatrix.hpp:526
bool uses_oracle(bool) const
Definition FragmentedSparseMatrix.hpp:528
double is_sparse_proportion() const
Definition FragmentedSparseMatrix.hpp:522
Index_ nrow() const
Definition FragmentedSparseMatrix.hpp:516
bool is_sparse() const
Definition FragmentedSparseMatrix.hpp:520
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > subset_ptr, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:635
FragmentedSparseMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool row_sparse, bool check=true)
Definition FragmentedSparseMatrix.hpp:468
bool prefer_rows() const
Definition FragmentedSparseMatrix.hpp:524
Fragmented sparse row matrix.
Definition FragmentedSparseMatrix.hpp:681
FragmentedSparseRowMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool check=true)
Definition FragmentedSparseMatrix.hpp:690
Virtual class for a matrix.
Definition Matrix.hpp:59
Predict future access requests on the target dimension.
Definition Oracle.hpp:21
Flexible representations for matrix data.
Definition Extractor.hpp:15
std::shared_ptr< const std::vector< Index_ > > VectorPtr
Definition Matrix.hpp:26
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< Array_ >()[0])>::type >::type ElementType
Definition ElementType.hpp:17
Options for accessing data from a Matrix instance.
Definition Options.hpp:30