1#ifndef TATAMI_ISOMETRIC_UNARY_COMPARE_HELPERS_H
2#define TATAMI_ISOMETRIC_UNARY_COMPARE_HELPERS_H
19template<CompareOperation op_,
typename InputValue_,
typename Index_,
typename OutputValue_>
20void delayed_compare_run_simple(
const InputValue_* input, Index_ length, InputValue_ scalar, OutputValue_* output) {
21 for (Index_ i = 0; i < length; ++i) {
22 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
23 auto& val = output[i];
24 val = delayed_compare<op_>(val, scalar);
26 output[i] = delayed_compare<op_>(input[i], scalar);
31template<CompareOperation op_,
typename InputValue_>
32bool delayed_compare_actual_sparse(InputValue_ scalar) {
33 return !delayed_compare<op_, InputValue_>(0, scalar);
49template<CompareOperation op_,
typename InputValue_>
57 my_sparse = delayed_compare_actual_sparse<op_>(my_scalar);
61 InputValue_ my_scalar;
68 static constexpr bool is_basic =
false;
70 bool is_sparse()
const {
81 template<
typename Index_,
typename OutputValue_>
82 void dense(
bool, Index_, Index_, Index_ length,
const InputValue_* input, OutputValue_* output)
const {
83 delayed_compare_run_simple<op_>(input, length, my_scalar, output);
86 template<
typename Index_,
typename OutputValue_>
87 void dense(
bool, Index_,
const std::vector<Index_>& indices,
const InputValue_* input, OutputValue_* output)
const {
88 delayed_compare_run_simple<op_>(input,
static_cast<Index_
>(indices.size()), my_scalar, output);
91 template<
typename Index_,
typename OutputValue_>
92 void sparse(
bool, Index_, Index_ number,
const InputValue_* input_value,
const Index_*, OutputValue_* output_value)
const {
93 delayed_compare_run_simple<op_>(input_value, number, my_scalar, output_value);
96 template<
typename OutputValue_,
typename,
typename Index_>
97 OutputValue_ fill(
bool, Index_)
const {
98 return delayed_compare<op_, InputValue_>(0, my_scalar);
116template<CompareOperation op_,
typename InputValue_,
typename Vector_>
128 for (
auto x : my_vector) {
129 if (!delayed_compare_actual_sparse<op_, InputValue_>(x)) {
139 bool my_sparse =
true;
145 static constexpr bool is_basic =
false;
147 bool zero_depends_on_row()
const {
151 bool zero_depends_on_column()
const {
155 bool non_zero_depends_on_row()
const {
159 bool non_zero_depends_on_column()
const {
163 bool is_sparse()
const {
174 template<
typename Index_,
typename OutputValue_>
175 void dense(
bool row, Index_ idx, Index_ start, Index_ length,
const InputValue_* input, OutputValue_* output)
const {
176 if (row == my_by_row) {
177 delayed_compare_run_simple<op_, InputValue_>(input, length, my_vector[idx], output);
179 for (Index_ i = 0; i < length; ++i) {
180 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
181 auto& val = output[i];
182 val = delayed_compare<op_, InputValue_>(val, my_vector[i + start]);
184 output[i] = delayed_compare<op_, InputValue_>(input[i], my_vector[i + start]);
190 template<
typename Index_,
typename OutputValue_>
191 void dense(
bool row, Index_ idx,
const std::vector<Index_>& indices,
const InputValue_* input, OutputValue_* output)
const {
192 if (row == my_by_row) {
193 delayed_compare_run_simple<op_, InputValue_>(input,
static_cast<Index_
>(indices.size()), my_vector[idx], output);
195 Index_ length = indices.size();
196 for (Index_ i = 0; i < length; ++i) {
197 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
198 auto& val = output[i];
199 val = delayed_compare<op_, InputValue_>(val, my_vector[indices[i]]);
201 output[i] = delayed_compare<op_, InputValue_>(input[i], my_vector[indices[i]]);
207 template<
typename Index_,
typename OutputValue_>
208 void sparse(
bool row, Index_ idx, Index_ number,
const InputValue_* input,
const Index_* indices, OutputValue_* output)
const {
209 if (row == my_by_row) {
210 delayed_compare_run_simple<op_, InputValue_>(input, number, my_vector[idx], output);
212 for (Index_ i = 0; i < number; ++i) {
213 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
214 auto& val = output[i];
215 val = delayed_compare<op_, InputValue_>(val, my_vector[indices[i]]);
217 output[i] = delayed_compare<op_, InputValue_>(input[i], my_vector[indices[i]]);
223 template<
typename OutputValue_,
typename,
typename Index_>
224 OutputValue_ fill(
bool row, Index_ idx)
const {
225 if (row == my_by_row) {
226 return delayed_compare<op_, InputValue_>(0, my_vector[idx]);
244template<
typename InputValue_ =
double>
255template<
typename InputValue_ =
double>
266template<
typename InputValue_ =
double>
277template<
typename InputValue_ =
double>
288template<
typename InputValue_ =
double>
299template<
typename InputValue_ =
double>
312template<
typename InputValue_ =
double,
typename Vector_>
325template<
typename InputValue_ =
double,
typename Vector_>
338template<
typename InputValue_ =
double,
typename Vector_>
351template<
typename InputValue_ =
double,
typename Vector_>
364template<
typename InputValue_ =
double,
typename Vector_>
377template<
typename InputValue_ =
double,
typename Vector_>
385template<SpecialCompareOperation op_,
bool pass_,
typename InputValue_,
typename Index_>
386void delayed_special_compare_run_simple(InputValue_* buffer, Index_ length) {
387 for (Index_ i = 0; i < length; ++i) {
388 auto& val = buffer[i];
389 val = delayed_special_compare<op_, pass_, InputValue_>(val);
393template<SpecialCompareOperation op_,
bool pass_,
typename InputValue_,
typename Index_,
typename OutputValue_>
394void delayed_special_compare_run_simple(
const InputValue_* input, Index_ length, OutputValue_* output) {
395 for (Index_ i = 0; i < length; ++i) {
396 output[i] = delayed_special_compare<op_, pass_, InputValue_>(input[i]);
400template<SpecialCompareOperation op_,
bool pass_,
typename InputValue_>
401bool delayed_special_compare_actual_sparse() {
402 return !delayed_special_compare<op_, pass_, InputValue_>(0);
419template<SpecialCompareOperation op_,
bool pass_,
typename InputValue_>
423 my_sparse = !delayed_special_compare<op_, pass_, InputValue_>(0);
433 static constexpr bool is_basic =
false;
435 bool is_sparse()
const {
446 template<
typename Index_>
447 void dense(
bool, Index_, Index_, Index_ length, InputValue_* buffer)
const {
448 delayed_special_compare_run_simple<op_, pass_>(buffer, length);
451 template<
typename Index_,
typename OutputValue_>
452 void dense(
bool, Index_, Index_, Index_ length,
const InputValue_* input, OutputValue_* output)
const {
453 delayed_special_compare_run_simple<op_, pass_>(input, length, output);
456 template<
typename Index_>
457 void dense(
bool, Index_,
const std::vector<Index_>& indices, InputValue_* buffer)
const {
458 delayed_special_compare_run_simple<op_, pass_>(buffer,
static_cast<Index_
>(indices.size()));
461 template<
typename Index_,
typename OutputValue_>
462 void dense(
bool, Index_,
const std::vector<Index_>& indices,
const InputValue_* input, OutputValue_* output)
const {
463 delayed_special_compare_run_simple<op_, pass_>(input,
static_cast<Index_
>(indices.size()), output);
466 template<
typename Index_>
467 void sparse(
bool, Index_, Index_ number, InputValue_* buffer,
const Index_*)
const {
468 delayed_special_compare_run_simple<op_, pass_>(buffer, number);
471 template<
typename Index_,
typename OutputValue_>
472 void sparse(
bool, Index_, Index_ number,
const InputValue_* input,
const Index_*, OutputValue_* output)
const {
473 delayed_special_compare_run_simple<op_, pass_>(input, number, output);
476 template<
typename OutputValue_,
typename,
typename Index_>
477 OutputValue_ fill(
bool, Index_)
const {
491template<
bool pass_ = true,
typename InputValue_ =
double>
502template<
bool pass_ = true,
typename InputValue_ =
double>
513template<
bool pass_ = true,
typename InputValue_ =
double>
Delayed scalar comparison.
Definition compare_helpers.hpp:50
DelayedUnaryIsometricCompareScalar(InputValue_ scalar)
Definition compare_helpers.hpp:56
Delayed vector comparisons.
Definition compare_helpers.hpp:117
DelayedUnaryIsometricCompareVector(Vector_ vector, bool by_row)
Definition compare_helpers.hpp:127
Delayed special value comparison.
Definition compare_helpers.hpp:420
Utilities for delayed comparison operations.
Flexible representations for matrix data.
Definition Extractor.hpp:15
DelayedUnaryIsometricCompareScalar< CompareOperation::LESS_THAN, InputValue_ > make_DelayedUnaryIsometricLessThanScalar(InputValue_ scalar)
Definition compare_helpers.hpp:267
DelayedUnaryIsometricCompareVector< CompareOperation::NOT_EQUAL, InputValue_, Vector_ > make_DelayedUnaryIsometricNotEqualVector(Vector_ vector, bool by_row)
Definition compare_helpers.hpp:378
DelayedUnaryIsometricCompareVector< CompareOperation::LESS_THAN, InputValue_, Vector_ > make_DelayedUnaryIsometricLessThanVector(Vector_ vector, bool by_row)
Definition compare_helpers.hpp:339
DelayedUnaryIsometricSpecialCompare< SpecialCompareOperation::ISINF, pass_, InputValue_ > make_DelayedUnaryIsometricIsinf()
Definition compare_helpers.hpp:503
DelayedUnaryIsometricSpecialCompare< SpecialCompareOperation::ISFINITE, pass_, InputValue_ > make_DelayedUnaryIsometricIsfinite()
Definition compare_helpers.hpp:514
DelayedUnaryIsometricCompareScalar< CompareOperation::NOT_EQUAL, InputValue_ > make_DelayedUnaryIsometricNotEqualScalar(InputValue_ scalar)
Definition compare_helpers.hpp:300
DelayedUnaryIsometricSpecialCompare< SpecialCompareOperation::ISNAN, pass_, InputValue_ > make_DelayedUnaryIsometricIsnan()
Definition compare_helpers.hpp:492
DelayedUnaryIsometricCompareVector< CompareOperation::EQUAL, InputValue_, Vector_ > make_DelayedUnaryIsometricEqualVector(Vector_ vector, bool by_row)
Definition compare_helpers.hpp:313
DelayedUnaryIsometricCompareScalar< CompareOperation::GREATER_THAN_OR_EQUAL, InputValue_ > make_DelayedUnaryIsometricGreaterThanOrEqualScalar(InputValue_ scalar)
Definition compare_helpers.hpp:278
DelayedUnaryIsometricCompareScalar< CompareOperation::GREATER_THAN, InputValue_ > make_DelayedUnaryIsometricGreaterThanScalar(InputValue_ scalar)
Definition compare_helpers.hpp:256
DelayedUnaryIsometricCompareScalar< CompareOperation::EQUAL, InputValue_ > make_DelayedUnaryIsometricEqualScalar(InputValue_ scalar)
Definition compare_helpers.hpp:245
DelayedUnaryIsometricCompareVector< CompareOperation::LESS_THAN_OR_EQUAL, InputValue_, Vector_ > make_DelayedUnaryIsometricLessThanOrEqualVector(Vector_ vector, bool by_row)
Definition compare_helpers.hpp:365
DelayedUnaryIsometricCompareScalar< CompareOperation::LESS_THAN_OR_EQUAL, InputValue_ > make_DelayedUnaryIsometricLessThanOrEqualScalar(InputValue_ scalar)
Definition compare_helpers.hpp:289
DelayedUnaryIsometricCompareVector< CompareOperation::GREATER_THAN_OR_EQUAL, InputValue_, Vector_ > make_DelayedUnaryIsometricGreaterThanOrEqualVector(Vector_ vector, bool by_row)
Definition compare_helpers.hpp:352
DelayedUnaryIsometricCompareVector< CompareOperation::GREATER_THAN, InputValue_, Vector_ > make_DelayedUnaryIsometricGreaterThanVector(Vector_ vector, bool by_row)
Definition compare_helpers.hpp:326