30 static constexpr bool known_sparse = (op_ == ArithmeticOperation::ADD ||
31 op_ == ArithmeticOperation::SUBTRACT ||
32 op_ == ArithmeticOperation::MULTIPLY);
34 static constexpr bool is_basic =
false;
43 template<
typename Index_,
typename InputValue_,
typename OutputValue_>
44 void dense(
bool, Index_, Index_, Index_ length,
const InputValue_* left_buffer,
const InputValue_* right_buffer, OutputValue_* output_buffer)
const {
45 for (Index_ i = 0; i < length; ++i) {
46 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
47 auto& val = output_buffer[i];
48 val = delayed_arithmetic<op_, true>(val, right_buffer[i]);
50 output_buffer[i] = delayed_arithmetic<op_, true>(left_buffer[i], right_buffer[i]);
55 template<
typename Index_,
typename InputValue_,
typename OutputValue_>
56 void dense(
bool, Index_,
const std::vector<Index_>& indices,
const InputValue_* left_buffer,
const InputValue_* right_buffer, OutputValue_* output_buffer)
const {
57 Index_ length = indices.size();
58 for (Index_ i = 0; i < length; ++i) {
59 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
60 auto& val = output_buffer[i];
61 val = delayed_arithmetic<op_, true>(val, right_buffer[i]);
63 output_buffer[i] = delayed_arithmetic<op_, true>(left_buffer[i], right_buffer[i]);
68 template<
typename Index_,
typename InputValue_,
typename OutputValue_>
74 constexpr bool must_have_both = (op_ == ArithmeticOperation::MULTIPLY &&
75 !std::numeric_limits<InputValue_>::has_quiet_NaN &&
76 !std::numeric_limits<InputValue_>::has_infinity);
78 return delayed_binary_isometric_sparse_operation<must_have_both>(
85 [](InputValue_ l, InputValue_ r) ->
auto {
86 return delayed_arithmetic<op_, true>(l, r);
91 template<
typename OutputValue_,
typename InputValue_,
typename Index_>
92 OutputValue_ fill(
bool, Index_)
const {
93 if constexpr(has_unsafe_divide_by_zero<op_, true, InputValue_, InputValue_>()) {
94 throw std::runtime_error(
"division by zero is not supported");
97 return delayed_arithmetic<op_, true, InputValue_>(0, 0);
101 bool is_sparse()
const {