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

◆ swap_pairs

callable_swap_pairs_ eve::swap_pairs = {}
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template<value T, std::ptrdiff_t I0, std::ptrdiff_t I1 >
T swap_pairs(T x, index_t<I0> const & i0, index_t<I1> const & i1);
constexpr callable_swap_pairs_ swap_pairs
swap chosen pair of elements.
Definition swap_pairs.hpp:51
EVE Main Namespace.
Definition abi.hpp:18

Parameters

  • x : argument.
  • i0 : first index
  • i1 : second index

Return value

Return x with element i0 and i1 swapped. Action on scalar is identity. Assert if i0 or i1 are out of range.

Example

#include <eve/wide.hpp>
#include <iostream>
#include <eve/module/core.hpp>
int main()
{
wide_it pi = {1, 3, 7, 15};
pi = eve::inc(pi);
auto _0 =eve::index_t<0>();
auto _1 =eve::index_t<1>();
auto _2 =eve::index_t<2>();
auto _3 =eve::index_t<3>();
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> swap_pairs(pi, _0, _3) = " << eve::swap_pairs(pi, _0, _3) << '\n'
<< "-> swap_pairs(pi, _1, _2) = " << eve::swap_pairs(pi, _1, _2) << '\n'
<< "-> swap_pairs(pi, _0, _1) = " << eve::swap_pairs(pi, _0, _1) << '\n';
return 0;
}
constexpr auto inc
elementwise_callable object returning the input incremented by 1.
Definition inc.hpp:83
constexpr auto pi
Callable object computing the constant .
Definition pi.hpp:77
Wrapper for SIMD registers.
Definition wide.hpp:86