tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
compare_helpers.hpp
Go to the documentation of this file.
1#ifndef TATAMI_ISOMETRIC_BINARY_COMPARE_HELPERS_H
2#define TATAMI_ISOMETRIC_BINARY_COMPARE_HELPERS_H
3
4#include "../compare_utils.hpp"
5#include "utils.hpp"
6
13namespace tatami {
14
22template<CompareOperation op_>
24public:
28 // It's sparse if f(0, 0) == 0.
29 static constexpr bool known_sparse = (op_ != CompareOperation::EQUAL &&
30 op_ != CompareOperation::GREATER_THAN_OR_EQUAL &&
31 op_ != CompareOperation::LESS_THAN_OR_EQUAL);
32
33 static constexpr bool is_basic = false;
38public:
42 template<typename Index_, typename InputValue_, typename OutputValue_>
44 for (Index_ i = 0; i < length; ++i) {
45 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
46 auto& val = output_buffer[i];
48 } else {
50 }
51 }
52 }
53
54 template<typename Index_, typename InputValue_, typename OutputValue_>
55 void dense(bool, Index_, const std::vector<Index_>& indices, const InputValue_* left_buffer, const InputValue_* right_buffer, OutputValue_* output_buffer) const {
56 Index_ length = indices.size();
57 for (Index_ i = 0; i < length; ++i) {
58 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
59 auto& val = output_buffer[i];
61 } else {
63 }
64 }
65 }
66
67 template<typename Index_, typename InputValue_, typename OutputValue_>
69 // None of the operations will return zero if one entry is zero and the other entry is non-zero...
70 // except for equality, but then, the sparse() method would never even be used.
72 left,
73 right,
78 [](InputValue_ l, InputValue_ r) -> auto {
79 return delayed_compare<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
140
148
149}
150
151#endif
Flexible representations for matrix data.
Definition Extractor.hpp:15
DelayedBinaryIsometricCompare< CompareOperation::LESS_THAN > make_DelayedBinaryIsometricLessThan()
Definition compare_helpers.hpp:121
DelayedBinaryIsometricCompare< CompareOperation::GREATER_THAN > make_DelayedBinaryIsometricGreaterThan()
Definition compare_helpers.hpp:113
DelayedBinaryIsometricCompare< CompareOperation::LESS_THAN_OR_EQUAL > make_DelayedBinaryIsometricLessThanOrEqual()
Definition compare_helpers.hpp:137
DelayedBinaryIsometricCompare< CompareOperation::NOT_EQUAL > make_DelayedBinaryIsometricNotEqual()
Definition compare_helpers.hpp:145
DelayedBinaryIsometricCompare< CompareOperation::GREATER_THAN_OR_EQUAL > make_DelayedBinaryIsometricGreaterThanOrEqual()
Definition compare_helpers.hpp:129
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35
DelayedBinaryIsometricCompare< CompareOperation::EQUAL > make_DelayedBinaryIsometricEqual()
Definition compare_helpers.hpp:105
Delayed binary isometric comparison.
Definition compare_helpers.hpp:23
A range of a sparse vector.
Definition SparseRange.hpp:32