1#ifndef TATAMI_ISOMETRIC_BINARY_COMPARE_HELPERS_H
2#define TATAMI_ISOMETRIC_BINARY_COMPARE_HELPERS_H
26template<CompareOperation 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_compare<op_>(val, right_buffer[i]);
49 output_buffer[i] = delayed_compare<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_compare<op_>(val, right_buffer[i]);
68 output_buffer[i] = delayed_compare<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)
85 return delayed_binary_isometric_sparse_operation<false>(
92 [](InputValue_ l, InputValue_ r) ->
auto {
93 return delayed_compare<op_>(l, r);
103 static constexpr bool known_sparse = (op_ != CompareOperation::EQUAL &&
104 op_ != CompareOperation::GREATER_THAN_OR_EQUAL &&
105 op_ != CompareOperation::LESS_THAN_OR_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_>
179template<
typename OutputValue_,
typename InputValue_,
typename Index_>
189template<
typename OutputValue_,
typename InputValue_,
typename Index_>
199template<
typename OutputValue_,
typename InputValue_,
typename Index_>
205template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
206std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricEqual() {
207 return std::make_shared<DelayedBinaryIsometricEqualHelper<OutputValue_, InputValue_, Index_> >();
210template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
211std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricGreaterThan() {
212 return std::make_shared<DelayedBinaryIsometricGreaterThanHelper<OutputValue_, InputValue_, Index_> >();
215template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
216std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricLessThan() {
217 return std::make_shared<DelayedBinaryIsometricLessThanHelper<OutputValue_, InputValue_, Index_> >();
220template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
221std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricGreaterThanOrEqual() {
222 return std::make_shared<DelayedBinaryIsometricGreaterThanOrEqualHelper<OutputValue_, InputValue_, Index_> >();
225template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
226std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricLessThanOrEqual() {
227 return std::make_shared<DelayedBinaryIsometricLessThanOrEqualHelper<OutputValue_, InputValue_, Index_> >();
230template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
231std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricNotEqual() {
232 return std::make_shared<DelayedBinaryIsometricNotEqualHelper<OutputValue_, InputValue_, Index_> >();
Interface for tatami::DelayedBinaryIsometricOperation helpers.
Helper operation interface for DelayedBinaryIsometricOperation.
Definition helper_interface.hpp:26
Utilities for delayed comparison operations.
Flexible representations for matrix data.
Definition Extractor.hpp:15
Helper for delayed binary isometric comparisons.
Definition compare_helpers.hpp:27
std::optional< Index_ > ncol() const
Definition compare_helpers.hpp:127
bool zero_depends_on_column() const
Definition compare_helpers.hpp:30
bool non_zero_depends_on_row() const
Definition compare_helpers.hpp:31
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 compare_helpers.hpp:54
bool is_sparse() const
Definition compare_helpers.hpp:118
bool zero_depends_on_row() const
Definition compare_helpers.hpp:29
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 compare_helpers.hpp:35
std::optional< Index_ > nrow() const
Definition compare_helpers.hpp:123
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 compare_helpers.hpp:73
bool non_zero_depends_on_column() const
Definition compare_helpers.hpp:32
OutputValue_ fill(const bool, const Index_) const
Definition compare_helpers.hpp:110
A range of a sparse vector.
Definition SparseRange.hpp:32