1#ifndef TATAMI_FRAGMENTED_SPARSE_MATRIX_H
2#define TATAMI_FRAGMENTED_SPARSE_MATRIX_H
10#include "primary_extraction.hpp"
11#include "secondary_extraction.hpp"
20#include "sanisizer/sanisizer.hpp"
33namespace FragmentedSparseMatrix_internal {
39template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
40class PrimaryMyopicFullDense final :
public MyopicDenseExtractor<Value_, Index_> {
42 PrimaryMyopicFullDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices,
const Index_ secondary) :
43 my_values(values), my_indices(indices), my_secondary(secondary) {}
45 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
46 const auto& curv = my_values[i];
47 const auto& curi = my_indices[i];
49 std::fill_n(buffer, my_secondary,
static_cast<Value_
>(0));
50 const auto curnnz = curv.size();
51 for (I<
decltype(curnnz)> x = 0; x < curnnz; ++x) {
52 buffer[curi[x]] = curv[x];
58 const ValueVectorStorage_& my_values;
59 const IndexVectorStorage_& my_indices;
63template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
64class PrimaryMyopicFullSparse final :
public MyopicSparseExtractor<Value_, Index_> {
66 PrimaryMyopicFullSparse(
67 const ValueVectorStorage_& values,
68 const IndexVectorStorage_& indices,
69 [[maybe_unused]]
const Index_ secondary ,
74 my_needs_value(opt.sparse_extract_value),
75 my_needs_index(opt.sparse_extract_index)
78 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
79 const auto& curv = my_values[i];
80 const auto& curi = my_indices[i];
82 SparseRange<Value_, Index_> output(curv.size(), NULL, NULL);
84 const auto curnnz = curv.size();
85 output.value = sparse_utils::extract_primary_vector(curv,
static_cast<I<decltype(curnnz)
> >(0), curnnz, value_buffer);
88 const auto curnnz = curi.size();
89 output.index = sparse_utils::extract_primary_vector(curi,
static_cast<I<decltype(curnnz)
> >(0), curnnz, index_buffer);
95 const ValueVectorStorage_& my_values;
96 const IndexVectorStorage_& my_indices;
97 bool my_needs_value, my_needs_index;
104template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
105class PrimaryMyopicBlockDense final :
public MyopicDenseExtractor<Value_, Index_> {
107 PrimaryMyopicBlockDense(
108 const ValueVectorStorage_& values,
109 const IndexVectorStorage_& indices,
110 const Index_ secondary,
111 const Index_ block_start,
112 const Index_ block_length
116 my_secondary(secondary),
117 my_block_start(block_start),
118 my_block_length(block_length)
121 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
122 const auto& curi = my_indices[i];
123 const auto& curv = my_values[i];
125 auto iStart = curi.begin();
126 auto iEnd = curi.end();
127 sparse_utils::refine_primary_block_limits(iStart, iEnd, my_secondary, my_block_start, my_block_length);
128 const auto start_pos = (iStart - curi.begin());
129 const auto end_pos = (iEnd - curi.begin());
131 std::fill_n(buffer, my_block_length,
static_cast<Value_
>(0));
132 for (
auto x = start_pos; x < end_pos; ++x) {
133 buffer[curi[x] - my_block_start] = curv[x];
139 const ValueVectorStorage_& my_values;
140 const IndexVectorStorage_& my_indices;
142 Index_ my_block_start, my_block_length;
145template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
146class PrimaryMyopicBlockSparse final :
public MyopicSparseExtractor<Value_, Index_> {
148 PrimaryMyopicBlockSparse(
149 const ValueVectorStorage_& values,
150 const IndexVectorStorage_& indices,
151 const Index_ secondary,
152 const Index_ block_start,
153 const Index_ block_length,
158 my_secondary(secondary),
159 my_block_start(block_start),
160 my_block_length(block_length),
161 my_needs_value(opt.sparse_extract_value),
162 my_needs_index(opt.sparse_extract_index)
165 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
166 const auto& curi = my_indices[i];
167 auto iStart = curi.begin();
168 auto iEnd = curi.end();
169 sparse_utils::refine_primary_block_limits(iStart, iEnd, my_secondary, my_block_start, my_block_length);
170 const auto offset = iStart - curi.begin();
171 const auto delta = iEnd - iStart;
173 SparseRange<Value_, Index_> output(delta, NULL, NULL);
174 if (my_needs_value) {
175 output.value = sparse_utils::extract_primary_vector(my_values[i], offset, delta, value_buffer);
177 if (my_needs_index) {
178 output.index = sparse_utils::extract_primary_vector(curi, offset, delta, index_buffer);
184 const ValueVectorStorage_& my_values;
185 const IndexVectorStorage_& my_indices;
187 Index_ my_block_start, my_block_length;
188 bool my_needs_value, my_needs_index;
195template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
196class PrimaryMyopicIndexDense final :
public MyopicDenseExtractor<Value_, Index_> {
198 PrimaryMyopicIndexDense(
199 const ValueVectorStorage_& values,
200 const IndexVectorStorage_& indices,
201 const Index_ secondary,
202 VectorPtr<Index_> indices_ptr
206 my_retriever(*indices_ptr, secondary),
207 my_num_indices(indices_ptr->size())
210 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
211 const auto& curi = my_indices[i];
212 const auto& curv = my_values[i];
213 std::fill_n(buffer, my_num_indices,
static_cast<Value_
>(0));
214 my_retriever.populate(
217 [&](
const auto s,
const auto offset) ->
void {
218 buffer[s] = curv[offset];
225 const ValueVectorStorage_& my_values;
226 const IndexVectorStorage_& my_indices;
227 sparse_utils::RetrievePrimarySubsetDense<Index_> my_retriever;
228 std::size_t my_num_indices;
231template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
232class PrimaryMyopicIndexSparse final :
public MyopicSparseExtractor<Value_, Index_> {
234 PrimaryMyopicIndexSparse(
235 const ValueVectorStorage_& values,
236 const IndexVectorStorage_& indices,
237 const Index_ secondary,
238 VectorPtr<Index_> indices_ptr,
243 my_retriever(*indices_ptr, secondary),
244 my_needs_value(opt.sparse_extract_value),
245 my_needs_index(opt.sparse_extract_index)
248 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
249 const auto& curi = my_indices[i];
250 const auto& curv = my_values[i];
252 auto vcopy = value_buffer;
253 auto icopy = index_buffer;
255 my_retriever.populate(
258 [&](
const auto offset,
const auto ix) ->
void {
260 if (my_needs_value) {
261 *vcopy = curv[offset];
264 if (my_needs_index) {
271 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
275 const ValueVectorStorage_& my_values;
276 const IndexVectorStorage_& my_indices;
277 sparse_utils::RetrievePrimarySubsetSparse<Index_> my_retriever;
278 bool my_needs_value, my_needs_index;
285template<
typename Index_,
class IndexVectorStorage_>
288 ServeIndices(
const IndexVectorStorage_& indices) : my_indices(indices) {}
291 const IndexVectorStorage_& my_indices;
294 typedef I<decltype(std::declval<IndexVectorStorage_>()[0].size())> Pointer;
296 Pointer start_offset(
const Index_)
const {
300 Pointer end_offset(
const Index_ primary)
const {
301 return my_indices[primary].size();
304 auto raw(
const Index_ primary)
const {
305 return my_indices[primary].begin();
309template<
typename Index_,
class IndexVectorStorage_>
310auto make_ServeIndices(
const IndexVectorStorage_& i) {
311 return ServeIndices<Index_, IndexVectorStorage_>(i);
314template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
315class SecondaryMyopicFullDense final :
public MyopicDenseExtractor<Value_, Index_> {
317 SecondaryMyopicFullDense(
318 const ValueVectorStorage_& values,
319 const IndexVectorStorage_& indices,
323 my_cache(make_ServeIndices<Index_>(indices), secondary, indices.size())
326 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
327 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
330 [&](Index_ primary, Index_ index_primary,
auto ptr) ->
void {
331 buffer[index_primary] = my_values[primary][ptr];
338 const ValueVectorStorage_& my_values;
339 sparse_utils::FullSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
342template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
343class SecondaryMyopicFullSparse final :
public MyopicSparseExtractor<Value_, Index_> {
345 SecondaryMyopicFullSparse(
346 const ValueVectorStorage_& values,
347 const IndexVectorStorage_& indices,
348 const Index_ secondary,
352 my_cache(make_ServeIndices<Index_>(indices), secondary, indices.size()),
353 my_needs_value(opt.sparse_extract_value),
354 my_needs_index(opt.sparse_extract_index)
357 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
361 [&](
const Index_ primary,
const Index_,
const auto ptr) ->
void {
362 if (my_needs_value) {
363 value_buffer[count] = my_values[primary][ptr];
365 if (my_needs_index) {
366 index_buffer[count] = primary;
371 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
375 const ValueVectorStorage_& my_values;
376 sparse_utils::FullSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
377 bool my_needs_value, my_needs_index;
384template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
385class SecondaryMyopicBlockDense final :
public MyopicDenseExtractor<Value_, Index_> {
387 SecondaryMyopicBlockDense(
388 const ValueVectorStorage_& values,
389 const IndexVectorStorage_& indices,
390 const Index_ secondary,
391 const Index_ block_start,
392 const Index_ block_length
395 my_cache(make_ServeIndices<Index_>(indices), secondary, block_start, block_length)
398 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
399 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
402 [&](
const Index_ primary,
const Index_ index_primary,
const auto ptr) ->
void {
403 buffer[index_primary] = my_values[primary][ptr];
410 const ValueVectorStorage_& my_values;
411 sparse_utils::BlockSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
414template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
415class SecondaryMyopicBlockSparse final :
public MyopicSparseExtractor<Value_, Index_> {
417 SecondaryMyopicBlockSparse(
418 const ValueVectorStorage_& values,
419 const IndexVectorStorage_& indices,
420 const Index_ secondary,
421 const Index_ block_start,
422 const Index_ block_length,
426 my_cache(make_ServeIndices<Index_>(indices), secondary, block_start, block_length),
427 my_needs_value(opt.sparse_extract_value),
428 my_needs_index(opt.sparse_extract_index)
431 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
435 [&](
const Index_ primary,
const Index_,
const auto ptr) ->
void {
436 if (my_needs_value) {
437 value_buffer[count] = my_values[primary][ptr];
439 if (my_needs_index) {
440 index_buffer[count] = primary;
445 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
449 const ValueVectorStorage_& my_values;
450 sparse_utils::BlockSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
451 bool my_needs_value, my_needs_index;
458template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
459class SecondaryMyopicIndexDense final :
public MyopicDenseExtractor<Value_, Index_> {
461 SecondaryMyopicIndexDense(
462 const ValueVectorStorage_& values,
463 const IndexVectorStorage_& indices,
464 const Index_ secondary,
465 VectorPtr<Index_> indices_ptr
468 my_cache(make_ServeIndices<Index_>(indices), secondary, std::move(indices_ptr))
471 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
472 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
475 [&](Index_ primary, Index_ index_primary,
auto ptr) ->
void {
476 buffer[index_primary] = my_values[primary][ptr];
483 const ValueVectorStorage_& my_values;
484 sparse_utils::IndexSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
487template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
488class SecondaryMyopicIndexSparse final :
public MyopicSparseExtractor<Value_, Index_> {
490 SecondaryMyopicIndexSparse(
491 const ValueVectorStorage_& values,
492 const IndexVectorStorage_& indices,
493 const Index_ secondary,
494 VectorPtr<Index_> indices_ptr,
498 my_cache(make_ServeIndices<Index_>(indices), secondary, std::move(indices_ptr)),
499 my_needs_value(opt.sparse_extract_value),
500 my_needs_index(opt.sparse_extract_index)
503 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
507 [&](
const Index_ primary,
const Index_,
const auto ptr) ->
void {
508 if (my_needs_value) {
509 value_buffer[count] = my_values[primary][ptr];
511 if (my_needs_index) {
512 index_buffer[count] = primary;
517 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
521 const ValueVectorStorage_& my_values;
522 sparse_utils::IndexSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
523 bool my_needs_value, my_needs_index;
569template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
584 ValueVectorStorage_ values,
585 IndexVectorStorage_ indices,
586 const bool row_sparse,
591 my_values(std::move(values)),
592 my_indices(std::move(indices)),
593 my_row_sparse(row_sparse)
596 if (my_values.size() != my_indices.size()) {
597 throw std::runtime_error(
"'values' and 'indices' should be of the same length");
601 if (!safe_non_negative_equal(my_indices.size(), my_nrow)) {
602 throw std::runtime_error(
"length of 'indices' should be equal to number of rows'");
605 if (!safe_non_negative_equal(my_indices.size(), my_ncol)) {
606 throw std::runtime_error(
"length of 'indices' should be equal to number of columns");
611 const auto num_indices = my_indices.size();
612 for (I<
decltype(num_indices)> i = 0; i < num_indices; ++i) {
613 const auto& curv = my_values[i];
614 const auto& curi = my_indices[i];
615 if (!safe_non_negative_equal(curv.size(), curi.size())) {
616 throw std::runtime_error(
"corresponding elements of 'values' and 'indices' should have the same length");
619 for (
const auto x : curi) {
620 if (x < 0 || x >= max_index) {
621 throw std::runtime_error(
"'indices' should contain non-negative integers less than the number of " + (my_row_sparse ? std::string(
"columns") : std::string(
"rows")));
625 const auto curnnz = curi.size();
626 for (I<
decltype(curnnz)> j = 1; j < curnnz; ++j) {
627 if (curi[j] <= curi[j - 1]) {
628 throw std::runtime_error(
"my_indices should be strictly increasing within each element of 'indices'");
635 sanisizer::can_ptrdiff<I<
decltype(curi.begin())> >(attest_for_Index(
static_cast<Index_
>(curnnz)));
644 FragmentedSparseMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices,
bool row_sparse,
bool check =
true) :
645 FragmentedSparseMatrix(
652 FragmentedSparseMatrixOptions fopt;
663 Index_ my_nrow, my_ncol;
664 ValueVectorStorage_ my_values;
665 IndexVectorStorage_ my_indices;
669 Index_
nrow()
const {
return my_nrow; }
671 Index_
ncol()
const {
return my_ncol; }
683 using Matrix<Value_, Index_>::dense;
685 using Matrix<Value_, Index_>::sparse;
688 Index_ secondary()
const {
700 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
704 if (my_row_sparse == row) {
705 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicFullDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
706 my_values, my_indices, secondary()
709 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicFullDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
710 my_values, my_indices, secondary()
715 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
717 const Index_ block_start,
718 const Index_ block_end,
721 if (my_row_sparse == row) {
722 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicBlockDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
723 my_values, my_indices, secondary(), block_start, block_end
726 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicBlockDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
727 my_values, my_indices, secondary(), block_start, block_end
732 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
734 VectorPtr<Index_> subset_ptr,
737 if (my_row_sparse == row) {
738 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicIndexDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
739 my_values, my_indices, secondary(), std::move(subset_ptr)
742 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicIndexDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
743 my_values, my_indices, secondary(), std::move(subset_ptr)
752 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
756 if (my_row_sparse == row) {
757 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicFullSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
758 my_values, my_indices, secondary(), opt
761 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicFullSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
762 my_values, my_indices, secondary(), opt
767 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
769 const Index_ block_start,
770 const Index_ block_end,
773 if (my_row_sparse == row) {
774 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicBlockSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
775 my_values, my_indices, secondary(), block_start, block_end, opt
778 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicBlockSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
779 my_values, my_indices, secondary(), block_start, block_end, opt
784 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
786 VectorPtr<Index_> subset_ptr,
789 if (my_row_sparse == row) {
790 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicIndexSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
791 my_values, my_indices, secondary(), std::move(subset_ptr), opt
794 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicIndexSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
795 my_values, my_indices, secondary(), std::move(subset_ptr), opt
804 std::unique_ptr<OracularDenseExtractor<Value_, Index_> >
dense(
809 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, opt));
812 std::unique_ptr<OracularDenseExtractor<Value_, Index_> >
dense(
815 const Index_ block_start,
816 const Index_ block_end,
819 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, block_start, block_end, opt));
822 std::unique_ptr<OracularDenseExtractor<Value_, Index_> >
dense(
828 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, std::move(subset_ptr), opt));
835 std::unique_ptr<OracularSparseExtractor<Value_, Index_> >
sparse(
840 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, opt));
843 std::unique_ptr<OracularSparseExtractor<Value_, Index_> >
sparse(
846 const Index_ block_start,
847 const Index_ block_end,
850 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, block_start, block_end, opt));
853 std::unique_ptr<OracularSparseExtractor<Value_, Index_> >
sparse(
859 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, std::move(subset_ptr), opt));
868template<
typename Value_,
typename Index_,
class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
class IndexVectorStorage_ = std::vector<std::vector<Index_> > >
879 FragmentedSparseMatrix<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_>(nrow, ncol, std::move(values), std::move(indices), false, check) {}
887template<
typename Value_,
typename Index_,
class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
class IndexVectorStorage_ = std::vector<std::vector<Index_> > >
898 FragmentedSparseMatrix<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_>(nrow, ncol, std::move(values), std::move(indices), true, check) {}
Get type of elements in an array.
Convert index type to container size.
Virtual class for a matrix of some numeric type.
Fragmented sparse column matrix.
Definition FragmentedSparseMatrix.hpp:869
FragmentedSparseColumnMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool check=true)
Definition FragmentedSparseMatrix.hpp:878
Fragmented sparse matrix representation.
Definition FragmentedSparseMatrix.hpp:570
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:835
FragmentedSparseMatrix(const Index_ nrow, const Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, const bool row_sparse, const FragmentedSparseMatrixOptions &options)
Definition FragmentedSparseMatrix.hpp:581
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Index_ block_start, const Index_ block_end, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:812
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > subset_ptr, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:822
Index_ ncol() const
Definition FragmentedSparseMatrix.hpp:671
double prefer_rows_proportion() const
Definition FragmentedSparseMatrix.hpp:679
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > subset_ptr, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:853
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Index_ block_start, const Index_ block_end, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:843
double is_sparse_proportion() const
Definition FragmentedSparseMatrix.hpp:675
Index_ nrow() const
Definition FragmentedSparseMatrix.hpp:669
bool is_sparse() const
Definition FragmentedSparseMatrix.hpp:673
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:804
bool prefer_rows() const
Definition FragmentedSparseMatrix.hpp:677
bool uses_oracle(const bool) const
Definition FragmentedSparseMatrix.hpp:681
Fragmented sparse row matrix.
Definition FragmentedSparseMatrix.hpp:888
FragmentedSparseRowMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool check=true)
Definition FragmentedSparseMatrix.hpp:897
Virtual class for a matrix.
Definition Matrix.hpp:59
Predict future access requests on the target dimension.
Definition Oracle.hpp:29
Copy data from one buffer to another.
Flexible representations for matrix data.
Definition Extractor.hpp:15
std::shared_ptr< const std::vector< Index_ > > VectorPtr
Definition Matrix.hpp:26
I< decltype(std::declval< Array_ >()[0])> ElementType
Definition ElementType.hpp:19
Options for FragmentedSparseMatrix().
Definition FragmentedSparseMatrix.hpp:534
bool check
Definition FragmentedSparseMatrix.hpp:545
Options for accessing data from a Matrix instance.
Definition Options.hpp:30