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

◆ swap_adjacent

auto eve::swap_adjacent = detail::named_shuffle_1<swap_adjacent_t> {}
inlineconstexpr

Defined in Header

#include <eve/module/core.hpp>

Can apply an opteration for group of elements instead of elements. Group size has to be 0 < G < T::size()

template<simd_value T, std::ptrdiff_t G>
T swap_adjacent(T x, fixed<G>) // (1)
template<simd_value T>
T swap_adjacent(T x) // (2)
constexpr auto swap_adjacent
a named shuffle that goes all pairs of elements and swaps them: [0, 1, 2, 3] => [1,...
Definition swap_adjacent.hpp:117
SIMD register cardinal type.
Definition cardinal.hpp:15

Parameters

  • x - simd_value to shuffle
  • G - (optional) - number of elements to treat as one.

Return value

Return x where groups of contiguous G elements are swapped.

Example

#include <eve/module/core.hpp>
#include <tts/tts.hpp>
int main()
{
w_t x {0, 1, 2, 3};
TTS_EXPECT( eve::all( w_t{1, 0, 3, 2} == eve::swap_adjacent(x)) );
TTS_EXPECT( eve::all( w_t{1, 0, 3, 2} == eve::swap_adjacent(x, eve::lane<1>)) );
TTS_EXPECT( eve::all( w_t{2, 3, 0, 1} == eve::swap_adjacent(x, eve::lane<2>)) );
// lane<0> and lane<4> are not OK.
}
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
Wrapper for SIMD registers.
Definition wide.hpp:70