1#ifndef TATAMI_FRAGMENTED_SPARSE_MATRIX_H
2#define TATAMI_FRAGMENTED_SPARSE_MATRIX_H
9#include "primary_extraction.hpp"
10#include "secondary_extraction.hpp"
19#include "sanisizer/sanisizer.hpp"
32namespace FragmentedSparseMatrix_internal {
38template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
39class PrimaryMyopicFullDense final :
public MyopicDenseExtractor<Value_, Index_> {
41 PrimaryMyopicFullDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices,
const Index_ secondary) :
42 my_values(values), my_indices(indices), my_secondary(secondary) {}
44 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
45 const auto& curv = my_values[i];
46 const auto& curi = my_indices[i];
48 std::fill_n(buffer, my_secondary,
static_cast<Value_
>(0));
49 const auto curnnz = curv.size();
50 for (I<
decltype(curnnz)> x = 0; x < curnnz; ++x) {
51 buffer[curi[x]] = curv[x];
57 const ValueVectorStorage_& my_values;
58 const IndexVectorStorage_& my_indices;
62template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
63class PrimaryMyopicFullSparse final :
public MyopicSparseExtractor<Value_, Index_> {
65 PrimaryMyopicFullSparse(
66 const ValueVectorStorage_& values,
67 const IndexVectorStorage_& indices,
68 [[maybe_unused]]
const Index_ secondary ,
73 my_needs_value(opt.sparse_extract_value),
74 my_needs_index(opt.sparse_extract_index)
77 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
78 const auto& curv = my_values[i];
79 const auto& curi = my_indices[i];
81 SparseRange<Value_, Index_> output(curv.size(), NULL, NULL);
83 const auto curnnz = curv.size();
84 output.value = sparse_utils::extract_primary_vector(curv,
static_cast<I<decltype(curnnz)
> >(0), curnnz, value_buffer);
87 const auto curnnz = curi.size();
88 output.index = sparse_utils::extract_primary_vector(curi,
static_cast<I<decltype(curnnz)
> >(0), curnnz, index_buffer);
94 const ValueVectorStorage_& my_values;
95 const IndexVectorStorage_& my_indices;
96 bool my_needs_value, my_needs_index;
103template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
104class PrimaryMyopicBlockDense final :
public MyopicDenseExtractor<Value_, Index_> {
106 PrimaryMyopicBlockDense(
107 const ValueVectorStorage_& values,
108 const IndexVectorStorage_& indices,
109 const Index_ secondary,
110 const Index_ block_start,
111 const Index_ block_length
115 my_secondary(secondary),
116 my_block_start(block_start),
117 my_block_length(block_length)
120 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
121 const auto& curi = my_indices[i];
122 const auto& curv = my_values[i];
124 auto iStart = curi.begin();
125 auto iEnd = curi.end();
126 sparse_utils::refine_primary_block_limits(iStart, iEnd, my_secondary, my_block_start, my_block_length);
127 const auto start_pos = (iStart - curi.begin());
128 const auto end_pos = (iEnd - curi.begin());
130 std::fill_n(buffer, my_block_length,
static_cast<Value_
>(0));
131 for (
auto x = start_pos; x < end_pos; ++x) {
132 buffer[curi[x] - my_block_start] = curv[x];
138 const ValueVectorStorage_& my_values;
139 const IndexVectorStorage_& my_indices;
141 Index_ my_block_start, my_block_length;
144template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
145class PrimaryMyopicBlockSparse final :
public MyopicSparseExtractor<Value_, Index_> {
147 PrimaryMyopicBlockSparse(
148 const ValueVectorStorage_& values,
149 const IndexVectorStorage_& indices,
150 const Index_ secondary,
151 const Index_ block_start,
152 const Index_ block_length,
157 my_secondary(secondary),
158 my_block_start(block_start),
159 my_block_length(block_length),
160 my_needs_value(opt.sparse_extract_value),
161 my_needs_index(opt.sparse_extract_index)
164 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
165 const auto& curi = my_indices[i];
166 auto iStart = curi.begin();
167 auto iEnd = curi.end();
168 sparse_utils::refine_primary_block_limits(iStart, iEnd, my_secondary, my_block_start, my_block_length);
169 const auto offset = iStart - curi.begin();
170 const auto delta = iEnd - iStart;
172 SparseRange<Value_, Index_> output(delta, NULL, NULL);
173 if (my_needs_value) {
174 output.value = sparse_utils::extract_primary_vector(my_values[i], offset, delta, value_buffer);
176 if (my_needs_index) {
177 output.index = sparse_utils::extract_primary_vector(curi, offset, delta, index_buffer);
183 const ValueVectorStorage_& my_values;
184 const IndexVectorStorage_& my_indices;
186 Index_ my_block_start, my_block_length;
187 bool my_needs_value, my_needs_index;
194template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
195class PrimaryMyopicIndexDense final :
public MyopicDenseExtractor<Value_, Index_> {
197 PrimaryMyopicIndexDense(
198 const ValueVectorStorage_& values,
199 const IndexVectorStorage_& indices,
200 const Index_ secondary,
201 VectorPtr<Index_> indices_ptr
205 my_retriever(*indices_ptr, secondary),
206 my_num_indices(indices_ptr->size())
209 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
210 const auto& curi = my_indices[i];
211 const auto& curv = my_values[i];
212 std::fill_n(buffer, my_num_indices,
static_cast<Value_
>(0));
213 my_retriever.populate(
216 [&](
const auto s,
const auto offset) ->
void {
217 buffer[s] = curv[offset];
224 const ValueVectorStorage_& my_values;
225 const IndexVectorStorage_& my_indices;
226 sparse_utils::RetrievePrimarySubsetDense<Index_> my_retriever;
227 std::size_t my_num_indices;
230template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
231class PrimaryMyopicIndexSparse final :
public MyopicSparseExtractor<Value_, Index_> {
233 PrimaryMyopicIndexSparse(
234 const ValueVectorStorage_& values,
235 const IndexVectorStorage_& indices,
236 const Index_ secondary,
237 VectorPtr<Index_> indices_ptr,
242 my_retriever(*indices_ptr, secondary),
243 my_needs_value(opt.sparse_extract_value),
244 my_needs_index(opt.sparse_extract_index)
247 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
248 const auto& curi = my_indices[i];
249 const auto& curv = my_values[i];
251 auto vcopy = value_buffer;
252 auto icopy = index_buffer;
254 my_retriever.populate(
257 [&](
const auto offset,
const auto ix) ->
void {
259 if (my_needs_value) {
260 *vcopy = curv[offset];
263 if (my_needs_index) {
270 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
274 const ValueVectorStorage_& my_values;
275 const IndexVectorStorage_& my_indices;
276 sparse_utils::RetrievePrimarySubsetSparse<Index_> my_retriever;
277 bool my_needs_value, my_needs_index;
284template<
typename Index_,
class IndexVectorStorage_>
287 ServeIndices(
const IndexVectorStorage_& indices) : my_indices(indices) {}
290 const IndexVectorStorage_& my_indices;
293 typedef I<decltype(std::declval<IndexVectorStorage_>()[0].size())> Pointer;
295 Pointer start_offset(
const Index_)
const {
299 Pointer end_offset(
const Index_ primary)
const {
300 return my_indices[primary].size();
303 auto raw(
const Index_ primary)
const {
304 return my_indices[primary].begin();
308template<
typename Index_,
class IndexVectorStorage_>
309auto make_ServeIndices(
const IndexVectorStorage_& i) {
310 return ServeIndices<Index_, IndexVectorStorage_>(i);
313template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
314class SecondaryMyopicFullDense final :
public MyopicDenseExtractor<Value_, Index_> {
316 SecondaryMyopicFullDense(
317 const ValueVectorStorage_& values,
318 const IndexVectorStorage_& indices,
322 my_cache(make_ServeIndices<Index_>(indices), secondary, indices.size())
325 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
326 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
329 [&](Index_ primary, Index_ index_primary,
auto ptr) ->
void {
330 buffer[index_primary] = my_values[primary][ptr];
337 const ValueVectorStorage_& my_values;
338 sparse_utils::FullSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
341template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
342class SecondaryMyopicFullSparse final :
public MyopicSparseExtractor<Value_, Index_> {
344 SecondaryMyopicFullSparse(
345 const ValueVectorStorage_& values,
346 const IndexVectorStorage_& indices,
347 const Index_ secondary,
351 my_cache(make_ServeIndices<Index_>(indices), secondary, indices.size()),
352 my_needs_value(opt.sparse_extract_value),
353 my_needs_index(opt.sparse_extract_index)
356 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
360 [&](
const Index_ primary,
const Index_,
const auto ptr) ->
void {
361 if (my_needs_value) {
362 value_buffer[count] = my_values[primary][ptr];
364 if (my_needs_index) {
365 index_buffer[count] = primary;
370 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
374 const ValueVectorStorage_& my_values;
375 sparse_utils::FullSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
376 bool my_needs_value, my_needs_index;
383template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
384class SecondaryMyopicBlockDense final :
public MyopicDenseExtractor<Value_, Index_> {
386 SecondaryMyopicBlockDense(
387 const ValueVectorStorage_& values,
388 const IndexVectorStorage_& indices,
389 const Index_ secondary,
390 const Index_ block_start,
391 const Index_ block_length
394 my_cache(make_ServeIndices<Index_>(indices), secondary, block_start, block_length)
397 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
398 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
401 [&](
const Index_ primary,
const Index_ index_primary,
const auto ptr) ->
void {
402 buffer[index_primary] = my_values[primary][ptr];
409 const ValueVectorStorage_& my_values;
410 sparse_utils::BlockSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
413template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
414class SecondaryMyopicBlockSparse final :
public MyopicSparseExtractor<Value_, Index_> {
416 SecondaryMyopicBlockSparse(
417 const ValueVectorStorage_& values,
418 const IndexVectorStorage_& indices,
419 const Index_ secondary,
420 const Index_ block_start,
421 const Index_ block_length,
425 my_cache(make_ServeIndices<Index_>(indices), secondary, block_start, block_length),
426 my_needs_value(opt.sparse_extract_value),
427 my_needs_index(opt.sparse_extract_index)
430 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
434 [&](
const Index_ primary,
const Index_,
const auto ptr) ->
void {
435 if (my_needs_value) {
436 value_buffer[count] = my_values[primary][ptr];
438 if (my_needs_index) {
439 index_buffer[count] = primary;
444 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
448 const ValueVectorStorage_& my_values;
449 sparse_utils::BlockSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
450 bool my_needs_value, my_needs_index;
457template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
458class SecondaryMyopicIndexDense final :
public MyopicDenseExtractor<Value_, Index_> {
460 SecondaryMyopicIndexDense(
461 const ValueVectorStorage_& values,
462 const IndexVectorStorage_& indices,
463 const Index_ secondary,
464 VectorPtr<Index_> indices_ptr
467 my_cache(make_ServeIndices<Index_>(indices), secondary, std::move(indices_ptr))
470 const Value_* fetch(
const Index_ i, Value_*
const buffer) {
471 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
474 [&](Index_ primary, Index_ index_primary,
auto ptr) ->
void {
475 buffer[index_primary] = my_values[primary][ptr];
482 const ValueVectorStorage_& my_values;
483 sparse_utils::IndexSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
486template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
487class SecondaryMyopicIndexSparse final :
public MyopicSparseExtractor<Value_, Index_> {
489 SecondaryMyopicIndexSparse(
490 const ValueVectorStorage_& values,
491 const IndexVectorStorage_& indices,
492 const Index_ secondary,
493 VectorPtr<Index_> indices_ptr,
497 my_cache(make_ServeIndices<Index_>(indices), secondary, std::move(indices_ptr)),
498 my_needs_value(opt.sparse_extract_value),
499 my_needs_index(opt.sparse_extract_index)
502 SparseRange<Value_, Index_> fetch(
const Index_ i, Value_*
const value_buffer, Index_*
const index_buffer) {
506 [&](
const Index_ primary,
const Index_,
const auto ptr) ->
void {
507 if (my_needs_value) {
508 value_buffer[count] = my_values[primary][ptr];
510 if (my_needs_index) {
511 index_buffer[count] = primary;
516 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
520 const ValueVectorStorage_& my_values;
521 sparse_utils::IndexSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
522 bool my_needs_value, my_needs_index;
568template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
583 ValueVectorStorage_ values,
584 IndexVectorStorage_ indices,
585 const bool row_sparse,
590 my_values(std::move(values)),
591 my_indices(std::move(indices)),
592 my_row_sparse(row_sparse)
595 if (my_values.size() != my_indices.size()) {
596 throw std::runtime_error(
"'values' and 'indices' should be of the same length");
600 if (!safe_non_negative_equal(my_indices.size(), my_nrow)) {
601 throw std::runtime_error(
"length of 'indices' should be equal to number of rows'");
604 if (!safe_non_negative_equal(my_indices.size(), my_ncol)) {
605 throw std::runtime_error(
"length of 'indices' should be equal to number of columns");
610 const auto num_indices = my_indices.size();
611 for (I<
decltype(num_indices)> i = 0; i < num_indices; ++i) {
612 const auto& curv = my_values[i];
613 const auto& curi = my_indices[i];
614 if (!safe_non_negative_equal(curv.size(), curi.size())) {
615 throw std::runtime_error(
"corresponding elements of 'values' and 'indices' should have the same length");
618 for (
const auto x : curi) {
619 if (x < 0 || x >= max_index) {
620 throw std::runtime_error(
"'indices' should contain non-negative integers less than the number of " + (my_row_sparse ? std::string(
"columns") : std::string(
"rows")));
624 const auto curnnz = curi.size();
625 for (I<
decltype(curnnz)> j = 1; j < curnnz; ++j) {
626 if (curi[j] <= curi[j - 1]) {
627 throw std::runtime_error(
"my_indices should be strictly increasing within each element of 'indices'");
634 sanisizer::can_ptrdiff<I<
decltype(curi.begin())> >(
static_cast<Index_
>(curnnz));
643 FragmentedSparseMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices,
bool row_sparse,
bool check =
true) :
644 FragmentedSparseMatrix(
651 FragmentedSparseMatrixOptions fopt;
662 Index_ my_nrow, my_ncol;
663 ValueVectorStorage_ my_values;
664 IndexVectorStorage_ my_indices;
668 Index_
nrow()
const {
return my_nrow; }
670 Index_
ncol()
const {
return my_ncol; }
682 using Matrix<Value_, Index_>::dense;
684 using Matrix<Value_, Index_>::sparse;
687 Index_ secondary()
const {
699 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
703 if (my_row_sparse == row) {
704 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicFullDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
705 my_values, my_indices, secondary()
708 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicFullDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
709 my_values, my_indices, secondary()
714 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
716 const Index_ block_start,
717 const Index_ block_end,
720 if (my_row_sparse == row) {
721 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicBlockDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
722 my_values, my_indices, secondary(), block_start, block_end
725 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicBlockDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
726 my_values, my_indices, secondary(), block_start, block_end
731 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
733 VectorPtr<Index_> subset_ptr,
736 if (my_row_sparse == row) {
737 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicIndexDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
738 my_values, my_indices, secondary(), std::move(subset_ptr)
741 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicIndexDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
742 my_values, my_indices, secondary(), std::move(subset_ptr)
751 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
755 if (my_row_sparse == row) {
756 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicFullSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
757 my_values, my_indices, secondary(), opt
760 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicFullSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
761 my_values, my_indices, secondary(), opt
766 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
768 const Index_ block_start,
769 const Index_ block_end,
772 if (my_row_sparse == row) {
773 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicBlockSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
774 my_values, my_indices, secondary(), block_start, block_end, opt
777 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicBlockSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
778 my_values, my_indices, secondary(), block_start, block_end, opt
783 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
785 VectorPtr<Index_> subset_ptr,
788 if (my_row_sparse == row) {
789 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicIndexSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
790 my_values, my_indices, secondary(), std::move(subset_ptr), opt
793 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicIndexSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
794 my_values, my_indices, secondary(), std::move(subset_ptr), opt
803 std::unique_ptr<OracularDenseExtractor<Value_, Index_> >
dense(
808 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, opt));
811 std::unique_ptr<OracularDenseExtractor<Value_, Index_> >
dense(
814 const Index_ block_start,
815 const Index_ block_end,
818 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, block_start, block_end, opt));
821 std::unique_ptr<OracularDenseExtractor<Value_, Index_> >
dense(
827 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, std::move(subset_ptr), opt));
834 std::unique_ptr<OracularSparseExtractor<Value_, Index_> >
sparse(
839 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, opt));
842 std::unique_ptr<OracularSparseExtractor<Value_, Index_> >
sparse(
845 const Index_ block_start,
846 const Index_ block_end,
849 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, block_start, block_end, opt));
852 std::unique_ptr<OracularSparseExtractor<Value_, Index_> >
sparse(
858 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, std::move(subset_ptr), opt));
867template<
typename Value_,
typename Index_,
class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
class IndexVectorStorage_ = std::vector<std::vector<Index_> > >
878 FragmentedSparseMatrix<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_>(nrow, ncol, std::move(values), std::move(indices), false, check) {}
886template<
typename Value_,
typename Index_,
class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
class IndexVectorStorage_ = std::vector<std::vector<Index_> > >
897 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:868
FragmentedSparseColumnMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool check=true)
Definition FragmentedSparseMatrix.hpp:877
Fragmented sparse matrix representation.
Definition FragmentedSparseMatrix.hpp:569
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:834
FragmentedSparseMatrix(const Index_ nrow, const Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, const bool row_sparse, const FragmentedSparseMatrixOptions &options)
Definition FragmentedSparseMatrix.hpp:580
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:811
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:821
Index_ ncol() const
Definition FragmentedSparseMatrix.hpp:670
double prefer_rows_proportion() const
Definition FragmentedSparseMatrix.hpp:678
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:852
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:842
double is_sparse_proportion() const
Definition FragmentedSparseMatrix.hpp:674
Index_ nrow() const
Definition FragmentedSparseMatrix.hpp:668
bool is_sparse() const
Definition FragmentedSparseMatrix.hpp:672
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:803
bool prefer_rows() const
Definition FragmentedSparseMatrix.hpp:676
bool uses_oracle(const bool) const
Definition FragmentedSparseMatrix.hpp:680
Fragmented sparse row matrix.
Definition FragmentedSparseMatrix.hpp:887
FragmentedSparseRowMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool check=true)
Definition FragmentedSparseMatrix.hpp:896
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:533
bool check
Definition FragmentedSparseMatrix.hpp:544
Options for accessing data from a Matrix instance.
Definition Options.hpp:30