E.V.E
v2023.02.15
Loading...
Searching...
No Matches

◆ cumfun

auto eve::cumfun = functor<cumfun_t>
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto cumfun(typename f, eve::value auto ... xs) noexcept; // 1
constexpr auto cumfun(typename f, non_empty_product_type tup) noexcept; // 2
// Semantic options
constexpr auto cumfun[widen](/*any of the above overloads*/) noexcept; // 3
}
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition value.hpp:34
constexpr auto cumfun
callable converting a pack of values into a tuple of the cumulative application of a two parameter ev...
Definition cumfun.hpp:98
EVE Main Namespace.
Definition abi.hpp:19

Parameters

  • f: invocable of two arguments.
  • x: value arguments.
  • xs...: values arguments.
  • tup: kumi tuple of values.

Return value

  1. return a kumi tuple of the values of the cumulated values of all xs converted to the element type of the common value of the xs using f.
  2. same as 1., using the tuple elements.
  3. same of 1. or 2., but the computation is made on upgraded elements.
Note
currently cumfun can be applied with f being one of these EVE fonctors : eve::add, eve::mul, eve::min, eve::max``eve::bit_and, eve::bit_or, eve::bit_xor that define abelian monoids and each possess a well defined neutral element.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
#include <numeric>
int main()
{
kumi::tuple t{ 2.0f, 3.0f, 1.0f,10000.0f, 10.0f};
std::cout << "t " << t << std::endl;
std::cout << "eve::cumfun(add, t) " << eve::cumfun(eve::add, t) << std::endl;
std::cout << "eve::cumfun(add, 1.0, 2.0, 3.0, 10000.0) " << eve::cumfun(eve::add, 1.0, 2.0, 3.0, 10000.0) << std::endl;
std::cout << "eve::cumfun(add, t) " << eve::cumfun(eve::add, t) << std::endl;
std::cout << "eve::cumfun[eve::widen](add, t) " << eve::cumfun[eve::widen](eve::add, t) << std::endl;
std::cout << "eve::cumfun(mul, t) " << eve::cumfun(eve::mul, t) << std::endl;
std::cout << "eve::cumfun(min, t) " << eve::cumfun(eve::min, t) << std::endl;
std::array<std::int16_t, 4> a{1, 2, 3, 32767};
auto ta = std::bit_cast<kumi::result::fill_t<4, std::int16_t>>(a);
std::cout << "ta " << ta << std::endl;
std::cout << "eve::cumfun[eve::saturated](add, ta) " << eve::cumfun[eve::saturated](eve::add, ta) << std::endl;
std::cout << "eve::cumfun(add, ta) " << eve::cumfun(eve::add, ta) << std::endl;
std::cout << "eve::cumfun[eve::widen](add, ta) " << eve::cumfun[eve::widen](eve::add, ta) << std::endl;
using wf_t = eve::wide<float>;
auto e = wf_t([](auto i, auto){return eve::sqr(float(i)); });
kumi::tuple wt{wf_t(e), 2.0f, 30000.0f, 100000.0f};
std::cout << "wt " << wt << std::endl;
std::cout << "eve::cumfun(add, wt) " << eve::cumfun(eve::add, wt) << std::endl;
std::cout << "eve::cumfun(mul, wt) " << eve::cumfun(eve::mul, wt) << std::endl;
std::cout << "eve::cumfun(add, wt) " << eve::cumfun(eve::add, wt) << std::endl;
std::cout << "eve::cumfun(min, wt) " << eve::cumfun(eve::min, wt) << std::endl;
std::cout << "eve::cumfun(max, wt) " << eve::cumfun(eve::max, wt) << std::endl;
std::cout << "eve::cumfun(bit_and, wt) " << eve::cumfun(eve::bit_and, wt) << std::endl;
std::cout << "eve::cumfun(bit_or, wt) " << eve::cumfun(eve::bit_or, wt) << std::endl;
std::cout << "eve::cumfun(bit_xor, wt) " << eve::cumfun(eve::bit_xor, wt) << std::endl;
};
constexpr auto sqr
Computes the square of the parameter.
Definition sqr.hpp:98
constexpr auto min
Computes the minimum of its arguments.
Definition min.hpp:103
constexpr auto mul
tuple_callable computing the product of its arguments.
Definition mul.hpp:128
constexpr auto max
Computes the maximum of its arguments.
Definition max.hpp:101
constexpr auto add
tuple_callable computing the sum of its arguments.
Definition add.hpp:126
constexpr auto bit_xor
bit_callable object computing the bitwise XOR of its arguments.
Definition bit_xor.hpp:86
constexpr auto bit_and
bit_callable object computing the bitwise AND of its arguments.
Definition bit_and.hpp:93
constexpr auto bit_or
bit_callable object computing the bitwise OR of its arguments.
Definition bit_or.hpp:88
Wrapper for SIMD registers.
Definition wide.hpp:94