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_>
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_compare<op_>(val, right_buffer[i]);
41 output_buffer[i] = delayed_compare<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_compare<op_>(val, right_buffer[i]);
53 output_buffer[i] = delayed_compare<op_>(left_buffer[i], right_buffer[i]);
63 OutputValue_* value_buffer,
70 return delayed_binary_isometric_sparse_operation<false>(
77 [](InputValue_ l, InputValue_ r) ->
auto {
78 return delayed_compare<op_>(l, r);
88 static constexpr bool known_sparse = (op_ != CompareOperation::EQUAL &&
89 op_ != CompareOperation::GREATER_THAN_OR_EQUAL &&
90 op_ != CompareOperation::LESS_THAN_OR_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_>
164template<
typename OutputValue_,
typename InputValue_,
typename Index_>
174template<
typename OutputValue_,
typename InputValue_,
typename Index_>
184template<
typename OutputValue_,
typename InputValue_,
typename Index_>
190template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
191std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricEqual() {
192 return std::make_shared<DelayedBinaryIsometricEqualHelper<OutputValue_, InputValue_, Index_> >();
195template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
196std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricGreaterThan() {
197 return std::make_shared<DelayedBinaryIsometricGreaterThanHelper<OutputValue_, InputValue_, Index_> >();
200template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
201std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricLessThan() {
202 return std::make_shared<DelayedBinaryIsometricLessThanHelper<OutputValue_, InputValue_, Index_> >();
205template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
206std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricGreaterThanOrEqual() {
207 return std::make_shared<DelayedBinaryIsometricGreaterThanOrEqualHelper<OutputValue_, InputValue_, Index_> >();
210template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
211std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricLessThanOrEqual() {
212 return std::make_shared<DelayedBinaryIsometricLessThanOrEqualHelper<OutputValue_, InputValue_, Index_> >();
215template<
typename OutputValue_ =
double,
typename InputValue_ =
double,
typename Index_ =
int>
216std::shared_ptr<DelayedBinaryIsometricOperationHelper<OutputValue_, InputValue_, Index_> > make_DelayedBinaryIsometricNotEqual() {
217 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:112
void dense(bool, Index_, Index_, Index_ length, const InputValue_ *left_buffer, const InputValue_ *right_buffer, OutputValue_ *output_buffer) const
Definition compare_helpers.hpp:35
bool zero_depends_on_column() const
Definition compare_helpers.hpp:30
bool non_zero_depends_on_row() const
Definition compare_helpers.hpp:31
bool is_sparse() const
Definition compare_helpers.hpp:103
bool zero_depends_on_row() const
Definition compare_helpers.hpp:29
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 compare_helpers.hpp:58
std::optional< Index_ > nrow() const
Definition compare_helpers.hpp:108
OutputValue_ fill(bool, Index_) const
Definition compare_helpers.hpp:95
bool non_zero_depends_on_column() const
Definition compare_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 compare_helpers.hpp:46
A range of a sparse vector.
Definition SparseRange.hpp:32