tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
boolean_helpers.hpp
Go to the documentation of this file.
1#ifndef TATAMI_ISOMETRIC_BINARY_BOOLEAN_HELPERS_H
2#define TATAMI_ISOMETRIC_BINARY_BOOLEAN_HELPERS_H
3
4#include "../boolean_utils.hpp"
5#include "utils.hpp"
6
13namespace tatami {
14
22template<BooleanOperation op_>
24public:
28 // It's sparse if f(0, 0) == 0.
29 static constexpr bool known_sparse = (op_ != BooleanOperation::EQUAL);
30
31 static constexpr bool is_basic = false;
36public:
40 template<typename Index_, typename InputValue_, typename OutputValue_>
42 for (Index_ i = 0; i < length; ++i) {
43 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
44 auto& val = output_buffer[i];
46 } else {
48 }
49 }
50 }
51
52 template<typename Index_, typename InputValue_, typename OutputValue_>
53 void dense(bool, Index_, const std::vector<Index_>& indices, const InputValue_* left_buffer, const InputValue_* right_buffer, OutputValue_* output_buffer) const {
54 Index_ length = indices.size();
55 for (Index_ i = 0; i < length; ++i) {
56 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
57 auto& val = output_buffer[i];
59 } else {
61 }
62 }
63 }
64
65 template<typename Index_, typename InputValue_, typename OutputValue_>
67 // Don't bother storing an explicit zero for AND operations when either
68 // entry is zero. This should be NaN-safe as NaNs are truthy, so
69 // applying AND on that would just be false anyway.
70 constexpr bool must_have_both = (op_ == BooleanOperation::AND);
72 left,
73 right,
78 [](InputValue_ l, InputValue_ r) -> auto {
79 return delayed_boolean<op_>(l, r);
80 }
81 );
82 }
83
84 template<typename OutputValue_, typename InputValue_, typename Index_>
85 OutputValue_ fill(bool, Index_) const {
86 if constexpr(known_sparse) {
87 return 0;
88 } else {
89 return 1;
90 }
91 }
92
93 bool is_sparse() const {
94 return known_sparse;
95 }
99};
100
108
116
124
132
133}
134
135#endif
Flexible representations for matrix data.
Definition Extractor.hpp:15
DelayedBinaryIsometricBoolean< BooleanOperation::AND > make_DelayedBinaryIsometricBooleanAnd()
Definition boolean_helpers.hpp:113
DelayedBinaryIsometricBoolean< BooleanOperation::OR > make_DelayedBinaryIsometricBooleanOr()
Definition boolean_helpers.hpp:121
DelayedBinaryIsometricBoolean< BooleanOperation::XOR > make_DelayedBinaryIsometricBooleanXor()
Definition boolean_helpers.hpp:129
DelayedBinaryIsometricBoolean< BooleanOperation::EQUAL > make_DelayedBinaryIsometricBooleanEqual()
Definition boolean_helpers.hpp:105
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35
Delayed binary isometric boolean operations.
Definition boolean_helpers.hpp:23
A range of a sparse vector.
Definition SparseRange.hpp:32