1#ifndef TATAMI_DELAYED_BINARY_ISOMETRIC_OPERATION_H
2#define TATAMI_DELAYED_BINARY_ISOMETRIC_OPERATION_H
8#include "../depends_utils.hpp"
27namespace DelayedBinaryIsometricOperation_internal {
33template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
34class DenseSimpleFull final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
37 const Matrix<InputValue_, Index_>& left,
38 const Matrix<InputValue_, Index_>& right,
39 const Helper_& helper,
41 MaybeOracle<oracle_, Index_> oracle,
45 my_oracle(oracle, my_helper, row)
47 my_left_ext = new_extractor<false, oracle_>(left, my_row, oracle, opt);
48 my_right_ext = new_extractor<false, oracle_>(right, my_row, std::move(oracle), opt);
49 my_extent = my_row ? left.ncol() : left.nrow();
51 my_right_holding_buffer.resize(my_extent);
52 if constexpr(!same_value) {
53 my_left_holding_buffer.resize(my_extent);
57 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
58 auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
60 if constexpr(same_value) {
61 auto lptr = my_left_ext->fetch(i, buffer);
62 copy_n(lptr, my_extent, buffer);
63 my_helper.dense(my_row, my_oracle.get(i),
static_cast<Index_
>(0), my_extent, buffer, rptr, buffer);
65 auto lptr = my_left_ext->fetch(i, my_left_holding_buffer.data());
66 my_helper.dense(my_row, my_oracle.get(i),
static_cast<Index_
>(0), my_extent, lptr, rptr, buffer);
73 const Helper_& my_helper;
75 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
77 std::unique_ptr<DenseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
79 std::vector<InputValue_> my_right_holding_buffer;
81 static constexpr bool same_value = std::is_same<OutputValue_, InputValue_>::value;
82 typename std::conditional<!same_value, std::vector<InputValue_>,
bool>::type my_left_holding_buffer;
85template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
86class DenseSimpleBlock final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
89 const Matrix<InputValue_, Index_>& left,
90 const Matrix<InputValue_, Index_>& right,
91 const Helper_& helper,
93 MaybeOracle<oracle_, Index_> oracle,
99 my_oracle(oracle, my_helper, row),
100 my_block_start(block_start),
101 my_block_length(block_length)
103 my_left_ext = new_extractor<false, oracle_>(left, my_row, oracle, my_block_start, my_block_length, opt);
104 my_right_ext = new_extractor<false, oracle_>(right, my_row, std::move(oracle), my_block_start, my_block_length, opt);
106 my_right_holding_buffer.resize(my_block_length);
107 if constexpr(!same_value) {
108 my_left_holding_buffer.resize(my_block_length);
112 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
113 auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
115 if constexpr(same_value) {
116 auto lptr = my_left_ext->fetch(i, buffer);
117 copy_n(lptr, my_block_length, buffer);
118 my_helper.dense(my_row, my_oracle.get(i), my_block_start, my_block_length, buffer, rptr, buffer);
120 auto lptr = my_left_ext->fetch(i, my_left_holding_buffer.data());
121 my_helper.dense(my_row, my_oracle.get(i), my_block_start, my_block_length, lptr, rptr, buffer);
128 const Helper_& my_helper;
130 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
132 Index_ my_block_start, my_block_length;
133 std::unique_ptr<DenseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
134 std::vector<InputValue_> my_right_holding_buffer;
136 static constexpr bool same_value = std::is_same<OutputValue_, InputValue_>::value;
137 typename std::conditional<!same_value, std::vector<InputValue_>,
bool>::type my_left_holding_buffer;
140template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
141class DenseSimpleIndex final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
144 const Matrix<InputValue_, Index_>& left,
145 const Matrix<InputValue_, Index_>& right,
146 const Helper_& helper,
148 MaybeOracle<oracle_, Index_> oracle,
149 VectorPtr<Index_> indices_ptr,
150 const Options& opt) :
153 my_oracle(oracle, my_helper, row),
154 my_indices_ptr(std::move(indices_ptr))
156 my_left_ext = new_extractor<false, oracle_>(left, my_row, oracle, my_indices_ptr, opt);
157 my_right_ext = new_extractor<false, oracle_>(right, my_row, std::move(oracle), my_indices_ptr, opt);
159 my_right_holding_buffer.resize(my_indices_ptr->size());
160 if constexpr(!same_value) {
161 my_left_holding_buffer.resize(my_indices_ptr->size());
165 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
166 auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
167 const auto& indices = *my_indices_ptr;
169 if constexpr(same_value) {
170 auto lptr = my_left_ext->fetch(i, buffer);
171 copy_n(lptr, indices.size(), buffer);
172 my_helper.dense(my_row, my_oracle.get(i), indices, buffer, rptr, buffer);
174 auto lptr = my_left_ext->fetch(i, my_left_holding_buffer.data());
175 my_helper.dense(my_row, my_oracle.get(i), indices, lptr, rptr, buffer);
182 const Helper_& my_helper;
184 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
186 VectorPtr<Index_> my_indices_ptr;
187 std::unique_ptr<DenseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
188 std::vector<InputValue_> my_right_holding_buffer;
190 static constexpr bool same_value = std::is_same<OutputValue_, InputValue_>::value;
191 typename std::conditional<!same_value, std::vector<InputValue_>,
bool>::type my_left_holding_buffer;
198template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
199class DenseExpandedFull final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
202 const Matrix<InputValue_, Index_>& left,
203 const Matrix<InputValue_, Index_>& right,
204 const Helper_& helper,
206 MaybeOracle<oracle_, Index_> oracle,
210 my_oracle(oracle, my_helper, row)
212 opt.sparse_extract_value =
true;
213 opt.sparse_extract_index =
true;
214 opt.sparse_ordered_index =
true;
215 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, opt);
216 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), opt);
218 my_extent = my_row ? left.ncol() : left.nrow();
219 my_left_vbuffer.resize(my_extent);
220 my_right_vbuffer.resize(my_extent);
221 my_output_vbuffer.resize(my_extent);
222 my_left_ibuffer.resize(my_extent);
223 my_right_ibuffer.resize(my_extent);
224 my_output_ibuffer.resize(my_extent);
227 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
228 auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
229 auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
231 i = my_oracle.get(i);
232 auto num = my_helper.sparse(my_row, i, lres, rres, my_output_vbuffer.data(), my_output_ibuffer.data(),
true,
true);
236 if (num < my_extent) {
237 std::fill_n(buffer, my_extent, my_helper.fill(my_row, i));
240 for (Index_ j = 0; j < num; ++j) {
241 buffer[my_output_ibuffer[j]] = my_output_vbuffer[j];
247 const Helper_& my_helper;
249 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
251 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
254 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
255 std::vector<OutputValue_> my_output_vbuffer;
256 std::vector<Index_> my_left_ibuffer, my_right_ibuffer, my_output_ibuffer;
259template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
260class DenseExpandedBlock final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
263 const Matrix<InputValue_, Index_>& left,
264 const Matrix<InputValue_, Index_>& right,
265 const Helper_& helper,
267 MaybeOracle<oracle_, Index_> oracle,
273 my_oracle(oracle, my_helper, row),
274 my_block_start(block_start),
275 my_block_length(block_length)
277 opt.sparse_extract_value =
true;
278 opt.sparse_extract_index =
true;
279 opt.sparse_ordered_index =
true;
280 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, my_block_start, my_block_length, opt);
281 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), my_block_start, my_block_length, opt);
283 my_left_vbuffer.resize(my_block_length);
284 my_right_vbuffer.resize(my_block_length);
285 my_output_vbuffer.resize(my_block_length);
286 my_left_ibuffer.resize(my_block_length);
287 my_right_ibuffer.resize(my_block_length);
288 my_output_ibuffer.resize(my_block_length);
291 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
292 auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
293 auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
295 i = my_oracle.get(i);
296 auto num = my_helper.sparse(my_row, i, lres, rres, my_output_vbuffer.data(), my_output_ibuffer.data(),
true,
true);
300 if (num < my_block_length) {
301 std::fill_n(buffer, my_block_length, my_helper.fill(my_row, i));
304 for (Index_ j = 0; j < num; ++j) {
305 buffer[my_output_ibuffer[j] - my_block_start] = my_output_vbuffer[j];
311 const Helper_& my_helper;
313 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
314 Index_ my_block_start, my_block_length;
316 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
318 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
319 std::vector<OutputValue_> my_output_vbuffer;
320 std::vector<Index_> my_left_ibuffer, my_right_ibuffer, my_output_ibuffer;
323template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
324class DenseExpandedIndex final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
327 const Matrix<InputValue_, Index_>& left,
328 const Matrix<InputValue_, Index_>& right,
329 const Helper_& helper,
331 MaybeOracle<oracle_, Index_> oracle,
332 VectorPtr<Index_> indices_ptr,
336 my_oracle(oracle, my_helper, row),
337 my_extent(indices_ptr->size())
342 const auto& indices = *indices_ptr;
344 my_remapping_offset = indices.front();
345 my_remapping.resize(indices.back() - my_remapping_offset + 1);
347 for (Index_ i = 0; i < my_extent; ++i) {
348 my_remapping[indices[i] - my_remapping_offset] = i;
352 opt.sparse_extract_value =
true;
353 opt.sparse_extract_index =
true;
354 opt.sparse_ordered_index =
true;
355 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, indices_ptr, opt);
356 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), std::move(indices_ptr), opt);
358 my_left_vbuffer.resize(my_extent);
359 my_right_vbuffer.resize(my_extent);
360 my_output_vbuffer.resize(my_extent);
361 my_left_ibuffer.resize(my_extent);
362 my_right_ibuffer.resize(my_extent);
363 my_output_ibuffer.resize(my_extent);
366 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
367 auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
368 auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
370 i = my_oracle.get(i);
371 auto num = my_helper.sparse(my_row, i, lres, rres, my_output_vbuffer.data(), my_output_ibuffer.data(),
true,
true);
375 if (num < my_extent) {
376 std::fill_n(buffer, my_extent, my_helper.fill(my_row, i));
379 for (Index_ j = 0; j < num; ++j) {
380 buffer[my_remapping[my_output_ibuffer[j] - my_remapping_offset]] = my_output_vbuffer[j];
386 const Helper_& my_helper;
388 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
391 std::vector<Index_> my_remapping;
392 Index_ my_remapping_offset = 0;
394 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
396 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
397 std::vector<OutputValue_> my_output_vbuffer;
398 std::vector<Index_> my_left_ibuffer, my_right_ibuffer, my_output_ibuffer;
405template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Helper_>
406class Sparse final :
public SparseExtractor<oracle_, OutputValue_, Index_> {
409 const Matrix<InputValue_, Index_>& left,
410 const Matrix<InputValue_, Index_>& right,
411 const Helper_& helper,
413 MaybeOracle<oracle_, Index_> oracle,
417 my_oracle(oracle, my_helper, row)
419 initialize(my_row ? left.ncol() : left.nrow(), opt);
420 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, opt);
421 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), opt);
425 const Matrix<InputValue_, Index_>& left,
426 const Matrix<InputValue_, Index_>& right,
427 const Helper_& helper,
429 MaybeOracle<oracle_, Index_> oracle,
435 my_oracle(oracle, my_helper, row)
437 initialize(block_length, opt);
438 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, block_start, block_length, opt);
439 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), block_start, block_length, opt);
443 const Matrix<InputValue_, Index_>& left,
444 const Matrix<InputValue_, Index_>& right,
445 const Helper_& helper,
447 MaybeOracle<oracle_, Index_> oracle,
448 VectorPtr<Index_> indices_ptr,
452 my_oracle(oracle, my_helper, row)
454 initialize(indices_ptr->size(), opt);
455 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, indices_ptr, opt);
456 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), std::move(indices_ptr), opt);
460 void initialize(std::size_t extent, Options& opt) {
461 my_report_value = opt.sparse_extract_value;
462 my_report_index = opt.sparse_extract_index;
464 my_left_ibuffer.resize(extent);
465 my_right_ibuffer.resize(extent);
466 if (my_report_value) {
467 my_left_vbuffer.resize(extent);
468 my_right_vbuffer.resize(extent);
471 opt.sparse_ordered_index =
true;
472 opt.sparse_extract_index =
true;
476 SparseRange<OutputValue_, Index_> fetch(Index_ i, OutputValue_* value_buffer, Index_* index_buffer) {
477 auto left_ranges = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
478 auto right_ranges = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
479 auto num = my_helper.sparse(
492 (my_report_value ? value_buffer: NULL),
493 (my_report_index ? index_buffer: NULL)
498 const Helper_& my_helper;
500 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Helper_, Index_> my_oracle;
502 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
503 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
504 std::vector<Index_> my_left_ibuffer, my_right_ibuffer;
506 bool my_report_value =
false;
507 bool my_report_index =
false;
532 typename OutputValue_,
533 typename InputValue_,
535 class Helper_ = DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>
547 std::shared_ptr<const Helper_> helper
549 my_left(std::move(left)), my_right(std::move(right)), my_helper(std::move(helper))
551 if (my_left->nrow() != my_right->nrow() || my_left->ncol() != my_right->ncol()) {
552 throw std::runtime_error(
"shape of the left and right matrices should be the same");
555 auto expected_rows = my_helper->nrow();
556 if (expected_rows.has_value() && *expected_rows != my_left->nrow()) {
557 throw std::runtime_error(
"number of matrix rows is not consistent with those expected by 'helper'");
559 auto expected_cols = my_helper->ncol();
560 if (expected_cols.has_value() && *expected_cols != my_left->ncol()) {
561 throw std::runtime_error(
"number of matrix columns is not consistent with those expected by 'helper'");
564 my_prefer_rows_proportion = (my_left->prefer_rows_proportion() + my_right->prefer_rows_proportion()) / 2;
566 if (my_helper->is_sparse()) {
567 my_is_sparse = my_left->is_sparse() && my_right->is_sparse();
570 my_is_sparse_proportion = (my_left->is_sparse_proportion() + my_right->is_sparse_proportion())/2;
575 std::shared_ptr<const Matrix<InputValue_, Index_> > my_left, my_right;
576 std::shared_ptr<const Helper_> my_helper;
578 double my_prefer_rows_proportion;
579 double my_is_sparse_proportion = 0;
580 bool my_is_sparse =
false;
584 return my_left->nrow();
588 return my_left->ncol();
596 return my_is_sparse_proportion;
600 return my_prefer_rows_proportion > 0.5;
604 return my_prefer_rows_proportion;
608 return my_left->uses_oracle(row) || my_right->uses_oracle(row);
619 template<
bool oracle_>
621 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleFull<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
631 template<
bool oracle_>
632 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 {
633 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleBlock<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
645 template<
bool oracle_>
647 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleIndex<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
653 std::move(indices_ptr),
658 template<
bool oracle_>
659 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_expanded_internal(
bool row,
MaybeOracle<oracle_, Index_> oracle,
const Options& opt)
const {
660 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedFull<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
670 template<
bool oracle_>
671 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 {
672 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedBlock<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
684 template<
bool oracle_>
686 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedIndex<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
692 std::move(indices_ptr),
697 template<
bool oracle_,
typename ... Args_>
698 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_internal(
bool row, Args_&& ... args)
const {
700 if (DelayedIsometricOperation_internal::can_dense_expand(*my_helper, row)) {
701 return dense_expanded_internal<oracle_>(row, std::forward<Args_>(args)...);
705 return dense_simple_internal<oracle_>(row, std::forward<Args_>(args)...);
709 std::unique_ptr<MyopicDenseExtractor<OutputValue_, Index_> >
dense(
bool row,
const Options& opt)
const {
710 return dense_internal<false>(row,
false, opt);
713 std::unique_ptr<MyopicDenseExtractor<OutputValue_, Index_> >
dense(
bool row, Index_ block_start, Index_ block_length,
const Options& opt)
const {
714 return dense_internal<false>(row,
false, block_start, block_length, opt);
718 return dense_internal<false>(row,
false, std::move(indices_ptr), opt);
725 template<
bool oracle_>
728 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
738 return std::make_unique<FullSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
739 dense_internal<oracle_>(row, std::move(oracle), opt),
740 row ? my_left->ncol() : my_left->nrow(),
745 template<
bool oracle_>
746 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 {
748 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
760 return std::make_unique<BlockSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
761 dense_internal<oracle_>(row, std::move(oracle), block_start, block_length, opt),
768 template<
bool oracle_>
771 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Helper_> >(
777 std::move(indices_ptr),
782 return std::make_unique<IndexSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
783 dense_internal<oracle_>(row, std::move(oracle), indices_ptr, opt),
790 std::unique_ptr<MyopicSparseExtractor<OutputValue_, Index_> >
sparse(
bool row,
const Options& opt)
const {
791 return sparse_internal<false>(row,
false, opt);
794 std::unique_ptr<MyopicSparseExtractor<OutputValue_, Index_> >
sparse(
bool row, Index_ block_start, Index_ block_length,
const Options& opt)
const {
795 return sparse_internal<false>(row,
false, block_start, block_length, opt);
799 return sparse_internal<false>(row,
false, std::move(indices_ptr), opt);
806 std::unique_ptr<OracularDenseExtractor<OutputValue_, Index_> >
dense(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
807 return dense_internal<true>(row, std::move(oracle), opt);
810 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 {
811 return dense_internal<true>(row, std::move(oracle), block_start, block_length, opt);
815 return dense_internal<true>(row, std::move(oracle), std::move(indices_ptr), opt);
822 std::unique_ptr<OracularSparseExtractor<OutputValue_, Index_> >
sparse(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
823 return sparse_internal<true>(row, std::move(oracle), opt);
826 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 {
827 return sparse_internal<true>(row, std::move(oracle), block_start, block_length, opt);
831 return sparse_internal<true>(row, std::move(oracle), std::move(indices_ptr), opt);
839template<
typename OutputValue_ =
double,
typename InputValue_,
typename Index_,
class Helper_>
840std::shared_ptr<Matrix<OutputValue_, Index_> > make_DelayedBinaryIsometricOperation(
841 std::shared_ptr<
const Matrix<InputValue_, Index_> > left,
842 std::shared_ptr<
const Matrix<InputValue_, Index_> > right,
843 std::shared_ptr<const Helper_> op)
845 return std::make_shared<DelayedBinaryIsometricOperation<OutputValue_, InputValue_, Index_, Helper_> >(std::move(left), std::move(right), std::move(op));
848template<
typename OutputValue_ =
double,
typename InputValue_,
typename Index_,
class Helper_>
849std::shared_ptr<Matrix<OutputValue_, Index_> > make_DelayedBinaryIsometricOperation(
850 std::shared_ptr<Matrix<InputValue_, Index_> > left,
851 std::shared_ptr<Matrix<InputValue_, Index_> > right,
852 std::shared_ptr<Helper_> op)
854 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:537
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(bool row, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:794
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:830
double prefer_rows_proportion() const
Definition DelayedBinaryIsometricOperation.hpp:603
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:717
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:814
double is_sparse_proportion() const
Definition DelayedBinaryIsometricOperation.hpp:595
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:544
bool prefer_rows() const
Definition DelayedBinaryIsometricOperation.hpp:599
std::unique_ptr< OracularSparseExtractor< OutputValue_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:822
Index_ nrow() const
Definition DelayedBinaryIsometricOperation.hpp:583
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(bool row, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:713
bool uses_oracle(bool row) const
Definition DelayedBinaryIsometricOperation.hpp:607
Index_ ncol() const
Definition DelayedBinaryIsometricOperation.hpp:587
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:798
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(bool row, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:790
std::unique_ptr< OracularDenseExtractor< OutputValue_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:806
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(bool row, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:709
bool is_sparse() const
Definition DelayedBinaryIsometricOperation.hpp:591
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:810
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:826
Virtual class for a matrix.
Definition Matrix.hpp:59
Predict future access requests on the target dimension.
Definition Oracle.hpp:23
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
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:25
Options for accessing data from a Matrix instance.
Definition Options.hpp:30