1#ifndef TATAMI_DELAYED_BINARY_ISOMETRIC_OPERATION_H
2#define TATAMI_DELAYED_BINARY_ISOMETRIC_OPERATION_H
8#include "../depends_utils.hpp"
26namespace DelayedBinaryIsometricOperation_internal {
32template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Operation_>
33class DenseSimpleFull final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
36 const Matrix<InputValue_, Index_>& left,
37 const Matrix<InputValue_, Index_>& right,
38 const Operation_& operation,
40 MaybeOracle<oracle_, Index_> oracle,
42 my_operation(operation),
44 my_oracle(oracle, my_operation, row)
46 my_left_ext = new_extractor<false, oracle_>(left, my_row, oracle, opt);
47 my_right_ext = new_extractor<false, oracle_>(right, my_row, std::move(oracle), opt);
48 my_extent = my_row ? left.ncol() : left.nrow();
50 my_right_holding_buffer.resize(my_extent);
51 if constexpr(!same_value) {
52 my_left_holding_buffer.resize(my_extent);
56 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
57 auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
59 if constexpr(same_value) {
60 auto lptr = my_left_ext->fetch(i, buffer);
61 copy_n(lptr, my_extent, buffer);
62 my_operation.dense(my_row, my_oracle.get(i),
static_cast<Index_
>(0), my_extent, buffer, rptr, buffer);
64 auto lptr = my_left_ext->fetch(i, my_left_holding_buffer.data());
65 my_operation.dense(my_row, my_oracle.get(i),
static_cast<Index_
>(0), my_extent, lptr, rptr, buffer);
72 const Operation_& my_operation;
74 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Operation_, Index_> my_oracle;
76 std::unique_ptr<DenseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
78 std::vector<InputValue_> my_right_holding_buffer;
80 static constexpr bool same_value = std::is_same<OutputValue_, InputValue_>::value;
81 typename std::conditional<!same_value, std::vector<InputValue_>,
bool>::type my_left_holding_buffer;
84template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Operation_>
85class DenseSimpleBlock final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
88 const Matrix<InputValue_, Index_>& left,
89 const Matrix<InputValue_, Index_>& right,
90 const Operation_& operation,
92 MaybeOracle<oracle_, Index_> oracle,
96 my_operation(operation),
98 my_oracle(oracle, my_operation, row),
99 my_block_start(block_start),
100 my_block_length(block_length)
102 my_left_ext = new_extractor<false, oracle_>(left, my_row, oracle, my_block_start, my_block_length, opt);
103 my_right_ext = new_extractor<false, oracle_>(right, my_row, std::move(oracle), my_block_start, my_block_length, opt);
105 my_right_holding_buffer.resize(my_block_length);
106 if constexpr(!same_value) {
107 my_left_holding_buffer.resize(my_block_length);
111 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
112 auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
114 if constexpr(same_value) {
115 auto lptr = my_left_ext->fetch(i, buffer);
116 copy_n(lptr, my_block_length, buffer);
117 my_operation.dense(my_row, my_oracle.get(i), my_block_start, my_block_length, buffer, rptr, buffer);
119 auto lptr = my_left_ext->fetch(i, my_left_holding_buffer.data());
120 my_operation.dense(my_row, my_oracle.get(i), my_block_start, my_block_length, lptr, rptr, buffer);
127 const Operation_& my_operation;
129 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Operation_, Index_> my_oracle;
131 Index_ my_block_start, my_block_length;
132 std::unique_ptr<DenseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
133 std::vector<InputValue_> my_right_holding_buffer;
135 static constexpr bool same_value = std::is_same<OutputValue_, InputValue_>::value;
136 typename std::conditional<!same_value, std::vector<InputValue_>,
bool>::type my_left_holding_buffer;
139template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Operation_>
140class DenseSimpleIndex final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
143 const Matrix<InputValue_, Index_>& left,
144 const Matrix<InputValue_, Index_>& right,
145 const Operation_& operation,
147 MaybeOracle<oracle_, Index_> oracle,
148 VectorPtr<Index_> indices_ptr,
149 const Options& opt) :
150 my_operation(operation),
152 my_oracle(oracle, my_operation, row),
153 my_indices_ptr(std::move(indices_ptr))
155 my_left_ext = new_extractor<false, oracle_>(left, my_row, oracle, my_indices_ptr, opt);
156 my_right_ext = new_extractor<false, oracle_>(right, my_row, std::move(oracle), my_indices_ptr, opt);
158 my_right_holding_buffer.resize(my_indices_ptr->size());
159 if constexpr(!same_value) {
160 my_left_holding_buffer.resize(my_indices_ptr->size());
164 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
165 auto rptr = my_right_ext->fetch(i, my_right_holding_buffer.data());
166 const auto& indices = *my_indices_ptr;
168 if constexpr(same_value) {
169 auto lptr = my_left_ext->fetch(i, buffer);
170 copy_n(lptr, indices.size(), buffer);
171 my_operation.dense(my_row, my_oracle.get(i), indices, buffer, rptr, buffer);
173 auto lptr = my_left_ext->fetch(i, my_left_holding_buffer.data());
174 my_operation.dense(my_row, my_oracle.get(i), indices, lptr, rptr, buffer);
181 const Operation_& my_operation;
183 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Operation_, Index_> my_oracle;
185 VectorPtr<Index_> my_indices_ptr;
186 std::unique_ptr<DenseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
187 std::vector<InputValue_> my_right_holding_buffer;
189 static constexpr bool same_value = std::is_same<OutputValue_, InputValue_>::value;
190 typename std::conditional<!same_value, std::vector<InputValue_>,
bool>::type my_left_holding_buffer;
197template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Operation_>
198class DenseExpandedFull final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
201 const Matrix<InputValue_, Index_>& left,
202 const Matrix<InputValue_, Index_>& right,
203 const Operation_& op,
205 MaybeOracle<oracle_, Index_> oracle,
209 my_oracle(oracle, my_operation, row)
211 opt.sparse_extract_value =
true;
212 opt.sparse_extract_index =
true;
213 opt.sparse_ordered_index =
true;
214 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, opt);
215 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), opt);
217 my_extent = my_row ? left.ncol() : left.nrow();
218 my_left_vbuffer.resize(my_extent);
219 my_right_vbuffer.resize(my_extent);
220 my_output_vbuffer.resize(my_extent);
221 my_left_ibuffer.resize(my_extent);
222 my_right_ibuffer.resize(my_extent);
223 my_output_ibuffer.resize(my_extent);
226 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
227 auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
228 auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
230 i = my_oracle.get(i);
231 auto num = my_operation.sparse(my_row, i, lres, rres, my_output_vbuffer.data(), my_output_ibuffer.data(),
true,
true);
235 if (num < my_extent) {
236 std::fill_n(buffer, my_extent, my_operation.fill(my_row, i));
239 for (Index_ j = 0; j < num; ++j) {
240 buffer[my_output_ibuffer[j]] = my_output_vbuffer[j];
246 const Operation_& my_operation;
248 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Operation_, Index_> my_oracle;
250 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
253 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
254 std::vector<OutputValue_> my_output_vbuffer;
255 std::vector<Index_> my_left_ibuffer, my_right_ibuffer, my_output_ibuffer;
258template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Operation_>
259class DenseExpandedBlock final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
262 const Matrix<InputValue_, Index_>& left,
263 const Matrix<InputValue_, Index_>& right,
264 const Operation_& operation,
266 MaybeOracle<oracle_, Index_> oracle,
270 my_operation(operation),
272 my_oracle(oracle, my_operation, row),
273 my_block_start(block_start),
274 my_block_length(block_length)
276 opt.sparse_extract_value =
true;
277 opt.sparse_extract_index =
true;
278 opt.sparse_ordered_index =
true;
279 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, my_block_start, my_block_length, opt);
280 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), my_block_start, my_block_length, opt);
282 my_left_vbuffer.resize(my_block_length);
283 my_right_vbuffer.resize(my_block_length);
284 my_output_vbuffer.resize(my_block_length);
285 my_left_ibuffer.resize(my_block_length);
286 my_right_ibuffer.resize(my_block_length);
287 my_output_ibuffer.resize(my_block_length);
290 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
291 auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
292 auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
294 i = my_oracle.get(i);
295 auto num = my_operation.sparse(my_row, i, lres, rres, my_output_vbuffer.data(), my_output_ibuffer.data(),
true,
true);
299 if (num < my_block_length) {
300 std::fill_n(buffer, my_block_length, my_operation.fill(my_row, i));
303 for (Index_ j = 0; j < num; ++j) {
304 buffer[my_output_ibuffer[j] - my_block_start] = my_output_vbuffer[j];
310 const Operation_& my_operation;
312 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Operation_, Index_> my_oracle;
313 Index_ my_block_start, my_block_length;
315 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
317 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
318 std::vector<OutputValue_> my_output_vbuffer;
319 std::vector<Index_> my_left_ibuffer, my_right_ibuffer, my_output_ibuffer;
322template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Operation_>
323class DenseExpandedIndex final :
public DenseExtractor<oracle_, OutputValue_, Index_> {
326 const Matrix<InputValue_, Index_>& left,
327 const Matrix<InputValue_, Index_>& right,
328 const Operation_& operation,
330 MaybeOracle<oracle_, Index_> oracle,
331 VectorPtr<Index_> indices_ptr,
333 my_operation(operation),
335 my_oracle(oracle, my_operation, row),
336 my_extent(indices_ptr->size())
341 const auto& indices = *indices_ptr;
343 my_remapping_offset = indices.front();
344 my_remapping.resize(indices.back() - my_remapping_offset + 1);
346 for (Index_ i = 0; i < my_extent; ++i) {
347 my_remapping[indices[i] - my_remapping_offset] = i;
351 opt.sparse_extract_value =
true;
352 opt.sparse_extract_index =
true;
353 opt.sparse_ordered_index =
true;
354 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, indices_ptr, opt);
355 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), std::move(indices_ptr), opt);
357 my_left_vbuffer.resize(my_extent);
358 my_right_vbuffer.resize(my_extent);
359 my_output_vbuffer.resize(my_extent);
360 my_left_ibuffer.resize(my_extent);
361 my_right_ibuffer.resize(my_extent);
362 my_output_ibuffer.resize(my_extent);
365 const OutputValue_* fetch(Index_ i, OutputValue_* buffer) {
366 auto lres = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
367 auto rres = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
369 i = my_oracle.get(i);
370 auto num = my_operation.sparse(my_row, i, lres, rres, my_output_vbuffer.data(), my_output_ibuffer.data(),
true,
true);
374 if (num < my_extent) {
375 std::fill_n(buffer, my_extent, my_operation.fill(my_row, i));
378 for (Index_ j = 0; j < num; ++j) {
379 buffer[my_remapping[my_output_ibuffer[j] - my_remapping_offset]] = my_output_vbuffer[j];
385 const Operation_& my_operation;
387 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Operation_, Index_> my_oracle;
390 std::vector<Index_> my_remapping;
391 Index_ my_remapping_offset = 0;
393 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
395 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
396 std::vector<OutputValue_> my_output_vbuffer;
397 std::vector<Index_> my_left_ibuffer, my_right_ibuffer, my_output_ibuffer;
404template<
bool oracle_,
typename OutputValue_,
typename InputValue_,
typename Index_,
class Operation_>
405class Sparse final :
public SparseExtractor<oracle_, OutputValue_, Index_> {
408 const Matrix<InputValue_, Index_>& left,
409 const Matrix<InputValue_, Index_>& right,
410 const Operation_& operation,
412 MaybeOracle<oracle_, Index_> oracle,
414 my_operation(operation),
416 my_oracle(oracle, my_operation, row)
418 initialize(my_row ? left.ncol() : left.nrow(), opt);
419 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, opt);
420 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), opt);
424 const Matrix<InputValue_, Index_>& left,
425 const Matrix<InputValue_, Index_>& right,
426 const Operation_& operation,
428 MaybeOracle<oracle_, Index_> oracle,
432 my_operation(operation),
434 my_oracle(oracle, my_operation, row)
436 initialize(block_length, opt);
437 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, block_start, block_length, opt);
438 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), block_start, block_length, opt);
442 const Matrix<InputValue_, Index_>& left,
443 const Matrix<InputValue_, Index_>& right,
444 const Operation_& operation,
446 MaybeOracle<oracle_, Index_> oracle,
447 VectorPtr<Index_> indices_ptr,
449 my_operation(operation),
451 my_oracle(oracle, my_operation, row)
453 initialize(indices_ptr->size(), opt);
454 my_left_ext = new_extractor<true, oracle_>(left, my_row, oracle, indices_ptr, opt);
455 my_right_ext = new_extractor<true, oracle_>(right, my_row, std::move(oracle), std::move(indices_ptr), opt);
459 void initialize(
size_t extent, Options& opt) {
460 my_report_value = opt.sparse_extract_value;
461 my_report_index = opt.sparse_extract_index;
463 my_left_ibuffer.resize(extent);
464 my_right_ibuffer.resize(extent);
465 if (my_report_value) {
466 my_left_vbuffer.resize(extent);
467 my_right_vbuffer.resize(extent);
470 opt.sparse_ordered_index =
true;
471 opt.sparse_extract_index =
true;
475 SparseRange<OutputValue_, Index_> fetch(Index_ i, OutputValue_* value_buffer, Index_* index_buffer) {
476 auto left_ranges = my_left_ext->fetch(i, my_left_vbuffer.data(), my_left_ibuffer.data());
477 auto right_ranges = my_right_ext->fetch(i, my_right_vbuffer.data(), my_right_ibuffer.data());
478 auto num = my_operation.sparse(
491 (my_report_value ? value_buffer: NULL),
492 (my_report_index ? index_buffer: NULL)
497 const Operation_& my_operation;
499 DelayedIsometricOperation_internal::MaybeOracleDepends<oracle_, Operation_, Index_> my_oracle;
501 std::unique_ptr<SparseExtractor<oracle_, InputValue_, Index_> > my_left_ext, my_right_ext;
502 std::vector<InputValue_> my_left_vbuffer, my_right_vbuffer;
503 std::vector<Index_> my_left_ibuffer, my_right_ibuffer;
505 bool my_report_value =
false;
506 bool my_report_index =
false;
531 typename OutputValue_,
532 typename InputValue_,
534 class Operation_ = DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>
546 std::shared_ptr<const Operation_> operation
548 my_left(std::move(left)), my_right(std::move(right)), my_operation(std::move(operation))
550 if (my_left->nrow() != my_right->nrow() || my_left->ncol() != my_right->ncol()) {
551 throw std::runtime_error(
"shape of the left and right matrices should be the same");
554 auto expected_rows = my_operation->nrow();
555 if (expected_rows.has_value() && *expected_rows != my_left->nrow()) {
556 throw std::runtime_error(
"number of matrix rows is not consistent with those expected by 'operation'");
558 auto expected_cols = my_operation->ncol();
559 if (expected_cols.has_value() && *expected_cols != my_left->ncol()) {
560 throw std::runtime_error(
"number of matrix columns is not consistent with those expected by 'operation'");
563 my_prefer_rows_proportion = (my_left->prefer_rows_proportion() + my_right->prefer_rows_proportion()) / 2;
565 if (my_operation->is_sparse()) {
566 my_is_sparse = my_left->is_sparse() && my_right->is_sparse();
569 my_is_sparse_proportion = (my_left->is_sparse_proportion() + my_right->is_sparse_proportion())/2;
574 std::shared_ptr<const Matrix<InputValue_, Index_> > my_left, my_right;
575 std::shared_ptr<const Operation_> my_operation;
577 double my_prefer_rows_proportion;
578 double my_is_sparse_proportion = 0;
579 bool my_is_sparse =
false;
583 return my_left->nrow();
587 return my_left->ncol();
595 return my_is_sparse_proportion;
599 return my_prefer_rows_proportion > 0.5;
603 return my_prefer_rows_proportion;
607 return my_left->uses_oracle(row) || my_right->uses_oracle(row);
618 template<
bool oracle_>
620 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleFull<oracle_, OutputValue_, InputValue_, Index_, Operation_> >(
630 template<
bool oracle_>
631 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 {
632 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleBlock<oracle_, OutputValue_, InputValue_, Index_, Operation_> >(
644 template<
bool oracle_>
646 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseSimpleIndex<oracle_, OutputValue_, InputValue_, Index_, Operation_> >(
652 std::move(indices_ptr),
657 template<
bool oracle_>
658 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_expanded_internal(
bool row,
MaybeOracle<oracle_, Index_> oracle,
const Options& opt)
const {
659 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedFull<oracle_, OutputValue_, InputValue_, Index_, Operation_> >(
669 template<
bool oracle_>
670 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 {
671 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedBlock<oracle_, OutputValue_, InputValue_, Index_, Operation_> >(
683 template<
bool oracle_>
685 return std::make_unique<DelayedBinaryIsometricOperation_internal::DenseExpandedIndex<oracle_, OutputValue_, InputValue_, Index_, Operation_> >(
691 std::move(indices_ptr),
696 template<
bool oracle_,
typename ... Args_>
697 std::unique_ptr<DenseExtractor<oracle_, OutputValue_, Index_> > dense_internal(
bool row, Args_&& ... args)
const {
699 if (DelayedIsometricOperation_internal::can_dense_expand(*my_operation, row)) {
700 return dense_expanded_internal<oracle_>(row, std::forward<Args_>(args)...);
704 return dense_simple_internal<oracle_>(row, std::forward<Args_>(args)...);
708 std::unique_ptr<MyopicDenseExtractor<OutputValue_, Index_> >
dense(
bool row,
const Options& opt)
const {
709 return dense_internal<false>(row,
false, opt);
712 std::unique_ptr<MyopicDenseExtractor<OutputValue_, Index_> >
dense(
bool row, Index_ block_start, Index_ block_length,
const Options& opt)
const {
713 return dense_internal<false>(row,
false, block_start, block_length, opt);
717 return dense_internal<false>(row,
false, std::move(indices_ptr), opt);
724 template<
bool oracle_>
727 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Operation_> >(
737 return std::make_unique<FullSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
738 dense_internal<oracle_>(row, std::move(oracle), opt),
739 row ? my_left->ncol() : my_left->nrow(),
744 template<
bool oracle_>
745 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 {
747 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Operation_> >(
759 return std::make_unique<BlockSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
760 dense_internal<oracle_>(row, std::move(oracle), block_start, block_length, opt),
767 template<
bool oracle_>
770 return std::make_unique<DelayedBinaryIsometricOperation_internal::Sparse<oracle_, OutputValue_, InputValue_, Index_, Operation_> >(
776 std::move(indices_ptr),
781 return std::make_unique<IndexSparsifiedWrapper<oracle_, OutputValue_, Index_> >(
782 dense_internal<oracle_>(row, std::move(oracle), indices_ptr, opt),
789 std::unique_ptr<MyopicSparseExtractor<OutputValue_, Index_> >
sparse(
bool row,
const Options& opt)
const {
790 return sparse_internal<false>(row,
false, opt);
793 std::unique_ptr<MyopicSparseExtractor<OutputValue_, Index_> >
sparse(
bool row, Index_ block_start, Index_ block_length,
const Options& opt)
const {
794 return sparse_internal<false>(row,
false, block_start, block_length, opt);
798 return sparse_internal<false>(row,
false, std::move(indices_ptr), opt);
805 std::unique_ptr<OracularDenseExtractor<OutputValue_, Index_> >
dense(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
806 return dense_internal<true>(row, std::move(oracle), opt);
809 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 {
810 return dense_internal<true>(row, std::move(oracle), block_start, block_length, opt);
814 return dense_internal<true>(row, std::move(oracle), std::move(indices_ptr), opt);
821 std::unique_ptr<OracularSparseExtractor<OutputValue_, Index_> >
sparse(
bool row, std::shared_ptr<
const Oracle<Index_> > oracle,
const Options& opt)
const {
822 return sparse_internal<true>(row, std::move(oracle), opt);
825 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 {
826 return sparse_internal<true>(row, std::move(oracle), block_start, block_length, opt);
830 return sparse_internal<true>(row, std::move(oracle), std::move(indices_ptr), opt);
838template<
typename OutputValue_ =
double,
typename InputValue_,
typename Index_,
class Operation_>
839std::shared_ptr<Matrix<OutputValue_, Index_> > make_DelayedBinaryIsometricOperation(
840 std::shared_ptr<
const Matrix<InputValue_, Index_> > left,
841 std::shared_ptr<
const Matrix<InputValue_, Index_> > right,
842 std::shared_ptr<const Operation_> op)
844 return std::make_shared<DelayedBinaryIsometricOperation<OutputValue_, InputValue_, Index_, Operation_> >(std::move(left), std::move(right), std::move(op));
847template<
typename OutputValue_ =
double,
typename InputValue_,
typename Index_,
class Operation_>
848std::shared_ptr<Matrix<OutputValue_, Index_> > make_DelayedBinaryIsometricOperation(
849 std::shared_ptr<Matrix<InputValue_, Index_> > left,
850 std::shared_ptr<Matrix<InputValue_, Index_> > right,
851 std::shared_ptr<Operation_> op)
853 return std::make_shared<DelayedBinaryIsometricOperation<OutputValue_, InputValue_, Index_, Operation_> >(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:536
bool prefer_rows() const
Definition DelayedBinaryIsometricOperation.hpp:598
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:716
std::unique_ptr< OracularSparseExtractor< OutputValue_, Index_ > > sparse(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:821
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(bool row, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:708
std::unique_ptr< OracularDenseExtractor< OutputValue_, Index_ > > dense(bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:805
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(bool row, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:789
bool uses_oracle(bool row) const
Definition DelayedBinaryIsometricOperation.hpp:606
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:813
bool is_sparse() const
Definition DelayedBinaryIsometricOperation.hpp:590
double is_sparse_proportion() const
Definition DelayedBinaryIsometricOperation.hpp:594
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(bool row, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:793
Index_ ncol() const
Definition DelayedBinaryIsometricOperation.hpp:586
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:809
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:825
std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > sparse(bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:797
std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > dense(bool row, Index_ block_start, Index_ block_length, const Options &opt) const
Definition DelayedBinaryIsometricOperation.hpp:712
Index_ nrow() const
Definition DelayedBinaryIsometricOperation.hpp:582
double prefer_rows_proportion() const
Definition DelayedBinaryIsometricOperation.hpp:602
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:829
DelayedBinaryIsometricOperation(std::shared_ptr< const Matrix< InputValue_, Index_ > > left, std::shared_ptr< const Matrix< InputValue_, Index_ > > right, std::shared_ptr< const Operation_ > operation)
Definition DelayedBinaryIsometricOperation.hpp:543
Virtual class for a matrix.
Definition Matrix.hpp:59
Predict future access requests on the target dimension.
Definition Oracle.hpp:21
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