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_>
35 void dense(
bool, Index_, Index_, Index_ length,
const InputValue_* left_buffer,
const InputValue_* right_buffer, OutputValue_* output_buffer)
const {
36 for (Index_ i = 0; i < length; ++i) {
37 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
38 auto& val = output_buffer[i];
39 val = delayed_boolean<op_>(val, right_buffer[i]);
41 output_buffer[i] = delayed_boolean<op_>(left_buffer[i], right_buffer[i]);
46 void dense(
bool, Index_,
const std::vector<Index_>& indices,
const InputValue_* left_buffer,
const InputValue_* right_buffer, OutputValue_* output_buffer)
const {
47 Index_ length = indices.size();
48 for (Index_ i = 0; i < length; ++i) {
49 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
50 auto& val = output_buffer[i];
51 val = delayed_boolean<op_>(val, right_buffer[i]);
53 output_buffer[i] = delayed_boolean<op_>(left_buffer[i], right_buffer[i]);
63 OutputValue_* value_buffer,
71 constexpr bool must_have_both = (op_ == BooleanOperation::AND);
72 return delayed_binary_isometric_sparse_operation<must_have_both>(
79 [](InputValue_ l, InputValue_ r) ->
auto {
80 return delayed_boolean<op_>(l, r);
90 static constexpr bool known_sparse = (op_ != BooleanOperation::EQUAL);
95 OutputValue_
fill(
bool, Index_)
const {
96 if constexpr(known_sparse) {
108 std::optional<Index_>
nrow()
const {
112 std::optional<Index_>
ncol()
const {
124template<
typename OutputValue_,
typename InputValue_,
typename Index_>
134template<
typename OutputValue_,
typename InputValue_,
typename Index_>
144template<
typename OutputValue_,
typename InputValue_,
typename Index_>
154template<
typename OutputValue_,
typename InputValue_,
typename Index_>
160template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
161std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricBooleanEqual() {
162 return std::make_shared<DelayedBinaryIsometricBooleanEqualHelper<OutputValue_, InputValue_, Index_> >();
165template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
166std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricBooleanAnd() {
167 return std::make_shared<DelayedBinaryIsometricBooleanAndHelper<OutputValue_, InputValue_, Index_> >();
170template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
171std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricBooleanOr() {
172 return std::make_shared<DelayedBinaryIsometricBooleanOrHelper<OutputValue_, InputValue_, Index_> >();
175template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
176std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricBooleanXor() {
177 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
bool non_zero_depends_on_column() const
Definition boolean_helpers.hpp:32
void dense(bool, Index_, const std::vector< Index_ > &indices, const InputValue_ *left_buffer, const InputValue_ *right_buffer, OutputValue_ *output_buffer) const
Definition boolean_helpers.hpp:46
bool is_sparse() const
Definition boolean_helpers.hpp:103
void dense(bool, Index_, Index_, Index_ length, const InputValue_ *left_buffer, const InputValue_ *right_buffer, OutputValue_ *output_buffer) const
Definition boolean_helpers.hpp:35
std::optional< Index_ > nrow() const
Definition boolean_helpers.hpp:108
bool zero_depends_on_column() const
Definition boolean_helpers.hpp:30
Index_ sparse(bool, Index_, const SparseRange< InputValue_, Index_ > &left, const SparseRange< InputValue_, Index_ > &right, OutputValue_ *value_buffer, Index_ *index_buffer, bool needs_value, bool needs_index) const
Definition boolean_helpers.hpp:58
OutputValue_ fill(bool, Index_) const
Definition boolean_helpers.hpp:95
std::optional< Index_ > ncol() const
Definition boolean_helpers.hpp:112
bool non_zero_depends_on_row() const
Definition boolean_helpers.hpp:31
A range of a sparse vector.
Definition SparseRange.hpp:32