1#ifndef TATAMI_DELAYED_BINARY_ISOMETRIC_OPERATION_H
2#define TATAMI_DELAYED_BINARY_ISOMETRIC_OPERATION_H
7#include "../../utils/Index_to_container.hpp"
9#include "../depends_utils.hpp"
28namespace DelayedBinaryIsometricOperation_internal {
34template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
35class DenseSimpleFull final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
38 const Matrix<InputValue_, Index_>& left,
39 const Matrix<InputValue_, Index_>& right,
40 const Helper_& helper,
42 MaybeOracle<oracle_, Index_> oracle,
46 my_oracle(oracle, my_helper, row)
48 my_left_ext = new_extractor<false, oracle_>(left, my_row, oracle, opt);
49 my_right_ext = new_extractor<false, oracle_>(right, my_row, std::move(oracle), opt);
50 my_extent = my_row ? left.ncol() : left.nrow();
53 if constexpr(!same_value) {
54 my_left_holding_buffer.resize(my_right_holding_buffer.size());
58 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
59 auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
61 if constexpr(same_value) {
62 auto lptr = my_left_ext->fetch(i, buffer);
63 copy_n(lptr, my_extent, buffer);
64 my_helper.dense(my_row, my_oracle.get(i),
static_cast<Index_
>(0), my_extent, buffer, rptr, buffer);
66 auto lptr = my_left_ext->fetch(i, my_left_holding_buffer.data());
67 my_helper.dense(my_row, my_oracle.get(i),
static_cast<Index_
>(0), my_extent, lptr, rptr, buffer);
74 const Helper_& my_helper;
76 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
78 std::unique_ptr<DenseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
80 std::vector<InputValue_> my_right_holding_buffer;
82 static constexpr bool same_value = std::is_same<OutputValue_, InputValue_>::value;
83 typename std::conditional<!same_value, std::vector<InputValue_>,
bool>::type my_left_holding_buffer;
86template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
87class DenseSimpleBlock final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
90 const Matrix<InputValue_, Index_>& left,
91 const Matrix<InputValue_, Index_>& right,
92 const Helper_& helper,
94 MaybeOracle<oracle_, Index_> oracle,
100 my_oracle(oracle, my_helper, row),
101 my_block_start(block_start),
102 my_block_length(block_length)
104 my_left_ext = new_extractor<false, oracle_>(left, my_row, oracle, my_block_start, my_block_length, opt);
105 my_right_ext = new_extractor<false, oracle_>(right, my_row, std::move(oracle), my_block_start, my_block_length, opt);
108 if constexpr(!same_value) {
109 my_left_holding_buffer.resize(my_right_holding_buffer.size());
113 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
114 auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
116 if constexpr(same_value) {
117 auto lptr = my_left_ext->fetch(i, buffer);
118 copy_n(lptr, my_block_length, buffer);
119 my_helper.dense(my_row, my_oracle.get(i), my_block_start, my_block_length, buffer, rptr, buffer);
121 auto lptr = my_left_ext->fetch(i, my_left_holding_buffer.data());
122 my_helper.dense(my_row, my_oracle.get(i), my_block_start, my_block_length, lptr, rptr, buffer);
129 const Helper_& my_helper;
131 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
133 Index_ my_block_start, my_block_length;
134 std::unique_ptr<DenseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
135 std::vector<InputValue_> my_right_holding_buffer;
137 static constexpr bool same_value = std::is_same<OutputValue_, InputValue_>::value;
138 typename std::conditional<!same_value, std::vector<InputValue_>,
bool>::type my_left_holding_buffer;
141template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
142class DenseSimpleIndex final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
145 const Matrix<InputValue_, Index_>& left,
146 const Matrix<InputValue_, Index_>& right,
147 const Helper_& helper,
149 MaybeOracle<oracle_, Index_> oracle,
150 VectorPtr<Index_> indices_ptr,
151 const Options& opt) :
154 my_oracle(oracle, my_helper, row),
155 my_indices_ptr(std::move(indices_ptr))
157 my_left_ext = new_extractor<false, oracle_>(left, my_row, oracle, my_indices_ptr, opt);
158 my_right_ext = new_extractor<false, oracle_>(right, my_row, std::move(oracle), my_indices_ptr, opt);
161 if constexpr(!same_value) {
162 my_left_holding_buffer.resize(my_right_holding_buffer.size());
166 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
167 auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
168 const auto& indices = *my_indices_ptr;
170 if constexpr(same_value) {
171 auto lptr = my_left_ext->fetch(i, buffer);
172 copy_n(lptr, indices.size(), buffer);
173 my_helper.dense(my_row, my_oracle.get(i), indices, buffer, rptr, buffer);
175 auto lptr = my_left_ext->fetch(i, my_left_holding_buffer.data());
176 my_helper.dense(my_row, my_oracle.get(i), indices, lptr, rptr, buffer);
183 const Helper_& my_helper;
185 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
187 VectorPtr<Index_> my_indices_ptr;
188 std::unique_ptr<DenseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
189 std::vector<InputValue_> my_right_holding_buffer;
191 static constexpr bool same_value = std::is_same<OutputValue_, InputValue_>::value;
192 typename std::conditional<!same_value, std::vector<InputValue_>,
bool>::type my_left_holding_buffer;
199template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
200class DenseExpandedFull final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
203 const Matrix<InputValue_, Index_>& left,
204 const Matrix<InputValue_, Index_>& right,
205 const Helper_& helper,
207 MaybeOracle<oracle_, Index_> oracle,
211 my_oracle(oracle, my_helper, row)
213 opt.sparse_extract_value =
true;
214 opt.sparse_extract_index =
true;
215 opt.sparse_ordered_index =
true;
216 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, opt);
217 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), opt);
218 my_extent = my_row ? left.ncol() : left.nrow();
221 my_right_vbuffer.resize(my_left_vbuffer.size());
226 my_right_ibuffer.resize(my_left_ibuffer.size());
227 my_output_ibuffer.resize(my_left_ibuffer.size());
230 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
231 auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
232 auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
234 i = my_oracle.get(i);
235 auto num = my_helper.sparse(my_row, i, lres, rres, my_output_vbuffer.data(), my_output_ibuffer.data(),
true,
true);
239 if (num < my_extent) {
240 std::fill_n(buffer, my_extent, my_helper.fill(my_row, i));
243 for (Index_ j = 0; j < num; ++j) {
244 buffer[my_output_ibuffer[j]] = my_output_vbuffer[j];
250 const Helper_& my_helper;
252 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
254 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
257 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
258 std::vector<OutputValue_> my_output_vbuffer;
259 std::vector<Index_> my_left_ibuffer, my_right_ibuffer, my_output_ibuffer;
262template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
263class DenseExpandedBlock final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
266 const Matrix<InputValue_, Index_>& left,
267 const Matrix<InputValue_, Index_>& right,
268 const Helper_& helper,
270 MaybeOracle<oracle_, Index_> oracle,
276 my_oracle(oracle, my_helper, row),
277 my_block_start(block_start),
278 my_block_length(block_length)
280 opt.sparse_extract_value =
true;
281 opt.sparse_extract_index =
true;
282 opt.sparse_ordered_index =
true;
283 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, my_block_start, my_block_length, opt);
284 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), my_block_start, my_block_length, opt);
287 my_right_vbuffer.resize(my_left_vbuffer.size());
292 my_right_ibuffer.resize(my_left_ibuffer.size());
293 my_output_ibuffer.resize(my_left_ibuffer.size());
296 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
297 auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
298 auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
300 i = my_oracle.get(i);
301 auto num = my_helper.sparse(my_row, i, lres, rres, my_output_vbuffer.data(), my_output_ibuffer.data(),
true,
true);
305 if (num < my_block_length) {
306 std::fill_n(buffer, my_block_length, my_helper.fill(my_row, i));
309 for (Index_ j = 0; j < num; ++j) {
310 buffer[my_output_ibuffer[j] - my_block_start] = my_output_vbuffer[j];
316 const Helper_& my_helper;
318 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
319 Index_ my_block_start, my_block_length;
321 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
323 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
324 std::vector<OutputValue_> my_output_vbuffer;
325 std::vector<Index_> my_left_ibuffer, my_right_ibuffer, my_output_ibuffer;
328template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
329class DenseExpandedIndex final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
332 const Matrix<InputValue_, Index_>& left,
333 const Matrix<InputValue_, Index_>& right,
334 const Helper_& helper,
336 MaybeOracle<oracle_, Index_> oracle,
337 VectorPtr<Index_> indices_ptr,
341 my_oracle(oracle, my_helper, row),
342 my_extent(indices_ptr->size())
347 const auto& indices = *indices_ptr;
349 my_remapping_offset = indices.front();
351 for (Index_ i = 0; i < my_extent; ++i) {
352 my_remapping[indices[i] - my_remapping_offset] = i;
356 opt.sparse_extract_value =
true;
357 opt.sparse_extract_index =
true;
358 opt.sparse_ordered_index =
true;
359 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, indices_ptr, opt);
360 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), std::move(indices_ptr), opt);
363 my_right_vbuffer.resize(my_left_vbuffer.size());
368 my_right_ibuffer.resize(my_left_ibuffer.size());
369 my_output_ibuffer.resize(my_left_ibuffer.size());
372 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
373 auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
374 auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
376 i = my_oracle.get(i);
377 auto num = my_helper.sparse(my_row, i, lres, rres, my_output_vbuffer.data(), my_output_ibuffer.data(),
true,
true);
381 if (num < my_extent) {
382 std::fill_n(buffer, my_extent, my_helper.fill(my_row, i));
385 for (Index_ j = 0; j < num; ++j) {
386 buffer[my_remapping[my_output_ibuffer[j] - my_remapping_offset]] = my_output_vbuffer[j];
392 const Helper_& my_helper;
394 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
397 std::vector<Index_> my_remapping;
398 Index_ my_remapping_offset = 0;
400 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
402 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
403 std::vector<OutputValue_> my_output_vbuffer;
404 std::vector<Index_> my_left_ibuffer, my_right_ibuffer, my_output_ibuffer;
411template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
412class Sparse final :
public SparseExtractor<oracle_, OutputValue_, Index_> {
415 const Matrix<InputValue_, Index_>& left,
416 const Matrix<InputValue_, Index_>& right,
417 const Helper_& helper,
419 MaybeOracle<oracle_, Index_> oracle,
423 my_oracle(oracle, my_helper, row)
425 initialize(my_row ? left.ncol() : left.nrow(), opt);
426 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, opt);
427 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), opt);
431 const Matrix<InputValue_, Index_>& left,
432 const Matrix<InputValue_, Index_>& right,
433 const Helper_& helper,
435 MaybeOracle<oracle_, Index_> oracle,
441 my_oracle(oracle, my_helper, row)
443 initialize(block_length, opt);
444 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, block_start, block_length, opt);
445 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), block_start, block_length, opt);
449 const Matrix<InputValue_, Index_>& left,
450 const Matrix<InputValue_, Index_>& right,
451 const Helper_& helper,
453 MaybeOracle<oracle_, Index_> oracle,
454 VectorPtr<Index_> indices_ptr,
458 my_oracle(oracle, my_helper, row)
460 initialize(indices_ptr->size(), opt);
461 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, indices_ptr, opt);
462 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), std::move(indices_ptr), opt);
466 void initialize(std::size_t extent, Options& opt) {
467 my_report_value = opt.sparse_extract_value;
468 my_report_index = opt.sparse_extract_index;
471 my_right_ibuffer.resize(my_left_ibuffer.size());
473 if (my_report_value) {
475 my_right_vbuffer.resize(my_left_vbuffer.size());
478 opt.sparse_ordered_index =
true;
479 opt.sparse_extract_index =
true;
483 SparseRange<OutputValue_, Index_> fetch(Index_ i, OutputValue_* value_buffer, Index_* index_buffer) {
484 auto left_ranges = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
485 auto right_ranges = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
486 auto num = my_helper.sparse(
499 (my_report_value ? value_buffer: NULL),
500 (my_report_index ? index_buffer: NULL)
505 const Helper_& my_helper;
507 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
509 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
510 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
511 std::vector<Index_> my_left_ibuffer, my_right_ibuffer;
513 bool my_report_value =
false;
514 bool my_report_index =
false;
539 typename OutputValue_,
540 typename InputValue_,
542 class Helper_ = DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>
554 std::shared_ptr<const Helper_> helper
556 my_left(std::move(left)), my_right(std::move(right)), my_helper(std::move(helper))
558 auto NR = my_left->nrow();
559 auto NC = my_left->ncol();
560 if (NR != my_right->nrow() || NC != my_right->ncol()) {
561 throw std::runtime_error(
"shape of the left and right matrices should be the same");
564 auto expected_rows = my_helper->nrow();
565 if (expected_rows.has_value() && *expected_rows != NR) {
566 throw std::runtime_error(
"number of matrix rows is not consistent with those expected by 'helper'");
568 auto expected_cols = my_helper->ncol();
569 if (expected_cols.has_value() && *expected_cols != NC) {
570 throw std::runtime_error(
"number of matrix columns is not consistent with those expected by 'helper'");
573 my_prefer_rows_proportion = (my_left->prefer_rows_proportion() + my_right->prefer_rows_proportion()) / 2;
575 if (my_helper->is_sparse()) {
576 my_is_sparse = my_left->is_sparse() && my_right->is_sparse();
579 my_is_sparse_proportion = (my_left->is_sparse_proportion() + my_right->is_sparse_proportion())/2;
584 std::shared_ptr<const Matrix<InputValue_, Index_> > my_left, my_right;
585 std::shared_ptr<const Helper_> my_helper;
587 double my_prefer_rows_proportion;
588 double my_is_sparse_proportion = 0;
589 bool my_is_sparse =
false;
593 return my_left->nrow();
597 return my_left->ncol();
605 return my_is_sparse_proportion;
609 return my_prefer_rows_proportion > 0.5;
613 return my_prefer_rows_proportion;
617 return my_left->uses_oracle(row) || my_right->uses_oracle(row);
628 template<
bool oracle_>
630 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleFull<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
640 template<
bool oracle_>
641 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_simple_internal(
bool row,
MaybeOracle<oracle_, Index_> oracle, Index_ block_start, Index_ block_length,
const Options& opt)
const {
642 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleBlock<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
654 template<
bool oracle_>
656 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleIndex<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
662 std::move(indices_ptr),
667 template<
bool oracle_>
668 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_expanded_internal(
bool row,
MaybeOracle<oracle_, Index_> oracle,
const Options& opt)
const {
669 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedFull<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
679 template<
bool oracle_>
680 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_expanded_internal(
bool row,
MaybeOracle<oracle_, Index_> oracle, Index_ block_start, Index_ block_length,
const Options& opt)
const {
681 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedBlock<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
693 template<
bool oracle_>
695 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedIndex<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
701 std::move(indices_ptr),
706 template<
bool oracle_,
typename ... Args_>
707 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_internal(
bool row, Args_&& ... args)
const {
709 if (DelayedIsometricOperation_internal::can_dense_expand(*my_helper, row)) {
710 return dense_expanded_internal<oracle_>(row, std::forward<Args_>(args)...);
714 return dense_simple_internal<oracle_>(row, std::forward<Args_>(args)...);
718 std::unique_ptr<MyopicDenseExtractor<OutputValue_, Index_> >
dense(
bool row,
const Options& opt)
const {
719 return dense_internal<false>(row,
false, opt);
722 std::unique_ptr<MyopicDenseExtractor<OutputValue_, Index_> >
dense(
bool row, Index_ block_start, Index_ block_length,
const Options& opt)
const {
723 return dense_internal<false>(row,
false, block_start, block_length, opt);
727 return dense_internal<false>(row,
false, std::move(indices_ptr), opt);
734 template<
bool oracle_>
737 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
747 return std::make_unique<FullSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
748 dense_internal<oracle_>(row, std::move(oracle), opt),
749 row ? my_left->ncol() : my_left->nrow(),
754 template<
bool oracle_>
755 std::unique_ptr<SparseExtractor<oracle_, OutputValue_, Index_> > sparse_internal(
bool row,
MaybeOracle<oracle_, Index_> oracle, Index_ block_start, Index_ block_length,
const Options& opt)
const {
757 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
769 return std::make_unique<BlockSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
770 dense_internal<oracle_>(row, std::move(oracle), block_start, block_length, opt),
777 template<
bool oracle_>
780 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
786 std::move(indices_ptr),
791 return std::make_unique<IndexSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
792 dense_internal<oracle_>(row, std::move(oracle), indices_ptr, opt),
799 std::unique_ptr<MyopicSparseExtractor<OutputValue_, Index_> >
sparse(
bool row,
const Options& opt)
const {
800 return sparse_internal<false>(row,
false, opt);
803 std::unique_ptr<MyopicSparseExtractor<OutputValue_, Index_> >
sparse(
bool row, Index_ block_start, Index_ block_length,
const Options& opt)
const {
804 return sparse_internal<false>(row,
false, block_start, block_length, opt);
808 return sparse_internal<false>(row,
false, std::move(indices_ptr), opt);
815 std::unique_ptr<OracularDenseExtractor<OutputValue_, Index_> >
dense(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
816 return dense_internal<true>(row, std::move(oracle), opt);
819 std::unique_ptr<OracularDenseExtractor<OutputValue_, Index_> >
dense(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle, Index_ block_start, Index_ block_length,
const Options& opt)
const {
820 return dense_internal<true>(row, std::move(oracle), block_start, block_length, opt);
824 return dense_internal<true>(row, std::move(oracle), std::move(indices_ptr), opt);
831 std::unique_ptr<OracularSparseExtractor<OutputValue_, Index_> >
sparse(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
832 return sparse_internal<true>(row, std::move(oracle), opt);
835 std::unique_ptr<OracularSparseExtractor<OutputValue_, Index_> >
sparse(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle, Index_ block_start, Index_ block_length,
const Options& opt)
const {
836 return sparse_internal<true>(row, std::move(oracle), block_start, block_length, opt);
840 return sparse_internal<true>(row, std::move(oracle), std::move(indices_ptr), opt);
848template<
typename OutputValue_ =
double,
typename InputValue_,
typename Index_,
class Helper_>
849std::shared_ptr<Matrix<OutputValue_, Index_> > make_DelayedBinaryIsometricOperation(
850 std::shared_ptr<
const Matrix<InputValue_, Index_> > left,
851 std::shared_ptr<
const Matrix<InputValue_, Index_> > right,
852 std::shared_ptr<const Helper_> op)
854 return std::make_shared<DelayedBinaryIsometricOperation<OutputValue_, InputValue_, Index_, Helper_> >(std::move(left), std::move(right), std::move(op));
857template<
typename OutputValue_ =
double,
typename InputValue_,
typename Index_,
class Helper_>
858std::shared_ptr<Matrix<OutputValue_, Index_> > make_DelayedBinaryIsometricOperation(
859 std::shared_ptr<Matrix<InputValue_, Index_> > left,
860 std::shared_ptr<Matrix<InputValue_, Index_> > right,
861 std::shared_ptr<Helper_> op)
863 return std::make_shared<DelayedBinaryIsometricOperation<OutputValue_, InputValue_, Index_, Helper_> >(std::move(left), std::move(right), std::move(op));
Virtual class for a matrix of some numeric type.
Wrapper classes for sparse extraction from a dense tatami::Matrix.
Interface for tatami::DelayedBinaryIsometricOperation helpers.
Delayed isometric operations on two matrices.
Definition DelayedBinaryIsometricOperation.hpp:544
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(bool row, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:803
std::unique_ptr< OracularSparseExtractor< OutputValue_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:839
double prefer_rows_proportion() const
Definition DelayedBinaryIsometricOperation.hpp:612
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:726
std::unique_ptr< OracularDenseExtractor< OutputValue_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:823
double is_sparse_proportion() const
Definition DelayedBinaryIsometricOperation.hpp:604
DelayedBinaryIsometricOperation(std::shared_ptr< const Matrix< InputValue_, Index_ > > left, std::shared_ptr< const Matrix< InputValue_, Index_ > > right, std::shared_ptr< const Helper_ > helper)
Definition DelayedBinaryIsometricOperation.hpp:551
bool prefer_rows() const
Definition DelayedBinaryIsometricOperation.hpp:608
std::unique_ptr< OracularSparseExtractor< OutputValue_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:831
Index_ nrow() const
Definition DelayedBinaryIsometricOperation.hpp:592
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(bool row, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:722
bool uses_oracle(bool row) const
Definition DelayedBinaryIsometricOperation.hpp:616
Index_ ncol() const
Definition DelayedBinaryIsometricOperation.hpp:596
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:807
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(bool row, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:799
std::unique_ptr< OracularDenseExtractor< OutputValue_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:815
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(bool row, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:718
bool is_sparse() const
Definition DelayedBinaryIsometricOperation.hpp:600
std::unique_ptr< OracularDenseExtractor< OutputValue_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:819
std::unique_ptr< OracularSparseExtractor< OutputValue_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:835
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
void resize_container_to_Index_size(Container_ &container, Index_ x)
Definition Index_to_container.hpp:86
typename std::conditional< oracle_, std::shared_ptr< const Oracle< Index_ > >, bool >::type MaybeOracle
Definition new_extractor.hpp:20
typename std::conditional< oracle_, OracularDenseExtractor< Value_, Index_ >, MyopicDenseExtractor< Value_, Index_ > >::type DenseExtractor
Definition Extractor.hpp:273
Value_ * copy_n(const Value_ *input, Size_ n, Value_ *output)
Definition copy.hpp:26
Options for accessing data from a Matrix instance.
Definition Options.hpp:30