1#ifndef TATAMI_FRAGMENTED_SPARSE_MATRIX_H
2#define TATAMI_FRAGMENTED_SPARSE_MATRIX_H
8#include "primary_extraction.hpp"
9#include "secondary_extraction.hpp"
18#include "sanisizer/sanisizer.hpp"
31namespace FragmentedSparseMatrix_internal {
37template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
38class PrimaryMyopicFullDense final :
public MyopicDenseExtractor<Value_, Index_> {
40 PrimaryMyopicFullDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary) :
41 my_values(values), my_indices(indices), my_secondary(secondary) {}
43 const Value_* fetch(Index_ i, Value_* buffer) {
44 const auto& curv = my_values[i];
45 const auto& curi = my_indices[i];
47 std::fill_n(buffer, my_secondary,
static_cast<Value_
>(0));
48 for (
decltype(curv.size()) x = 0, end = curv.size(); x < end; ++x) {
49 buffer[curi[x]] = curv[x];
55 const ValueVectorStorage_& my_values;
56 const IndexVectorStorage_& my_indices;
60template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
61class PrimaryMyopicFullSparse final :
public MyopicSparseExtractor<Value_, Index_> {
63 PrimaryMyopicFullSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, [[maybe_unused]] Index_ secondary ,
const Options& opt) :
64 my_values(values), my_indices(indices), my_needs_value(opt.sparse_extract_value), my_needs_index(opt.sparse_extract_index) {}
66 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
67 const auto& curv = my_values[i];
68 const auto& curi = my_indices[i];
70 SparseRange<Value_, Index_> output(curv.size(), NULL, NULL);
72 output.value = sparse_utils::extract_primary_vector(curv,
static_cast<decltype(curv.size())
>(0), curv.size(), vbuffer);
75 output.index = sparse_utils::extract_primary_vector(curi,
static_cast<decltype(curi.size())
>(0), curi.size(), index_buffer);
81 const ValueVectorStorage_& my_values;
82 const IndexVectorStorage_& my_indices;
83 bool my_needs_value, my_needs_index;
90template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
91class PrimaryMyopicBlockDense final :
public MyopicDenseExtractor<Value_, Index_> {
93 PrimaryMyopicBlockDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length) :
94 my_values(values), my_indices(indices), my_secondary(secondary), my_block_start(block_start), my_block_length(block_length) {}
96 const Value_* fetch(Index_ i, Value_* buffer) {
97 const auto& curi = my_indices[i];
98 const auto& curv = my_values[i];
100 auto iStart = curi.begin();
101 auto iEnd = curi.end();
102 sparse_utils::refine_primary_block_limits(iStart, iEnd, my_secondary, my_block_start, my_block_length);
103 auto start_pos = (iStart - curi.begin());
104 auto end_pos = (iEnd - curi.begin());
106 std::fill_n(buffer, my_block_length,
static_cast<Value_
>(0));
107 for (
auto x = start_pos; x < end_pos; ++x) {
108 buffer[curi[x] - my_block_start] = curv[x];
114 const ValueVectorStorage_& my_values;
115 const IndexVectorStorage_& my_indices;
117 Index_ my_block_start, my_block_length;
120template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
121class PrimaryMyopicBlockSparse final :
public MyopicSparseExtractor<Value_, Index_> {
123 PrimaryMyopicBlockSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length,
const Options& opt) :
126 my_secondary(secondary),
127 my_block_start(block_start),
128 my_block_length(block_length),
129 my_needs_value(opt.sparse_extract_value),
130 my_needs_index(opt.sparse_extract_index)
133 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
134 const auto& curi = my_indices[i];
135 auto iStart = curi.begin();
136 auto iEnd = curi.end();
137 sparse_utils::refine_primary_block_limits(iStart, iEnd, my_secondary, my_block_start, my_block_length);
138 auto offset = iStart - curi.begin();
139 auto delta = iEnd - iStart;
141 SparseRange<Value_, Index_> output(delta, NULL, NULL);
142 if (my_needs_value) {
143 output.value = sparse_utils::extract_primary_vector(my_values[i], offset, delta, vbuffer);
145 if (my_needs_index) {
146 output.index = sparse_utils::extract_primary_vector(curi, offset, delta, index_buffer);
152 const ValueVectorStorage_& my_values;
153 const IndexVectorStorage_& my_indices;
155 Index_ my_block_start, my_block_length;
156 bool my_needs_value, my_needs_index;
163template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
164class PrimaryMyopicIndexDense final :
public MyopicDenseExtractor<Value_, Index_> {
166 PrimaryMyopicIndexDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr) :
167 my_values(values), my_indices(indices), my_retriever(*indices_ptr, secondary), my_num_indices(indices_ptr->size()) {}
169 const Value_* fetch(Index_ i, Value_* buffer) {
170 const auto& curi = my_indices[i];
171 const auto& curv = my_values[i];
172 std::fill_n(buffer, my_num_indices,
static_cast<Value_
>(0));
173 my_retriever.populate(
176 [&](
auto s,
auto offset) ->
void {
177 buffer[s] = curv[offset];
184 const ValueVectorStorage_& my_values;
185 const IndexVectorStorage_& my_indices;
186 sparse_utils::RetrievePrimarySubsetDense<Index_> my_retriever;
187 std::size_t my_num_indices;
190template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
191class PrimaryMyopicIndexSparse final :
public MyopicSparseExtractor<Value_, Index_> {
193 PrimaryMyopicIndexSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr,
const Options& opt) :
194 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) {}
196 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
197 const auto& curi = my_indices[i];
198 const auto& curv = my_values[i];
200 auto vcopy = vbuffer;
201 auto icopy = index_buffer;
203 my_retriever.populate(
206 [&](
auto offset,
auto ix) ->
void {
208 if (my_needs_value) {
209 *vcopy = curv[offset];
212 if (my_needs_index) {
219 return SparseRange<Value_, Index_>(count, my_needs_value ? vbuffer : NULL, my_needs_index ? index_buffer : NULL);
223 const ValueVectorStorage_& my_values;
224 const IndexVectorStorage_& my_indices;
225 sparse_utils::RetrievePrimarySubsetSparse<Index_> my_retriever;
226 bool my_needs_value, my_needs_index;
233template<
typename Index_,
class IndexVectorStorage_>
236 ServeIndices(
const IndexVectorStorage_& indices) : my_indices(indices) {}
239 const IndexVectorStorage_& my_indices;
242 typedef decltype(std::declval<IndexVectorStorage_>()[0].size()) pointer_type;
244 pointer_type start_offset(Index_)
const {
248 pointer_type end_offset(Index_ primary)
const {
249 return my_indices[primary].size();
252 auto raw(Index_ primary)
const {
253 return my_indices[primary].begin();
257template<
typename Index_,
class IndexVectorStorage_>
258auto make_ServeIndices(
const IndexVectorStorage_& i) {
259 return ServeIndices<Index_, IndexVectorStorage_>(i);
262template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
263class SecondaryMyopicFullDense final :
public MyopicDenseExtractor<Value_, Index_> {
265 SecondaryMyopicFullDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary) :
266 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, indices.size()) {}
268 const Value_* fetch(Index_ i, Value_* buffer) {
269 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
272 [&](Index_ primary, Index_ index_primary,
auto ptr) ->
void {
273 buffer[index_primary] = my_values[primary][ptr];
280 const ValueVectorStorage_& my_values;
281 sparse_utils::FullSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
284template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
285class SecondaryMyopicFullSparse final :
public MyopicSparseExtractor<Value_, Index_> {
287 SecondaryMyopicFullSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary,
const Options& opt) :
288 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) {}
290 SparseRange<Value_, Index_> fetch(Index_ i, Value_* value_buffer, Index_* index_buffer) {
294 [&](Index_ primary, Index_,
auto ptr) ->
void {
295 if (my_needs_value) {
296 value_buffer[count] = my_values[primary][ptr];
298 if (my_needs_index) {
299 index_buffer[count] = primary;
304 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
308 const ValueVectorStorage_& my_values;
309 sparse_utils::FullSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
310 bool my_needs_value, my_needs_index;
317template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
318class SecondaryMyopicBlockDense final :
public MyopicDenseExtractor<Value_, Index_> {
320 SecondaryMyopicBlockDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length) :
321 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, block_start, block_length) {}
323 const Value_* fetch(Index_ i, Value_* buffer) {
324 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
327 [&](Index_ primary, Index_ index_primary,
auto ptr) ->
void {
328 buffer[index_primary] = my_values[primary][ptr];
335 const ValueVectorStorage_& my_values;
336 sparse_utils::BlockSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
339template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
340class SecondaryMyopicBlockSparse final :
public MyopicSparseExtractor<Value_, Index_> {
342 SecondaryMyopicBlockSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length,
const Options& opt) :
343 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) {}
345 SparseRange<Value_, Index_> fetch(Index_ i, Value_* value_buffer, Index_* index_buffer) {
349 [&](Index_ primary, Index_,
auto ptr) ->
void {
350 if (my_needs_value) {
351 value_buffer[count] = my_values[primary][ptr];
353 if (my_needs_index) {
354 index_buffer[count] = primary;
359 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
363 const ValueVectorStorage_& my_values;
364 sparse_utils::BlockSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
365 bool my_needs_value, my_needs_index;
372template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
373class SecondaryMyopicIndexDense final :
public MyopicDenseExtractor<Value_, Index_> {
375 SecondaryMyopicIndexDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr) :
376 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, std::move(indices_ptr)) {}
378 const Value_* fetch(Index_ i, Value_* buffer) {
379 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
382 [&](Index_ primary, Index_ index_primary,
auto ptr) ->
void {
383 buffer[index_primary] = my_values[primary][ptr];
390 const ValueVectorStorage_& my_values;
391 sparse_utils::IndexSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
394template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
395class SecondaryMyopicIndexSparse final :
public MyopicSparseExtractor<Value_, Index_> {
397 SecondaryMyopicIndexSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr,
const Options& opt) :
398 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) {}
400 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
404 [&](Index_ primary, Index_,
auto ptr) ->
void {
405 if (my_needs_value) {
406 vbuffer[count] = my_values[primary][ptr];
408 if (my_needs_index) {
409 index_buffer[count] = primary;
414 return SparseRange<Value_, Index_>(count, my_needs_value ? vbuffer : NULL, my_needs_index ? index_buffer : NULL);
418 const ValueVectorStorage_& my_values;
419 sparse_utils::IndexSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
420 bool my_needs_value, my_needs_index;
466template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
479 my_nrow(nrow), my_ncol(ncol), my_values(std::move(values)), my_indices(std::move(indices)), my_row_sparse(row_sparse)
482 if (my_values.size() != my_indices.size()) {
483 throw std::runtime_error(
"'values' and 'indices' should be of the same length");
487 if (!safe_non_negative_equal(my_indices.size(), my_nrow)) {
488 throw std::runtime_error(
"length of 'indices' should be equal to number of rows'");
491 if (!safe_non_negative_equal(my_indices.size(), my_ncol)) {
492 throw std::runtime_error(
"length of 'indices' should be equal to number of columns");
497 for (
decltype(my_indices.size()) i = 0, end = my_indices.size(); i < end; ++i) {
498 const auto& curv = my_values[i];
499 const auto& curi = my_indices[i];
500 if (!safe_non_negative_equal(curv.size(), curi.size())) {
501 throw std::runtime_error(
"corresponding elements of 'values' and 'indices' should have the same length");
504 for (
auto x : curi) {
505 if (x < 0 || x >= max_index) {
506 throw std::runtime_error(
"'indices' should contain non-negative integers less than the number of " + (my_row_sparse ? std::string(
"columns") : std::string(
"rows")));
510 for (
decltype(curi.size()) j = 1, jend = curi.size(); j < jend; ++j) {
511 if (curi[j] <= curi[j - 1]) {
512 throw std::runtime_error(
"my_indices should be strictly increasing within each element of 'indices'");
519 sanisizer::can_ptrdiff<
decltype(curi.begin())>(
static_cast<Index_
>(curi.size()));
528 FragmentedSparseMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices,
bool row_sparse,
bool check =
true) :
529 FragmentedSparseMatrix(
536 FragmentedSparseMatrixOptions fopt;
547 Index_ my_nrow, my_ncol;
548 ValueVectorStorage_ my_values;
549 IndexVectorStorage_ my_indices;
553 Index_
nrow()
const {
return my_nrow; }
555 Index_
ncol()
const {
return my_ncol; }
567 using Matrix<Value_, Index_>::dense;
569 using Matrix<Value_, Index_>::sparse;
572 Index_ secondary()
const {
584 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
bool row,
const Options&)
const {
585 if (my_row_sparse == row) {
586 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicFullDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
587 my_values, my_indices, secondary()
590 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicFullDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
591 my_values, my_indices, secondary()
596 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
bool row, Index_ block_start, Index_ block_end,
const Options&)
const {
597 if (my_row_sparse == row) {
598 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicBlockDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
599 my_values, my_indices, secondary(), block_start, block_end
602 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicBlockDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
603 my_values, my_indices, secondary(), block_start, block_end
608 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
bool row, VectorPtr<Index_> subset_ptr,
const Options&)
const {
609 if (my_row_sparse == row) {
610 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicIndexDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
611 my_values, my_indices, secondary(), std::move(subset_ptr)
614 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicIndexDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
615 my_values, my_indices, secondary(), std::move(subset_ptr)
624 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
bool row,
const Options& opt)
const {
625 if (my_row_sparse == row) {
626 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicFullSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
627 my_values, my_indices, secondary(), opt
630 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicFullSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
631 my_values, my_indices, secondary(), opt
636 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
bool row, Index_ block_start, Index_ block_end,
const Options& opt)
const {
637 if (my_row_sparse == row) {
638 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicBlockSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
639 my_values, my_indices, secondary(), block_start, block_end, opt
642 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicBlockSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
643 my_values, my_indices, secondary(), block_start, block_end, opt
648 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
bool row, VectorPtr<Index_> subset_ptr,
const Options& opt)
const {
649 if (my_row_sparse == row) {
650 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicIndexSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
651 my_values, my_indices, secondary(), std::move(subset_ptr), opt
654 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicIndexSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
655 my_values, my_indices, secondary(), std::move(subset_ptr), opt
664 std::unique_ptr<OracularDenseExtractor<Value_, Index_> >
dense(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
665 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, opt));
668 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 {
669 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, block_start, block_end, opt));
673 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, std::move(subset_ptr), opt));
680 std::unique_ptr<OracularSparseExtractor<Value_, Index_> >
sparse(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
681 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, opt));
684 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 {
685 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, block_start, block_end, opt));
689 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, std::move(subset_ptr), opt));
698template<
typename Value_,
typename Index_,
class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
class IndexVectorStorage_ = std::vector<std::vector<Index_> > >
709 FragmentedSparseMatrix<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_>(nrow, ncol, std::move(values), std::move(indices), false, check) {}
717template<
typename Value_,
typename Index_,
class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
class IndexVectorStorage_ = std::vector<std::vector<Index_> > >
728 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:699
FragmentedSparseColumnMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool check=true)
Definition FragmentedSparseMatrix.hpp:708
Fragmented sparse matrix representation.
Definition FragmentedSparseMatrix.hpp:467
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:664
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:688
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:680
FragmentedSparseMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool row_sparse, const FragmentedSparseMatrixOptions &options)
Definition FragmentedSparseMatrix.hpp:478
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:684
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:668
Index_ ncol() const
Definition FragmentedSparseMatrix.hpp:555
double prefer_rows_proportion() const
Definition FragmentedSparseMatrix.hpp:563
bool uses_oracle(bool) const
Definition FragmentedSparseMatrix.hpp:565
double is_sparse_proportion() const
Definition FragmentedSparseMatrix.hpp:559
Index_ nrow() const
Definition FragmentedSparseMatrix.hpp:553
bool is_sparse() const
Definition FragmentedSparseMatrix.hpp:557
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:672
bool prefer_rows() const
Definition FragmentedSparseMatrix.hpp:561
Fragmented sparse row matrix.
Definition FragmentedSparseMatrix.hpp:718
FragmentedSparseRowMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool check=true)
Definition FragmentedSparseMatrix.hpp:727
Virtual class for a matrix.
Definition Matrix.hpp:59
Predict future access requests on the target dimension.
Definition Oracle.hpp:29
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 FragmentedSparseMatrix().
Definition FragmentedSparseMatrix.hpp:431
bool check
Definition FragmentedSparseMatrix.hpp:442
Options for accessing data from a Matrix instance.
Definition Options.hpp:30