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

◆ cumprod

auto eve::cumprod = functor<cumprod_t>
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto cumprod(eve::value auto ... xs) noexcept; // 1
constexpr auto cumprod(non_empty_product_type tup) noexcept; // 2
// Semantic options
constexpr auto cumprod[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 cumprod
callable converting a pack of values into a tuple of the cumulative product of its values.
Definition cumprod.hpp:89
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 products 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 <bit>
int main()
{
kumi::tuple t{1.0f, 2.0f, 3.0f, 10000.0f};
std::cout << "t " << t << std::endl;
std::cout << "eve::cumprod(t) " << eve::cumprod(t) << std::endl;
std::cout << "eve::cumprod(1.0, 2.0, 3.0, 10000.0) " << eve::cumprod(1.0, 2.0, 3.0, 10000.0) << std::endl;
std::cout << "eve::cumprod(t) " << eve::cumprod(t) << std::endl;
std::cout << "eve::cumprod[eve::widen](t) " << eve::cumprod[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 << "eve::cumprod[eve::saturated](ta) " << eve::cumprod[eve::saturated](ta) << std::endl;
std::cout << "eve::cumprod(ta) " << eve::cumprod(ta) << std::endl;
std::cout << "eve::cumprod[eve::widen](ta) " << eve::cumprod[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::cumprod(wt) " << eve::cumprod(wt) << std::endl;
};
constexpr auto sqr
Computes the square of the parameter.
Definition sqr.hpp:98
Wrapper for SIMD registers.
Definition wide.hpp:94