◆ reduce
Callable object computing a generalized fold operation. Required header: Member Functions
template<simd_value T> auto operator()( T v ) const noexcept;
template<simd_value T, Callable F> auto operator()( T v, F binary_op ) const noexcept;
Parameters
Return value Generalized fold of auto operator[]( conditional_expression auto cond ) const noexcept;
Higher-order function generating a masked version of eve::reduce Parameters
Return value A Callable object so that the expression Supported decorators
ExampleSee it live on Compiler Explorer #include <eve/function/reduce.hpp>
#include <eve/wide.hpp>
#include <iostream>
using wide_ft = eve::wide<float, eve::fixed<4>>;
using wide_it = eve::wide<std::int16_t, eve::fixed<4>>;
int main()
{
wide_ft pf = {0.5f,1.5f,2.5f,3.f};
wide_it qi = {2,3,4,5};
auto const sum = [](auto a, auto b) { return a+b; };
auto const prod = [](auto a, auto b) { return a*b; };
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qi = " << qi << '\n'
std::cout << "---- simd with splat" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qi = " << qi << '\n'
return 0;
}
constexpr splat_type const splat Higher-order Callable Object allowing reduction to generate wide results instead of scalars. Definition: splat.hpp:44 constexpr callable_reduce_ reduce Callable object computing a generalized fold operation. Definition: reduce.hpp:82 |