1#ifndef TATAMI_FRAGMENTED_SPARSE_MATRIX_H
2#define TATAMI_FRAGMENTED_SPARSE_MATRIX_H
5#include "primary_extraction.hpp"
6#include "secondary_extraction.hpp"
28namespace FragmentedSparseMatrix_internal {
34template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
35class PrimaryMyopicFullDense final :
public MyopicDenseExtractor<Value_, Index_> {
37 PrimaryMyopicFullDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary) :
38 my_values(values), my_indices(indices), my_secondary(secondary) {}
40 const Value_* fetch(Index_ i, Value_* buffer) {
41 const auto& curv = my_values[i];
42 const auto& curi = my_indices[i];
44 std::fill_n(buffer, my_secondary,
static_cast<Value_
>(0));
45 for (
decltype(curv.size()) x = 0, end = curv.size(); 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 final :
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<decltype(curv.size())
>(0), curv.size(), vbuffer);
72 output.index = sparse_utils::extract_primary_vector(curi,
static_cast<decltype(curi.size())
>(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 final :
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 auto start_pos = (iStart - curi.begin());
101 auto end_pos = (iEnd - curi.begin());
103 std::fill_n(buffer, my_block_length,
static_cast<Value_
>(0));
104 for (
auto x = start_pos; x < end_pos; ++x) {
105 buffer[curi[x] - my_block_start] = curv[x];
111 const ValueVectorStorage_& my_values;
112 const IndexVectorStorage_& my_indices;
114 Index_ my_block_start, my_block_length;
117template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
118class PrimaryMyopicBlockSparse final :
public MyopicSparseExtractor<Value_, Index_> {
120 PrimaryMyopicBlockSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length,
const Options& opt) :
123 my_secondary(secondary),
124 my_block_start(block_start),
125 my_block_length(block_length),
126 my_needs_value(opt.sparse_extract_value),
127 my_needs_index(opt.sparse_extract_index)
130 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
131 const auto& curi = my_indices[i];
132 auto iStart = curi.begin();
133 auto iEnd = curi.end();
134 sparse_utils::refine_primary_block_limits(iStart, iEnd, my_secondary, my_block_start, my_block_length);
135 auto offset = iStart - curi.begin();
136 auto delta = iEnd - iStart;
138 SparseRange<Value_, Index_> output(delta, NULL, NULL);
139 if (my_needs_value) {
140 output.value = sparse_utils::extract_primary_vector(my_values[i], offset, delta, vbuffer);
142 if (my_needs_index) {
143 output.index = sparse_utils::extract_primary_vector(curi, offset, delta, index_buffer);
149 const ValueVectorStorage_& my_values;
150 const IndexVectorStorage_& my_indices;
152 Index_ my_block_start, my_block_length;
153 bool my_needs_value, my_needs_index;
160template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
161class PrimaryMyopicIndexDense final :
public MyopicDenseExtractor<Value_, Index_> {
163 PrimaryMyopicIndexDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr) :
164 my_values(values), my_indices(indices), my_retriever(*indices_ptr, secondary), my_num_indices(indices_ptr->size()) {}
166 const Value_* fetch(Index_ i, Value_* buffer) {
167 const auto& curi = my_indices[i];
168 const auto& curv = my_values[i];
169 std::fill_n(buffer, my_num_indices,
static_cast<Value_
>(0));
170 my_retriever.populate(
173 [&](
auto s,
auto offset) ->
void {
174 buffer[s] = curv[offset];
181 const ValueVectorStorage_& my_values;
182 const IndexVectorStorage_& my_indices;
183 sparse_utils::RetrievePrimarySubsetDense<Index_> my_retriever;
184 std::size_t my_num_indices;
187template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
188class PrimaryMyopicIndexSparse final :
public MyopicSparseExtractor<Value_, Index_> {
190 PrimaryMyopicIndexSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr,
const Options& opt) :
191 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) {}
193 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
194 const auto& curi = my_indices[i];
195 const auto& curv = my_values[i];
197 auto vcopy = vbuffer;
198 auto icopy = index_buffer;
200 my_retriever.populate(
203 [&](
auto offset,
auto ix) ->
void {
205 if (my_needs_value) {
206 *vcopy = curv[offset];
209 if (my_needs_index) {
216 return SparseRange<Value_, Index_>(count, my_needs_value ? vbuffer : NULL, my_needs_index ? index_buffer : NULL);
220 const ValueVectorStorage_& my_values;
221 const IndexVectorStorage_& my_indices;
222 sparse_utils::RetrievePrimarySubsetSparse<Index_> my_retriever;
223 bool my_needs_value, my_needs_index;
230template<
typename Index_,
class IndexVectorStorage_>
233 ServeIndices(
const IndexVectorStorage_& indices) : my_indices(indices) {}
236 const IndexVectorStorage_& my_indices;
239 typedef decltype(std::declval<IndexVectorStorage_>()[0].size()) pointer_type;
241 pointer_type start_offset(Index_)
const {
245 pointer_type end_offset(Index_ primary)
const {
246 return my_indices[primary].size();
249 auto raw(Index_ primary)
const {
250 return my_indices[primary].begin();
254template<
typename Index_,
class IndexVectorStorage_>
255auto make_ServeIndices(
const IndexVectorStorage_& i) {
256 return ServeIndices<Index_, IndexVectorStorage_>(i);
259template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
260class SecondaryMyopicFullDense final :
public MyopicDenseExtractor<Value_, Index_> {
262 SecondaryMyopicFullDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary) :
263 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, indices.size()) {}
265 const Value_* fetch(Index_ i, Value_* buffer) {
266 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
269 [&](Index_ primary, Index_ index_primary,
auto ptr) ->
void {
270 buffer[index_primary] = my_values[primary][ptr];
277 const ValueVectorStorage_& my_values;
278 sparse_utils::FullSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
281template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
282class SecondaryMyopicFullSparse final :
public MyopicSparseExtractor<Value_, Index_> {
284 SecondaryMyopicFullSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary,
const Options& opt) :
285 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) {}
287 SparseRange<Value_, Index_> fetch(Index_ i, Value_* value_buffer, Index_* index_buffer) {
291 [&](Index_ primary, Index_,
auto ptr) ->
void {
292 if (my_needs_value) {
293 value_buffer[count] = my_values[primary][ptr];
295 if (my_needs_index) {
296 index_buffer[count] = primary;
301 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
305 const ValueVectorStorage_& my_values;
306 sparse_utils::FullSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
307 bool my_needs_value, my_needs_index;
314template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
315class SecondaryMyopicBlockDense final :
public MyopicDenseExtractor<Value_, Index_> {
317 SecondaryMyopicBlockDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length) :
318 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, block_start, block_length) {}
320 const Value_* fetch(Index_ i, Value_* buffer) {
321 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
324 [&](Index_ primary, Index_ index_primary,
auto ptr) ->
void {
325 buffer[index_primary] = my_values[primary][ptr];
332 const ValueVectorStorage_& my_values;
333 sparse_utils::BlockSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
336template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
337class SecondaryMyopicBlockSparse final :
public MyopicSparseExtractor<Value_, Index_> {
339 SecondaryMyopicBlockSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, Index_ block_start, Index_ block_length,
const Options& opt) :
340 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) {}
342 SparseRange<Value_, Index_> fetch(Index_ i, Value_* value_buffer, Index_* index_buffer) {
346 [&](Index_ primary, Index_,
auto ptr) ->
void {
347 if (my_needs_value) {
348 value_buffer[count] = my_values[primary][ptr];
350 if (my_needs_index) {
351 index_buffer[count] = primary;
356 return SparseRange<Value_, Index_>(count, my_needs_value ? value_buffer : NULL, my_needs_index ? index_buffer : NULL);
360 const ValueVectorStorage_& my_values;
361 sparse_utils::BlockSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
362 bool my_needs_value, my_needs_index;
369template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
370class SecondaryMyopicIndexDense final :
public MyopicDenseExtractor<Value_, Index_> {
372 SecondaryMyopicIndexDense(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr) :
373 my_values(values), my_cache(make_ServeIndices<Index_>(indices), secondary, std::move(indices_ptr)) {}
375 const Value_* fetch(Index_ i, Value_* buffer) {
376 std::fill_n(buffer, my_cache.size(),
static_cast<Value_
>(0));
379 [&](Index_ primary, Index_ index_primary,
auto ptr) ->
void {
380 buffer[index_primary] = my_values[primary][ptr];
387 const ValueVectorStorage_& my_values;
388 sparse_utils::IndexSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
391template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
392class SecondaryMyopicIndexSparse final :
public MyopicSparseExtractor<Value_, Index_> {
394 SecondaryMyopicIndexSparse(
const ValueVectorStorage_& values,
const IndexVectorStorage_& indices, Index_ secondary, VectorPtr<Index_> indices_ptr,
const Options& opt) :
395 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) {}
397 SparseRange<Value_, Index_> fetch(Index_ i, Value_* vbuffer, Index_* index_buffer) {
401 [&](Index_ primary, Index_,
auto ptr) ->
void {
402 if (my_needs_value) {
403 vbuffer[count] = my_values[primary][ptr];
405 if (my_needs_index) {
406 index_buffer[count] = primary;
411 return SparseRange<Value_, Index_>(count, my_needs_value ? vbuffer : NULL, my_needs_index ? index_buffer : NULL);
415 const ValueVectorStorage_& my_values;
416 sparse_utils::IndexSecondaryExtractionCache<Index_, ServeIndices<Index_, IndexVectorStorage_> > my_cache;
417 bool my_needs_value, my_needs_index;
463template<
typename Value_,
typename Index_,
class ValueVectorStorage_,
class IndexVectorStorage_>
476 my_nrow(nrow), my_ncol(ncol), my_values(std::move(values)), my_indices(std::move(indices)), my_row_sparse(row_sparse)
479 if (my_values.size() != my_indices.size()) {
480 throw std::runtime_error(
"'values' and 'indices' should be of the same length");
485 throw std::runtime_error(
"length of 'indices' should be equal to number of rows'");
489 throw std::runtime_error(
"length of 'indices' should be equal to number of columns");
494 for (
decltype(my_indices.size()) i = 0, end = my_indices.size(); i < end; ++i) {
495 const auto& curv = my_values[i];
496 const auto& curi = my_indices[i];
497 if (!safe_non_negative_equal(curv.size(), curi.size())) {
498 throw std::runtime_error(
"corresponding elements of 'values' and 'indices' should have the same length");
501 for (
auto x : curi) {
502 if (x < 0 || x >= max_index) {
503 throw std::runtime_error(
"'indices' should contain non-negative integers less than the number of " + (my_row_sparse ? std::string(
"columns") : std::string(
"rows")));
507 for (
decltype(curi.size()) j = 1, jend = curi.size(); j < jend; ++j) {
508 if (curi[j] <= curi[j - 1]) {
509 throw std::runtime_error(
"my_indices should be strictly increasing within each element of 'indices'");
520 FragmentedSparseMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices,
bool row_sparse,
bool check =
true) :
521 FragmentedSparseMatrix(
528 FragmentedSparseMatrixOptions fopt;
539 Index_ my_nrow, my_ncol;
540 ValueVectorStorage_ my_values;
541 IndexVectorStorage_ my_indices;
545 Index_
nrow()
const {
return my_nrow; }
547 Index_
ncol()
const {
return my_ncol; }
559 using Matrix<Value_, Index_>::dense;
561 using Matrix<Value_, Index_>::sparse;
564 Index_ secondary()
const {
576 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
bool row,
const Options&)
const {
577 if (my_row_sparse == row) {
578 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicFullDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
579 my_values, my_indices, secondary()
582 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicFullDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
583 my_values, my_indices, secondary()
588 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
bool row, Index_ block_start, Index_ block_end,
const Options&)
const {
589 if (my_row_sparse == row) {
590 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicBlockDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
591 my_values, my_indices, secondary(), block_start, block_end
594 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicBlockDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
595 my_values, my_indices, secondary(), block_start, block_end
600 std::unique_ptr<MyopicDenseExtractor<Value_, Index_> > dense(
bool row, VectorPtr<Index_> subset_ptr,
const Options&)
const {
601 if (my_row_sparse == row) {
602 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicIndexDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
603 my_values, my_indices, secondary(), std::move(subset_ptr)
606 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicIndexDense<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
607 my_values, my_indices, secondary(), std::move(subset_ptr)
616 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
bool row,
const Options& opt)
const {
617 if (my_row_sparse == row) {
618 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicFullSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
619 my_values, my_indices, secondary(), opt
622 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicFullSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
623 my_values, my_indices, secondary(), opt
628 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
bool row, Index_ block_start, Index_ block_end,
const Options& opt)
const {
629 if (my_row_sparse == row) {
630 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicBlockSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
631 my_values, my_indices, secondary(), block_start, block_end, opt
634 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicBlockSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
635 my_values, my_indices, secondary(), block_start, block_end, opt
640 std::unique_ptr<MyopicSparseExtractor<Value_, Index_> > sparse(
bool row, VectorPtr<Index_> subset_ptr,
const Options& opt)
const {
641 if (my_row_sparse == row) {
642 return std::make_unique<FragmentedSparseMatrix_internal::PrimaryMyopicIndexSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
643 my_values, my_indices, secondary(), std::move(subset_ptr), opt
646 return std::make_unique<FragmentedSparseMatrix_internal::SecondaryMyopicIndexSparse<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_> >(
647 my_values, my_indices, secondary(), std::move(subset_ptr), opt
656 std::unique_ptr<OracularDenseExtractor<Value_, Index_> >
dense(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
657 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, opt));
660 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 {
661 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, block_start, block_end, opt));
665 return std::make_unique<PseudoOracularDenseExtractor<Value_, Index_> >(std::move(oracle), dense(row, std::move(subset_ptr), opt));
672 std::unique_ptr<OracularSparseExtractor<Value_, Index_> >
sparse(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
673 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, opt));
676 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 {
677 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, block_start, block_end, opt));
681 return std::make_unique<PseudoOracularSparseExtractor<Value_, Index_> >(std::move(oracle), sparse(row, std::move(subset_ptr), opt));
690template<
typename Value_,
typename Index_,
class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
class IndexVectorStorage_ = std::vector<std::vector<Index_> > >
701 FragmentedSparseMatrix<Value_, Index_, ValueVectorStorage_, IndexVectorStorage_>(nrow, ncol, std::move(values), std::move(indices), false, check) {}
709template<
typename Value_,
typename Index_,
class ValueVectorStorage_ = std::vector<std::vector<Value_> >,
class IndexVectorStorage_ = std::vector<std::vector<Index_> > >
720 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:691
FragmentedSparseColumnMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool check=true)
Definition FragmentedSparseMatrix.hpp:700
Fragmented sparse matrix representation.
Definition FragmentedSparseMatrix.hpp:464
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:656
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:680
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition FragmentedSparseMatrix.hpp:672
FragmentedSparseMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool row_sparse, const FragmentedSparseMatrixOptions &options)
Definition FragmentedSparseMatrix.hpp:475
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:676
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:660
Index_ ncol() const
Definition FragmentedSparseMatrix.hpp:547
double prefer_rows_proportion() const
Definition FragmentedSparseMatrix.hpp:555
bool uses_oracle(bool) const
Definition FragmentedSparseMatrix.hpp:557
double is_sparse_proportion() const
Definition FragmentedSparseMatrix.hpp:551
Index_ nrow() const
Definition FragmentedSparseMatrix.hpp:545
bool is_sparse() const
Definition FragmentedSparseMatrix.hpp:549
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:664
bool prefer_rows() const
Definition FragmentedSparseMatrix.hpp:553
Fragmented sparse row matrix.
Definition FragmentedSparseMatrix.hpp:710
FragmentedSparseRowMatrix(Index_ nrow, Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, bool check=true)
Definition FragmentedSparseMatrix.hpp:719
Virtual class for a matrix.
Definition Matrix.hpp:59
Predict future access requests on the target dimension.
Definition Oracle.hpp:23
Flexible representations for matrix data.
Definition Extractor.hpp:15
std::shared_ptr< const std::vector< Index_ > > VectorPtr
Definition Matrix.hpp:26
bool safe_non_negative_equal(Left_ l, Right_ r)
Definition integer_comparisons.hpp:23
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:428
bool check
Definition FragmentedSparseMatrix.hpp:439
Options for accessing data from a Matrix instance.
Definition Options.hpp:30