1#ifndef TATAMI_ISOMETRIC_BINARY_BOOLEAN_HELPERS_H
2#define TATAMI_ISOMETRIC_BINARY_BOOLEAN_HELPERS_H
26template<BooleanOperation op_,
typename OutputValue_,
typename InputValue_,
typename Index_>
40 const InputValue_*
const left_buffer,
41 const InputValue_*
const right_buffer,
42 OutputValue_*
const output_buffer)
44 for (Index_ i = 0; i < length; ++i) {
45 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
46 auto& val = output_buffer[i];
47 val = delayed_boolean<op_>(val, right_buffer[i]);
49 output_buffer[i] = delayed_boolean<op_>(left_buffer[i], right_buffer[i]);
57 const std::vector<Index_>& indices,
58 const InputValue_*
const left_buffer,
59 const InputValue_*
const right_buffer,
60 OutputValue_*
const output_buffer)
62 const Index_ length = indices.size();
63 for (Index_ i = 0; i < length; ++i) {
64 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
65 auto& val = output_buffer[i];
66 val = delayed_boolean<op_>(val, right_buffer[i]);
68 output_buffer[i] = delayed_boolean<op_>(left_buffer[i], right_buffer[i]);
78 OutputValue_*
const value_buffer,
79 Index_*
const index_buffer,
80 const bool needs_value,
81 const bool needs_index)
86 constexpr bool must_have_both = (op_ == BooleanOperation::AND);
87 return delayed_binary_isometric_sparse_operation<must_have_both>(
94 [](InputValue_ l, InputValue_ r) ->
auto {
95 return delayed_boolean<op_>(l, r);
105 static constexpr bool known_sparse = (op_ != BooleanOperation::EQUAL);
110 OutputValue_
fill(
const bool,
const Index_)
const {
111 if constexpr(known_sparse) {
123 std::optional<Index_>
nrow()
const {
127 std::optional<Index_>
ncol()
const {
139template<
typename OutputValue_,
typename InputValue_,
typename Index_>
149template<
typename OutputValue_,
typename InputValue_,
typename Index_>
159template<
typename OutputValue_,
typename InputValue_,
typename Index_>
169template<
typename OutputValue_,
typename InputValue_,
typename Index_>
175template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
176std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricBooleanEqual() {
177 return std::make_shared<DelayedBinaryIsometricBooleanEqualHelper<OutputValue_, InputValue_, Index_> >();
180template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
181std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricBooleanAnd() {
182 return std::make_shared<DelayedBinaryIsometricBooleanAndHelper<OutputValue_, InputValue_, Index_> >();
185template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
186std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricBooleanOr() {
187 return std::make_shared<DelayedBinaryIsometricBooleanOrHelper<OutputValue_, InputValue_, Index_> >();
190template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
191std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricBooleanXor() {
192 return std::make_shared<DelayedBinaryIsometricBooleanXorHelper<OutputValue_, InputValue_, Index_> >();
Interface for tatami::DelayedBinaryIsometricOperation helpers.
Utilities for delayed boolean operations.
Helper operation interface for DelayedBinaryIsometricOperation.
Definition helper_interface.hpp:26
Flexible representations for matrix data.
Definition Extractor.hpp:15
Helper for delayed binary isometric boolean operations.
Definition boolean_helpers.hpp:27
bool zero_depends_on_row() const
Definition boolean_helpers.hpp:29
void dense(const bool, const Index_, const std::vector< Index_ > &indices, const InputValue_ *const left_buffer, const InputValue_ *const right_buffer, OutputValue_ *const output_buffer) const
Definition boolean_helpers.hpp:54
bool non_zero_depends_on_column() const
Definition boolean_helpers.hpp:32
bool is_sparse() const
Definition boolean_helpers.hpp:118
void dense(const bool, const Index_, const Index_, const Index_ length, const InputValue_ *const left_buffer, const InputValue_ *const right_buffer, OutputValue_ *const output_buffer) const
Definition boolean_helpers.hpp:35
std::optional< Index_ > nrow() const
Definition boolean_helpers.hpp:123
bool zero_depends_on_column() const
Definition boolean_helpers.hpp:30
Index_ sparse(const bool, const Index_, const SparseRange< InputValue_, Index_ > &left, const SparseRange< InputValue_, Index_ > &right, OutputValue_ *const value_buffer, Index_ *const index_buffer, const bool needs_value, const bool needs_index) const
Definition boolean_helpers.hpp:73
std::optional< Index_ > ncol() const
Definition boolean_helpers.hpp:127
OutputValue_ fill(const bool, const Index_) const
Definition boolean_helpers.hpp:110
bool non_zero_depends_on_row() const
Definition boolean_helpers.hpp:31
A range of a sparse vector.
Definition SparseRange.hpp:32