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

◆ blend

auto eve::blend = detail::named_shuffle_2<blend_t> {}
inlineconstexpr
Note
You might be looking for eve::if_else_.

Defined in Header

#include <eve/module/core.hpp>

(TODO: support mixing more than 2 registers)

Accepts a pattern with just 0 and 1 that indicates number of the element for the current slot

blend([0, 1, 2, 3], [4, 5, 6, 7], pattern<1, 0, 0, 1>) -> [4, 1, 2, 7].

As any named shuffle, allows to specify a group size.

template<simd_value T, std::ptrdiff_t G, std::ptrdiff_t ...I> // (1)
template<simd_value T, std::ptrdiff_t G>
T blend(T x, T y, fixed<G>, pattern_formula auto gen)
template<simd_value T, std::ptrdiff_t ...I> // (2)
T blend(T x, T y, pattern_t<I...>)
template<simd_value T, std::ptrdiff_t ...I>
T blend(T x, T y, pattern_formula auto gen)
what callable can be a pattern formula
Definition pattern.hpp:99
Specifies that a type is a SIMD type. The concept simd_value<T> is satisfied if and only if T satisfi...
Definition vectorized.hpp:34
constexpr auto blend
a named shuffle for mixing 2 registers together, without changing positions.
Definition blend.hpp:150
SIMD register cardinal type.
Definition cardinal.hpp:15
Shuffling pattern.
Definition pattern.hpp:27

Parameters

  • x, y - values to shuffle.
  • G - (optional) - number of elements to treat as one.
  • pattern - how to shuffle elements I == 0 -> take a group from x I == 1 -> take a group from y
  • gen - eve::pattern_formula = alternative way to specify a pattern, computing it from index and size.

Return value

Returns a register with elements selected according to the mask.

Example

#include <eve/module/core.hpp>
#include <tts/tts.hpp>
int
main()
{
w_t x {0, 1, 2, 3};
w_t y {4, 5, 6, 7};
// basic example
TTS_EXPECT(eve::all(w_t{4, 1, 2, 7} == eve::blend(x, y, eve::pattern<1, 0, 0, 1>)));
// basic example, formula
TTS_EXPECT(
eve::all(w_t{0, 5, 2, 7} == eve::blend(x, y, [](int i, int /*size*/) { return i % 2; })));
// mixing groups
TTS_EXPECT(eve::all(w_t{4, 5, 2, 3} == eve::blend(x, y, eve::lane<2>, eve::pattern<1, 0>)));
}
constexpr callable_all_ all
Computes a bool value which is true if and only if all elements of x are not zero.
Definition all.hpp:58
constexpr auto pattern
Generate a shuffling pattern.
Definition pattern.hpp:90
Wrapper for SIMD registers.
Definition wide.hpp:70