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(
const Index_ i, OutputValue_*
const buffer) {
59 const auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
61 if constexpr(same_value) {
62 const 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,
95 const Index_ block_start,
96 const Index_ block_length,
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(
const Index_ i, OutputValue_*
const buffer) {
114 const auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
116 if constexpr(same_value) {
117 const 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 const 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(
const Index_ i, OutputValue_*
const buffer) {
167 const 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 const 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 const 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_*
const buffer) {
231 const auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
232 const auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
234 i = my_oracle.get(i);
235 const 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,
271 const Index_ block_start,
272 const Index_ block_length,
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_*
const buffer) {
297 const auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
298 const auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
300 i = my_oracle.get(i);
301 const 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_*
const buffer) {
373 const auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
374 const auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
376 i = my_oracle.get(i);
377 const 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,
436 const Index_ block_start,
437 const Index_ block_length,
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(
const Index_ i, OutputValue_*
const value_buffer, Index_*
const index_buffer) {
484 const auto left_ranges = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
485 const auto right_ranges = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
486 const 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 const auto NR = my_left->nrow();
559 const 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 const 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 const 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_>
629 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_simple_internal(
634 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleFull<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
644 template<
bool oracle_>
645 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_simple_internal(
648 const Index_ block_start,
649 const Index_ block_length,
652 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleBlock<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
664 template<
bool oracle_>
665 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_simple_internal(
671 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleIndex<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
677 std::move(indices_ptr),
682 template<
bool oracle_>
683 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_expanded_internal(
688 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedFull<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
698 template<
bool oracle_>
699 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_expanded_internal(
702 const Index_ block_start,
703 const Index_ block_length,
706 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedBlock<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
718 template<
bool oracle_>
719 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_expanded_internal(
725 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedIndex<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
731 std::move(indices_ptr),
736 template<
bool oracle_,
typename ... Args_>
737 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_internal(
const bool row, Args_&& ... args)
const {
739 if (DelayedIsometricOperation_internal::can_dense_expand(*my_helper, row)) {
740 return dense_expanded_internal<oracle_>(row, std::forward<Args_>(args)...);
744 return dense_simple_internal<oracle_>(row, std::forward<Args_>(args)...);
748 std::unique_ptr<MyopicDenseExtractor<OutputValue_, Index_> >
dense(
752 return dense_internal<false>(row,
false, opt);
755 std::unique_ptr<MyopicDenseExtractor<OutputValue_, Index_> >
dense(
757 const Index_ block_start,
758 const Index_ block_length,
761 return dense_internal<false>(row,
false, block_start, block_length, opt);
764 std::unique_ptr<MyopicDenseExtractor<OutputValue_, Index_> >
dense(
769 return dense_internal<false>(row,
false, std::move(indices_ptr), opt);
776 template<
bool oracle_>
777 std::unique_ptr<SparseExtractor<oracle_, OutputValue_, Index_> > sparse_internal(
783 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
793 return std::make_unique<FullSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
794 dense_internal<oracle_>(row, std::move(oracle), opt),
795 row ? my_left->ncol() : my_left->nrow(),
800 template<
bool oracle_>
801 std::unique_ptr<SparseExtractor<oracle_, OutputValue_, Index_> > sparse_internal(
804 const Index_ block_start,
805 const Index_ block_length,
809 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
821 return std::make_unique<BlockSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
822 dense_internal<oracle_>(row, std::move(oracle), block_start, block_length, opt),
829 template<
bool oracle_>
830 std::unique_ptr<SparseExtractor<oracle_, OutputValue_, Index_> > sparse_internal(
837 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
843 std::move(indices_ptr),
848 return std::make_unique<IndexSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
849 dense_internal<oracle_>(row, std::move(oracle), indices_ptr, opt),
856 std::unique_ptr<MyopicSparseExtractor<OutputValue_, Index_> >
sparse(
860 return sparse_internal<false>(row,
false, opt);
863 std::unique_ptr<MyopicSparseExtractor<OutputValue_, Index_> >
sparse(
865 const Index_ block_start,
866 const Index_ block_length,
869 return sparse_internal<false>(row,
false, block_start, block_length, opt);
872 std::unique_ptr<MyopicSparseExtractor<OutputValue_, Index_> >
sparse(
877 return sparse_internal<false>(row,
false, std::move(indices_ptr), opt);
884 std::unique_ptr<OracularDenseExtractor<OutputValue_, Index_> >
dense(
889 return dense_internal<true>(row, std::move(oracle), opt);
892 std::unique_ptr<OracularDenseExtractor<OutputValue_, Index_> >
dense(
895 const Index_ block_start,
896 const Index_ block_length,
899 return dense_internal<true>(row, std::move(oracle), block_start, block_length, opt);
902 std::unique_ptr<OracularDenseExtractor<OutputValue_, Index_> >
dense(
908 return dense_internal<true>(row, std::move(oracle), std::move(indices_ptr), opt);
915 std::unique_ptr<OracularSparseExtractor<OutputValue_, Index_> >
sparse(
920 return sparse_internal<true>(row, std::move(oracle), opt);
923 std::unique_ptr<OracularSparseExtractor<OutputValue_, Index_> >
sparse(
926 const Index_ block_start,
927 const Index_ block_length,
930 return sparse_internal<true>(row, std::move(oracle), block_start, block_length, opt);
933 std::unique_ptr<OracularSparseExtractor<OutputValue_, Index_> >
sparse(
939 return sparse_internal<true>(row, std::move(oracle), std::move(indices_ptr), opt);
947template<
typename OutputValue_ =
double,
typename InputValue_,
typename Index_,
class Helper_>
948std::shared_ptr<Matrix<OutputValue_, Index_> > make_DelayedBinaryIsometricOperation(
949 std::shared_ptr<
const Matrix<InputValue_, Index_> > left,
950 std::shared_ptr<
const Matrix<InputValue_, Index_> > right,
951 std::shared_ptr<const Helper_> op)
953 return std::make_shared<DelayedBinaryIsometricOperation<OutputValue_, InputValue_, Index_, Helper_> >(std::move(left), std::move(right), std::move(op));
956template<
typename OutputValue_ =
double,
typename InputValue_,
typename Index_,
class Helper_>
957std::shared_ptr<Matrix<OutputValue_, Index_> > make_DelayedBinaryIsometricOperation(
958 std::shared_ptr<Matrix<InputValue_, Index_> > left,
959 std::shared_ptr<Matrix<InputValue_, Index_> > right,
960 std::shared_ptr<Helper_> op)
962 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< OracularDenseExtractor< OutputValue_, Index_ > > dense(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:884
double prefer_rows_proportion() const
Definition DelayedBinaryIsometricOperation.hpp:612
std::unique_ptr< OracularSparseExtractor< OutputValue_, Index_ > > sparse(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:915
std::unique_ptr< OracularSparseExtractor< OutputValue_, Index_ > > sparse(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:933
std::unique_ptr< OracularDenseExtractor< OutputValue_, Index_ > > dense(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:902
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(const bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:872
std::unique_ptr< OracularSparseExtractor< OutputValue_, Index_ > > sparse(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Index_ block_start, const Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:923
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
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(const bool row, const Index_ block_start, const Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:863
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(const bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:764
bool prefer_rows() const
Definition DelayedBinaryIsometricOperation.hpp:608
Index_ nrow() const
Definition DelayedBinaryIsometricOperation.hpp:592
bool uses_oracle(bool row) const
Definition DelayedBinaryIsometricOperation.hpp:616
Index_ ncol() const
Definition DelayedBinaryIsometricOperation.hpp:596
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(const bool row, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:748
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(const bool row, const Index_ block_start, const Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:755
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(const bool row, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:856
bool is_sparse() const
Definition DelayedBinaryIsometricOperation.hpp:600
std::unique_ptr< OracularDenseExtractor< OutputValue_, Index_ > > dense(const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Index_ block_start, const Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:892
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, const Index_ x, Args_ &&... args)
Definition Index_to_container.hpp:92
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_ *const input, const Size_ n, Value_ *const output)
Definition copy.hpp:37
Options for accessing data from a Matrix instance.
Definition Options.hpp:30