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

◆ cumsum

auto eve::cumsum = functor<cumsum_t>
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto cumsum(eve::value auto ... xs) noexcept; // 1
constexpr auto cumsum(non_empty_product_type tup) noexcept; // 2
// Semantic options
constexpr auto cumsum[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 cumsum
callable converting a pack of values into a tuple of the cumulative sum of its values.
Definition cumsum.hpp:90
EVE Main Namespace.
Definition abi.hpp:19

Parameters

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

Return value

  1. return a kumi tuple of the values of the cumulated sums of all xs converted to the element type of the common value of the xs.
  2. same as 1., using the tuple elements.
  3. same of 1. or 2., but the computation is made on upgraded elements.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
#include <numeric>
int main()
{
kumi::tuple t{1.0, 2.0, 3.0, 10.0, 20.0, 30.0, 100.0, 200.0, 300.0, };
std::cout << "t " << t << std::endl;
std::cout << "eve::cumsum(t) " << eve::cumsum(t) << std::endl;
std::cout << "eve::cumsum(1.0, 2.0, 3.0, 10000.0) " << eve::cumsum(1.0, 2.0, 3.0, 10000.0) << std::endl;
std::cout << "eve::cumsum(t) " << eve::cumsum(t) << std::endl;
std::cout << "eve::cumsum[eve::widen](t) " << eve::cumsum[eve::widen](t) << std::endl;
std::array<std::int16_t, 4> a{1, 2, 3, 10000};
auto ta = std::bit_cast<kumi::result::fill_t<4, std::int16_t>>(a);
std::cout << "ta " << ta << std::endl;
std::cout << "eve::cumsum[eve::saturated](ta) " << eve::cumsum[eve::saturated](ta) << std::endl;
std::cout << "eve::cumsum(ta) " << eve::cumsum(ta) << std::endl;
std::cout << "eve::cumsum[eve::widen](ta) " << eve::cumsum[eve::widen](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, 10000.0f};
std::cout << "wt " << wt << std::endl;
std::cout << "eve::cumsum(wt) " << eve::cumsum(wt) << std::endl;
};
constexpr auto sqr
Computes the square of the parameter.
Definition sqr.hpp:98
Wrapper for SIMD registers.
Definition wide.hpp:94