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

Detailed Description

Variables

constexpr auto eve::bit_and = functor<bit_and_t>
 bit_callable object computing the bitwise AND of its arguments.
constexpr auto eve::bit_andnot = functor<bit_andnot_t>
 bit_callable object computing the bitwise ANDNOT of its arguments.
constexpr auto eve::bit_cast = functor<bit_cast_t>
 Computes a bitwise reinterpretation of an object.
constexpr auto eve::bit_ceil = functor<bit_ceil_t>
 elementwise_callable object computing the smallest integral power of two that is not smaller than x.
constexpr auto eve::bit_flip = functor<bit_flip_t>
 strict_elementwise_callable object flipping the value the ith bit of each element.
constexpr auto eve::bit_floor = functor<bit_floor_t>
 elementwise_callable object computing, if x is not zero, the largest integral power of two that is not greater than x.
constexpr auto eve::bit_mask = functor<bit_mask_t>
 elementwise_callable object computing a bit mask full of zeroes or ones
constexpr auto eve::bit_not = functor<bit_not_t>
 elementwise_callable object computing the one complement of the parameter.
constexpr auto eve::bit_notand = functor<bit_notand_t>
 bit_callable object computing the bitwise NOTAND of its arguments.
constexpr auto eve::bit_notor = functor<bit_notor_t>
 bit_callable object computing the bitwise NOTOR of its arguments.
constexpr auto eve::bit_or = functor<bit_or_t>
 bit_callable object computing the bitwise OR of its arguments.
constexpr auto eve::bit_ornot = functor<bit_ornot_t>
 bit_callable object Computing the bitwise ORNOT of its arguments.
constexpr auto eve::bit_reverse = functor<bit_reverse_t>
 strict_elementwise_callable object reversing the bit order.
constexpr auto eve::bit_select = functor<bit_select_t>
 strict_elementwise_callable object selecting bits from a mask and two entries.
constexpr auto eve::bit_set = functor<bit_set_t>
 strict_elementwise_callable object setting to 1 the ith bit of each element.
constexpr auto eve::bit_shl = functor<shl_t>
 strict_elementwise_callable object computing a logical left shift.
constexpr auto eve::bit_shr = functor<bit_shr_t>
 strict_elementwise_callable object computing a logical right shift.
constexpr auto eve::bit_swap_adjacent = functor<bit_swap_adjacent_t>
 strict_elementwise_callable object swapping adjacent groups of n bits.
constexpr auto eve::bit_swap_pairs = functor<bit_swap_pairs_t>
 strict_elementwise_callable object swapping pairs.
constexpr auto eve::bit_ternary = functor<bit_ternary_t>
 callable object implementing ternary logic.
constexpr auto eve::bit_unset = functor<bit_unset_t>
 strict_elementwise_callable object setting to 01 the ith bit of each element.
constexpr auto eve::bit_width = functor<bit_width_t>
 elementwise_callable object Computing elementwise the number of bits needed to store the parameter.
constexpr auto eve::bit_xor = functor<bit_xor_t>
 bit_callable object computing the bitwise XOR of its arguments.
constexpr auto eve::byte_reverse = functor<byte_reverse_t>
 elementwise_callable object reversing the byte order.
constexpr auto eve::byte_swap_adjacent = functor<byte_swap_adjacent_t>
 strict_elementwise_callable object that swap adjacent groups of N bytes.
constexpr auto eve::byte_swap_pairs = functor<byte_swap_pairs_t>
 strict_elementwise_callable object swapping chosen pairs of bytes in each vector element.
constexpr auto eve::countl_one = functor<countl_one_t>
 elementwise_callable object computing the number of consecutive bits set in a value starting from left
constexpr auto eve::countl_zero = functor<countl_zero_t>
 elementwise_callable object computing the number of consecutive bits unset in a value starting from left
constexpr auto eve::countr_one = functor<countr_one_t>
 elementwise_callable object computing the number of consecutive bits set in a value starting from right.
constexpr auto eve::countr_zero = functor<countr_zero_t>
 elementwise_callable object computing the number of consecutive bits unset in a value starting from right.
constexpr auto eve::firstbitset = functor<firstbitset_t>
 Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit set in the input.
constexpr auto eve::firstbitunset = functor<firstbitunset_t>
 Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit unset in the input.
constexpr auto eve::hi = functor<hi_t>
 elementwise_callable computing the most significant half of each lane.
constexpr auto eve::lo = functor<lo_t>
 Computes the least significant half of each lane.
constexpr auto eve::lohi = functor<lohi_t>
 elementwise_callable computing the lohi pair of values.
constexpr auto eve::popcount = functor<popcount_t>
 elementwise_callable object computing elementwise the number of bits set in the parameter.
constexpr auto eve::rotl = functor<rotl_t>
 Bitwise rotation to the left.
constexpr auto eve::rotr = functor<rotr_t>
 Bitwise rotation to the right.
constexpr auto eve::rshl = functor<rshl_t>
 Computes the arithmetic left/right shift operation according to shift sign.
constexpr auto eve::rshr = functor<rshr_t>
 Computes the arithmetic right/left shift operation according to shift sign.
constexpr auto eve::shl = functor<shl_t>
 Computes the arithmetic left shift operation.
constexpr auto eve::shr = functor<shr_t>
 Computes the arithmetic right shift operation.
constexpr auto eve::swap_pairs = functor<swap_pairs_t>
 swap chosen pair of elements.

Variable Documentation

◆ bit_and

auto eve::bit_and = functor<bit_and_t>
inlineconstexpr

bit_callable object computing the bitwise AND of its arguments.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto bit_and(value auto x, value auto ... xs) noexcept; // 1
constexpr auto bit_and(eve::non_empty_product_type auto const& tup) noexcept; // 2
// Lanes masking
constexpr auto bit_and[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto bit_and[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:134
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 bit_and
bit_callable object computing the bitwise AND of its arguments.
Definition bit_and.hpp:93
EVE Main Namespace.
Definition abi.hpp:19

Parameters

Return value

  1. The value of the bitwise AND of its arguments converted to the common bit_value of the arguments
  2. equivalent to the call on the elements of the tuple.
  3. The operation is performed conditionally. This is only supported when all parameters share the same number of lanes or are scalars.
Note
Although the infix notation with & is supported for two parameters, the & operator on standard scalar types is the original one and so can lead to automatic promotion. Moreover, and due to C++ limitations is not available for floating point scalar entries.

External reference

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wf1{0.0, -4.0, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, -4, 1, -1, 2, -2, 3, -3};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
eve::wide wu1{7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "-> bit_and(wf0, wf1) = " << eve::bit_and(wf0, wf1) << "\n";
std::cout << "-> bit_and[ignore_last(2)](wf0, wf1) = " << eve::bit_and[eve::ignore_last(2)](wf0, wf1) << "\n";
std::cout << "-> bit_and[wf0 != 0](wf0, wf1) = " << eve::bit_and[wf0 != 0](wf0, wf1) << "\n";
std::cout << "-> bit_and(wu0, wu1) = " << eve::bit_and(wu0, wu1) << "\n";
std::cout << "-> bit_and(wi0, wi1) = " << eve::bit_and(wi0, wi1) << "\n";
std::cout << "-> bit_and(2.,1.,2.,3.,-3.,-4.,-6.0) = " << eve::bit_and(2.0, 1.0, 2.0, 3.0, -3.0, -4., -6.0) << "\n";
std::cout << "->:bit_and(2.1,2.,2.,2.,2.,2.,2.) = " << eve::bit_and(2.1,2.,2.,2.,2.,2.,2.) << "\n";
}
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition conditional.hpp:361
Wrapper for SIMD registers.
Definition wide.hpp:94

◆ bit_andnot

auto eve::bit_andnot = functor<bit_andnot_t>
inlineconstexpr

bit_callable object computing the bitwise ANDNOT of its arguments.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto bit_andnot(value auto x, value auto ... xs) noexcept; // 1
constexpr auto bit_andnot(eve::non_empty_product_type auto const& tup) noexcept; // 2
// Lanes masking
constexpr auto bit_andnot[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto bit_andnot[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
}
constexpr auto bit_andnot
bit_callable object computing the bitwise ANDNOT of its arguments.
Definition bit_andnot.hpp:91

Parameters

Return value

  1. The return value type is to the common bit_value of the parameters. Each parameter is converted to this type and then:
    • For two parameters it computes the bitwise ANDNOT of the two parameters
    • For more than two parameters the call is semantically equivalent to bit_andnot(a0, bit_and(xs...))
  2. equivalent to the call on the elements of the tuple.
  3. The operation is performed conditionally. This is only supported when all parameters share the same number of lanes or are scalars.

External references

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wf1{0.0, -4.0, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, -4, 1, -1, 2, -2, 3, -3};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
eve::wide wu1{7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "-> bit_andnot(wf0, wf1) = " << eve::bit_andnot(wf0, wf1) << "\n";
std::cout << "-> bit_andnot[ignore_last(2)](wf0, wf1) = " << eve::bit_andnot[eve::ignore_last(2)](wf0, wf1) << "\n";
std::cout << "-> bit_andnot[wf0 != 0](wf0, wf1) = " << eve::bit_andnot[wf0 != 0](wf0, wf1) << "\n";
std::cout << "-> bit_andnot(wu0, wu1) = " << eve::bit_andnot(wu0, wu1) << "\n";
std::cout << "-> bit_andnot(wi0, wi1) = " << eve::bit_andnot(wi0, wi1) << "\n";
std::cout << "-> bit_andnot(2.,1.,2.,3.,-3.,-4.,-6.0) = " << eve::bit_andnot(2.0, 1.0, 2.0, 3.0, -3.0, -4., -6.0) << "\n";
std::cout << "->:bit_andnot(2.1,2.,2.,2.,2.,2.,2.) = " << eve::bit_andnot(2.1,2.,2.,2.,2.,2.,2.) << "\n";
using w_t = eve::wide<double>;
std::cout << "->:bit_andnot(w_t(2.1),w_t(2.),w_t(2.),w_t(2.),w_t(2.),w_t(2.),w_t(2.)) = " << eve::bit_andnot(w_t(2.1),w_t(2.),w_t(2.),w_t(2.),w_t(2.),w_t(2.),w_t(2.)) << "\n";
}

◆ bit_cast

auto eve::bit_cast = functor<bit_cast_t>
inlineconstexpr

Computes a bitwise reinterpretation of an object.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
constexpr auto bit_cast operator()(value x, as<scalar_value> t) noexcept;
}
constexpr auto bit_cast
Computes a bitwise reinterpretation of an object.
Definition bit_cast.hpp:83
Lightweight type-wrapper.
Definition as.hpp:29

Parameters

Template parameters

  • To: scalar type to which each element of x is casted

Return value

The bits of x of type From reinterpreted as being those of a variable of type To is returned.

Every bit in the value representation of the returned To object is equal to the corresponding bit in the object representation of from. The values of padding bits in the returned To object are unspecified.

If there is no value of type To corresponding to the value representation produced, the behavior is undefined. If there are multiple such values, which value is produced is unspecified.

External reference

Example

// revision 2
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0f, 1.0f, 2.0f, 3.0f, -1.0f, -2.0f, -3.0f, -4.0f};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> bit_cast(wf0, as(wu)) = " << eve::bit_cast(wf0, eve::as(wu0)) << "\n";
std::cout << "-> bit_cast(wf0, as(wu0))= " << eve::bit_cast(wf0, eve::as(wu0)) << "\n";
std::cout << "-> bit_cast(wi0, as(wu0))= " << eve::bit_cast(wi0, eve::as(wu0)) << "\n";
std::cout << "-> bit_cast(wu0, as(wi0))= " << eve::bit_cast(wu0, eve::as(wi0)) << "\n";
std::cout << "-> bit_cast(wi0, as(wu0))= " << eve::bit_cast(wi0, eve::as(wu0)) << "\n";
std::cout << "-> bit_cast(wu, as(wi0)) = " << eve::bit_cast(wu0, eve::as(wi0)) << "\n";
}

◆ bit_ceil

auto eve::bit_ceil = functor<bit_ceil_t>
inlineconstexpr

elementwise_callable object computing the smallest integral power of two that is not smaller than x.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto bit_ceil(value auto x) noexcept; // 1
// Lanes masking
constexpr auto bit_ceil[conditional_expr auto c](value auto x) noexcept; // 2
constexpr auto bit_ceil[logical_value auto m](value auto x) noexcept; // 2
}
constexpr auto bit_ceil
elementwise_callable object computing the smallest integral power of two that is not smaller than x.
Definition bit_ceil.hpp:77

Parameters

Return value

  1. The value of the smallest integral power of two that is not smaller than x is returned. If that value is not representable in the input type, the behavior is undefined.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> bit_ceil(wf0) = " << eve::bit_ceil(wf0) << "\n";
std::cout << "-> bit_ceil[ignore_last(2)](wf0) = " << eve::bit_ceil[eve::ignore_last(2)](wf0) << "\n";
std::cout << "-> bit_ceil[wf0 != 0](wf0) = " << eve::bit_ceil[wf0 != 0](wf0) << "\n";
std::cout << "-> bit_ceil(wu0) = " << eve::bit_ceil(wu0) << "\n";
std::cout << "-> bit_ceil[ignore_last(2)](wu0) = " << eve::bit_ceil[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> bit_ceil[wu0 != 0](wu0) = " << eve::bit_ceil[wu0 != 0](wu0) << "\n";
std::cout << "-> bit_ceil(wi0) = " << eve::bit_ceil(wi0) << "\n";
std::cout << "-> bit_ceil[ignore_last(2)](wi0) = " << eve::bit_ceil[eve::ignore_last(2)](wi0) << "\n";
std::cout << "-> bit_ceil[wi0 != 0](wi0) = " << eve::bit_ceil[wi0 != 0](wi0) << "\n";
}

◆ bit_flip

auto eve::bit_flip = functor<bit_flip_t>
inlineconstexpr

strict_elementwise_callable object flipping the value the ith bit of each element.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto bit_flip(integral_value auto x, integral_value auto i) noexcept; // 1
// Lanes masking
constexpr auto bit_flip[conditional_expr auto c](integral_value auto x, integral_value auto i) noexcept; // 2
constexpr auto bit_flip[logical_value auto m](integral_value auto x, integral_value auto i) noexcept; // 2
}
The concept integral_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:51
constexpr auto bit_flip
strict_elementwise_callable object flipping the value the ith bit of each element.
Definition bit_flip.hpp:72

Parameters

Return value

  1. The value of the parameter is returned with the ith bit flipped. if the index is out of range the call will assert.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide pi = {1, 3, 7, 15, 31, 63, 127, 255};
std::cout << "<- pi = " << pi << '\n';
std::cout << "-> bit_flip(pi, 1) = " << eve::bit_flip(pi, 1) << '\n';
std::cout << "-> bit_flip(pi, 2) = " << eve::bit_flip(pi, 2) << '\n';
std::cout << "-> bit_flip(pi, 3) = " << eve::bit_flip(pi, 3) << '\n';
std::cout << "-> bit_flip(pi, 4) = " << eve::bit_flip(pi, 4) << '\n';
std::cout << "-> bit_flip(pi, 8) = " << eve::bit_flip(pi, 8) << '\n';
std::cout << "-> bit_flip[pi > 15](pi, 1) = " << eve::bit_flip[pi > 15](pi, 1) << '\n';
std::cout << "-> bit_flip[pi > 15](pi, 2) = " << eve::bit_flip[pi > 15](pi, 2) << '\n';
std::cout << "-> bit_flip[pi > 15](pi, 3) = " << eve::bit_flip[pi > 15](pi, 3) << '\n';
std::cout << "-> bit_flip[pi > 15](pi, 4) = " << eve::bit_flip[pi > 15](pi, 4) << '\n';
std::cout << "-> bit_flip[pi > 15](pi, 8) = " << eve::bit_flip[pi > 15](pi, 8) << '\n';
}
constexpr auto pi
Callable object computing the constant .
Definition pi.hpp:79

◆ bit_floor

auto eve::bit_floor = functor<bit_floor_t>
inlineconstexpr

elementwise_callable object computing, if x is not zero, the largest integral power of two that is not greater than x.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_floor(value auto x) noexcept; // 1
// Lanes masking
constexpr auto bit_floor[conditional_expr auto c](value auto x) noexcept; // 2
constexpr auto bit_floor[logical_value auto m](value auto x) noexcept; // 2
}
constexpr auto bit_floor
elementwise_callable object computing, if x is not zero, the largest integral power of two that is no...
Definition bit_floor.hpp:77

Parameters

Return value

  1. The value of the largest integral power of two that is not greater than x is returned. If x is zero returns zero.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> bit_floor(wf0) = " << eve::bit_floor(wf0) << "\n";
std::cout << "-> bit_floor[ignore_last(2)](wf0) = " << eve::bit_floor[eve::ignore_last(2)](wf0) << "\n";
std::cout << "-> bit_floor[wf0 != 0](wf0) = " << eve::bit_floor[wf0 != 0](wf0) << "\n";
std::cout << "-> bit_floor(wu0) = " << eve::bit_floor(wu0) << "\n";
std::cout << "-> bit_floor[ignore_last(2)](wu0) = " << eve::bit_floor[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> bit_floor[wu0 != 0](wu0) = " << eve::bit_floor[wu0 != 0](wu0) << "\n";
std::cout << "-> bit_floor(wi0) = " << eve::bit_floor(wi0) << "\n";
std::cout << "-> bit_floor[ignore_last(2)](wi0) = " << eve::bit_floor[eve::ignore_last(2)](wi0) << "\n";
std::cout << "-> bit_floor[wi0 != 0](wi0) = " << eve::bit_floor[wi0 != 0](wi0) << "\n";
}

◆ bit_mask

auto eve::bit_mask = functor<bit_mask_t>
inlineconstexpr

elementwise_callable object computing a bit mask full of zeroes or ones

Callable Signatures

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_mask(value auto x) noexcept; // 1
// Lanes masking
constexpr auto bit_mask[conditional_expr auto c](value auto x) noexcept; // 2
constexpr auto bit_mask[logical_value auto m](value auto x) noexcept; // 2
}
constexpr auto bit_mask
elementwise_callable object computing a bit mask full of zeroes or ones
Definition bit_mask.hpp:69

Parameters

Return value

  1. For each elementwise of x:
    • if the element is zero, an element with all bits unset is returned.
    • else an element of the type with all bits set is returned.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> bit_mask(wf0) = " << eve::bit_mask(wf0) << "\n";
std::cout << "-> bit_mask[ignore_last(2)](wf0) = " << eve::bit_mask[eve::ignore_last(2)](wf0) << "\n";
std::cout << "-> bit_mask[wf0 != 0](wf0) = " << eve::bit_mask[wf0 != 0](wf0) << "\n";
std::cout << "-> bit_mask(wu0) = " << eve::bit_mask(wu0) << "\n";
std::cout << "-> bit_mask[ignore_last(2)](wu0) = " << eve::bit_mask[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> bit_mask[wu0 != 0](wu0) = " << eve::bit_mask[wu0 != 0](wu0) << "\n";
std::cout << "-> bit_mask(wi0) = " << eve::bit_mask(wi0) << "\n";
std::cout << "-> bit_mask[ignore_last(2)](wi0) = " << eve::bit_mask[eve::ignore_last(2)](wi0) << "\n";
std::cout << "-> bit_mask[wi0 != 0](wi0) = " << eve::bit_mask[wi0 != 0](wi0) << "\n";
}

◆ bit_not

auto eve::bit_not = functor<bit_not_t>
inlineconstexpr

elementwise_callable object computing the one complement of the parameter.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_not(value auto x) noexcept; // 1
// Lanes masking
constexpr auto bit_not[conditional_expr auto c](value auto x) noexcept; // 2
constexpr auto bit_not[logical_value auto m](value auto x) noexcept; // 2
}
constexpr auto bit_not
elementwise_callable object computing the one complement of the parameter.
Definition bit_not.hpp:71

Parameters

Return value

  1. The value of the bitwise NOT of the parameter is returned.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> bit_not(wf0) = " << eve::bit_not(wf0) << "\n";
std::cout << "-> bit_not[ignore_last(2)](wf0) = " << eve::bit_not[eve::ignore_last(2)](wf0) << "\n";
std::cout << "-> bit_not[wf0 != 0](wf0) = " << eve::bit_not[wf0 != 0](wf0) << "\n";
std::cout << "-> bit_not(wu0) = " << eve::bit_not(wu0) << "\n";
std::cout << "-> bit_not[ignore_last(2)](wu0) = " << eve::bit_not[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> bit_not[wu0 != 0](wu0) = " << eve::bit_not[wu0 != 0](wu0) << "\n";
std::cout << "-> bit_not(wi0) = " << eve::bit_not(wi0) << "\n";
std::cout << "-> bit_not[ignore_last(2)](wi0) = " << eve::bit_not[eve::ignore_last(2)](wi0) << "\n";
std::cout << "-> bit_not[wi0 != 0](wi0) = " << eve::bit_not[wi0 != 0](wi0) << "\n";
}

◆ bit_notand

auto eve::bit_notand = functor<bit_notand_t>
inlineconstexpr

bit_callable object computing the bitwise NOTAND of its arguments.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto bit_notand(value auto x, value auto ... xs) noexcept; // 1
constexpr auto bit_notand(eve::non_empty_product_type auto const& tup) noexcept; // 2
// Lanes masking
constexpr auto bit_notand[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto bit_notand[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
}
constexpr auto bit_notand
bit_callable object computing the bitwise NOTAND of its arguments.
Definition bit_notand.hpp:88

Parameters

Return value

  1. The return value type is the common bit_value of the parameters. Each parameter is converted to this type and then:
    • For two parameters it computes the bitwise NOTAND of the two parameters
    • For more than two parameters the call is semantically equivalent to bit_notand(a0, bit_and(xs...))
  2. equivalent to the call on the elements of the tuple.
  3. The operation is performed conditionally. This is only supported when all parameters share the same number of lanes or are scalars.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wf1{0.0, -4.0, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, -4, 1, -1, 2, -2, 3, -3};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
eve::wide wu1{7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "-> bit_notand(wf0, wf1) = " << eve::bit_notand(wf0, wf1) << "\n";
std::cout << "-> bit_notand[ignore_last(2)](wf0, wf1) = " << eve::bit_notand[eve::ignore_last(2)](wf0, wf1) << "\n";
std::cout << "-> bit_notand[wf0 != 0](wf0, wf1) = " << eve::bit_notand[wf0 != 0](wf0, wf1) << "\n";
std::cout << "-> bit_notand(wu0, wu1) = " << eve::bit_notand(wu0, wu1) << "\n";
std::cout << "-> bit_notand(wi0, wi1) = " << eve::bit_notand(wi0, wi1) << "\n";
std::cout << "-> bit_notand(2.,1.,2.,3.,-3.,-4.,-6.0) = " << eve::bit_notand(2.0, 1.0, 2.0, 3.0, -3.0, -4., -6.0) << "\n";
std::cout << "->:bit_notand(2.1,2.,2.,2.,2.,2.,2.) = " << eve::bit_notand(2.1,2.,2.,2.,2.,2.,2.) << "\n";
}

◆ bit_notor

auto eve::bit_notor = functor<bit_notor_t>
inlineconstexpr

bit_callable object computing the bitwise NOTOR of its arguments.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto bit_notor(value auto x, value auto ... xs) noexcept; // 1
constexpr auto bit_notor(eve::non_empty_product_type auto const& tup) noexcept; // 2
// Lanes masking
constexpr auto bit_notor[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto bit_notor[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
}
constexpr auto bit_notor
bit_callable object computing the bitwise NOTOR of its arguments.
Definition bit_notor.hpp:88

Parameters

Return value

  1. The return value type is the common bit_value of the parameters. Each parameter is converted to this type and then:
    • For two parameters it computes the bitwise NOTOR of the two parameters
    • For more than two parameters the call is semantically equivalent to bit_notor(a0, bit_or(xs...))
  2. equivalent to the call on the elements of the tuple.
  3. The operation is performed conditionally. This is only supported when all parameters share the same number of lanes or are scalars.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wf1{0.0, -4.0, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, -4, 1, -1, 2, -2, 3, -3};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
eve::wide wu1{7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "-> bit_notor(wf0, wf1) = " << eve::bit_notor(wf0, wf1) << "\n";
std::cout << "-> bit_notor[ignore_last(2)](wf0, wf1) = " << eve::bit_notor[eve::ignore_last(2)](wf0, wf1) << "\n";
std::cout << "-> bit_notor[wf0 != 0](wf0, wf1) = " << eve::bit_notor[wf0 != 0](wf0, wf1) << "\n";
std::cout << "-> bit_notor(wu0, wu1) = " << eve::bit_notor(wu0, wu1) << "\n";
std::cout << "-> bit_notor(wi0, wi1) = " << eve::bit_notor(wi0, wi1) << "\n";
std::cout << "-> bit_notor(2.,1.,2.,3.,-3.,-4.,-6.0) = " << eve::bit_notor(2.0, 1.0, 2.0, 3.0, -3.0, -4., -6.0) << "\n";
std::cout << "->:bit_notor(2.1,2.,2.,2.,2.,2.,2.) = " << eve::bit_notor(2.1,2.,2.,2.,2.,2.,2.) << "\n";
}

◆ bit_or

auto eve::bit_or = functor<bit_or_t>
inlineconstexpr

bit_callable object computing the bitwise OR of its arguments.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto bit_or(value auto x, value auto ... xs) noexcept; // 1
constexpr auto bit_or(eve::non_empty_product_type auto const& tup) noexcept; // 2
// Lanes masking
constexpr auto bit_or[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto bit_or[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
}
constexpr auto bit_or
bit_callable object computing the bitwise OR of its arguments.
Definition bit_or.hpp:88

Parameters

Return value

  1. The value of the bitwise OR of its arguments converted to the common bit_value of the parameters.
  2. Equivalent to the call on the elements of the tuple.
  3. The operation is performed conditionally. This is only supported when all parameters share the same number of lanes or are scalars.
Note
Although the infix notation with | is supported for two parameters, the | operator on standard scalar types is the original one and so can lead to automatic promotion. Moreover, and due to C++ limitations is not available for floating point scalar entries.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wf1{0.0, -4.0, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, -4, 1, -1, 2, -2, 3, -3};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
eve::wide wu1{7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "-> bit_or(wf0, wf1) = " << eve::bit_or(wf0, wf1) << "\n";
std::cout << "-> bit_or[ignore_last(2)](wf0, wf1) = " << eve::bit_or[eve::ignore_last(2)](wf0, wf1) << "\n";
std::cout << "-> bit_or[wf0 != 0](wf0, wf1) = " << eve::bit_or[wf0 != 0](wf0, wf1) << "\n";
std::cout << "-> bit_or(wu0, wu1) = " << eve::bit_or(wu0, wu1) << "\n";
std::cout << "-> bit_or(wi0, wi1) = " << eve::bit_or(wi0, wi1) << "\n";
std::cout << "-> bit_or(2.,1.,2.,3.,-3.,-4.,-6.0) = " << eve::bit_or(2.0, 1.0, 2.0, 3.0, -3.0, -4., -6.0) << "\n";
std::cout << "->:bit_or(2.1,2.,2.,2.,2.,2.,2.) = " << eve::bit_or(2.1,2.,2.,2.,2.,2.,2.) << "\n";
}

◆ bit_ornot

auto eve::bit_ornot = functor<bit_ornot_t>
inlineconstexpr

bit_callable object Computing the bitwise ORNOT of its arguments.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto bit_ornot(value auto x, value auto ... xs) noexcept; // 1
// Lanes masking
constexpr auto bit_ornot[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 2
constexpr auto bit_ornot[logical_value auto m](/*any of the above overloads*/) noexcept; // 2
}
constexpr auto bit_ornot
bit_callable object Computing the bitwise ORNOT of its arguments.
Definition bit_ornot.hpp:84

Parameters

Return value

  1. The return value type isbit_value of the parameters. Each parameter is converted to this type and then:
    • For two parameters it computes the bitwise ORNOT of the two parameters
    • For more than two parameters the call is semantically equivalent to bit_ornot(a0, bit_and(xs...))
  2. The operation is performed conditionally. This is only supported when all parameters share the same number of lanes or are scalars.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wf1{0.0, -4.0, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, -4, 1, -1, 2, -2, 3, -3};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
eve::wide wu1{7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "-> bit_ornot(wf0, wf1) = " << eve::bit_ornot(wf0, wf1) << "\n";
std::cout << "-> bit_ornot[ignore_last(2)](wf0, wf1) = " << eve::bit_ornot[eve::ignore_last(2)](wf0, wf1) << "\n";
std::cout << "-> bit_ornot[wf0 != 0](wf0, wf1) = " << eve::bit_ornot[wf0 != 0](wf0, wf1) << "\n";
std::cout << "-> bit_ornot(wu0, wu1) = " << eve::bit_ornot(wu0, wu1) << "\n";
std::cout << "-> bit_ornot(wi0, wi1) = " << eve::bit_ornot(wi0, wi1) << "\n";
std::cout << "-> bit_ornot(2.,1.,2.,3.,-3.,-4.,-6.0) = " << eve::bit_ornot(2.0, 1.0, 2.0, 3.0, -3.0, -4., -6.0) << "\n";
std::cout << "->:bit_ornot(2.1,2.,2.,2.,2.,2.,2.) = " << eve::bit_ornot(2.1,2.,2.,2.,2.,2.,2.) << "\n";
}

◆ bit_reverse

auto eve::bit_reverse = functor<bit_reverse_t>
inlineconstexpr

strict_elementwise_callable object reversing the bit order.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto bit_reverse(unsigned_value auto x) noexcept; // 1
constexpr auto bit_reverse(unsigned_value auto x integral_scalar_value n) noexcept; // 2
// Lanes masking
constexpr auto bit_reverse[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto bit_reverse[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
}
Specify that a type represents an integral scalar value. The concept integral_scalar_value<T> is sati...
Definition vectorizable.hpp:28
The concept unsigned_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:84
constexpr auto bit_reverse
strict_elementwise_callable object reversing the bit order.
Definition bit_reverse.hpp:84

Parameters

Return value

  1. The values of the of the parameter are returned with bits in reversed order.
  2. if n is present :
    • if n == 0 the call returns x
    • if 2*n is greater or equal to the size of the element type of x, the call is identical to reverse(x).
    • otherwise the first n bits and the last n bits of each element of x are swapped in reverse order and the central remaining bits are unchanged.
  3. The operation is performed conditionally.

Example

// revision 1
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> bit_reverse(wu0) = " << eve::bit_reverse(wu0) << "\n";
std::cout << "-> bit_reverse(wu0, 3) = " << eve::bit_reverse(wu0, 3) << "\n";
std::cout << "-> bit_reverse[ignore_last(2)](wu0) = " << eve::bit_reverse[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> bit_reverse[wu0 != 2u](wu0) = " << eve::bit_reverse[wu0 != 2u](wu0) << "\n";
}

◆ bit_select

auto eve::bit_select = functor<bit_select_t>
inlineconstexpr

strict_elementwise_callable object selecting bits from a mask and two entries.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_select((auto value auto m, auto value x, auto value y) noexcept;
}
constexpr auto bit_select
strict_elementwise_callable object selecting bits from a mask and two entries.
Definition bit_select.hpp:69

Parameters

Return value The value of the selected bits is returned.

  • In a short way (omitting casting details to bring all bit sizes of the parameters equal), it means that the result is composed of the bits of x for which the corresponding bit of m is set and the bits of y for which the corresponding bit of m is unset.
  • If x or y is an simd value, the type of the result has the element type of the common type of x and y and the maximum of the cardinals of m and this type, otherwise it is the type of x.

Example

// revision 2
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wl = {2, -3, 0, 1 << 10};
eve::wide wi = {3, -2, 4, 2 };
eve::wide wu = {0u, 1023u, 1u, ~0u << 8};
std::cout << "<- wl = " << wl << "\n";
std::cout << "<- wi = " << wi << "\n";
std::cout << "<- wu = " << wu << "\n";
std::cout << "-> bit_select(wl, wu, 0) = " << eve::bit_select(wl, wu, ~0u) << "\n";
std::cout << "-> bit_select(wl, wi, 0) = " << eve::bit_select(wl, wi, -1) << "\n";
}

◆ bit_set

auto eve::bit_set = functor<bit_set_t>
inlineconstexpr

strict_elementwise_callable object setting to 1 the ith bit of each element.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_set(integral_value auto x, integral_value auto n) noexcept; // 1
// Lanes masking
constexpr auto bit_set[conditional_expr auto c](integral_value, auto x integral_value auto n) noexcept; // 2
constexpr auto bit_set[logical_value auto m](integral_value auto x, integral_value auto n) noexcept; // 2
}
constexpr auto bit_set
strict_elementwise_callable object setting to 1 the ith bit of each element.
Definition bit_set.hpp:69

Parameters

Return value

  1. The value of the parameter is returned with the ith bit set to 1. If the index is out of range the call will assert.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide pi = {1, 3, 7, 15, 31, 63, 127, 255};
std::cout << "<- pi = " << pi << '\n';
std::cout << "-> bit_set(pi, 1) = " << eve::bit_set(pi, 1) << '\n';
std::cout << "-> bit_set(pi, 2) = " << eve::bit_set(pi, 2) << '\n';
std::cout << "-> bit_set(pi, 3) = " << eve::bit_set(pi, 3) << '\n';
std::cout << "-> bit_set(pi, 4) = " << eve::bit_set(pi, 4) << '\n';
std::cout << "-> bit_set(pi, 8) = " << eve::bit_set(pi, 8) << '\n';
std::cout << "-> bit_set[pi > 15](pi, 1) = " << eve::bit_set[pi > 15](pi, 1) << '\n';
std::cout << "-> bit_set[pi > 15](pi, 2) = " << eve::bit_set[pi > 15](pi, 2) << '\n';
std::cout << "-> bit_set[pi > 15](pi, 3) = " << eve::bit_set[pi > 15](pi, 3) << '\n';
std::cout << "-> bit_set[pi > 15](pi, 4) = " << eve::bit_set[pi > 15](pi, 4) << '\n';
std::cout << "-> bit_set[pi > 15](pi, 8) = " << eve::bit_set[pi > 15](pi, 8) << '\n';
}

◆ bit_shl

auto eve::bit_shl = functor<shl_t>
inlineconstexpr

strict_elementwise_callable object computing a logical left shift.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_shl(integral_value auto, x integral_value auto n) noexcept; // 1
// Lanes masking
constexpr auto bit_shl[conditional_expr auto c](integral_value auto x, integral_value auto n) noexcept; // 2
constexpr auto bit_shl[logical_value auto m](integral_value auto x, integral_value auto n) noexcept; // 2
}
constexpr auto bit_shl
strict_elementwise_callable object computing a logical left shift.
Definition bit_shl.hpp:63

Parameters

Return value

  1. The value of the logical left shift is returned.
  2. The operation is performed conditionally.
Note
  • The call bit_shl(x, n) is equivalent to x << n if x is an simd value.
  • The types must share the same cardinal or be scalar and if \(N\) is the size in bits of the element type of x, all elements of n must belong to the interval \([0, N[\) or the result is undefined.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, 4, 1, 1, 2, 2, 3, 3};
eve::wide wi2{0, -4, 1, -1, 2, -2, 3, -3};
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wi2 = " << wi2 << "\n";
std::cout << "-> bit_shl(wi0, wi1) = " << eve::bit_shl(wi0, wi1) << "\n";
std::cout << "-> bit_shl[ignore_last(2)](wi0, wi1) = " << eve::bit_shl[eve::ignore_last(2)](wi0, wi1) << "\n";
std::cout << "-> bit_shl[wi2 > 0](wi0, wi2) = " << eve::bit_shl[wi2 > 0](wi0, wi2) << "\n";
}

◆ bit_shr

auto eve::bit_shr = functor<bit_shr_t>
inlineconstexpr

strict_elementwise_callable object computing a logical right shift.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_shr(integral_value auto x, integral_value auto n) noexcept; // 1
// Lanes masking
constexpr auto bit_shr[conditional_expr auto c](integral_value auto x, integral_value auto n) noexcept; // 2
constexpr auto bit_shr[logical_value auto m](integral_value auto x, integral_value auto n) noexcept; // 2
}
constexpr auto bit_shr
strict_elementwise_callable object computing a logical right shift.
Definition bit_shr.hpp:85

Parameters

Return value

  1. The value of the logical right shift is returned.
  2. The operation is performed conditionally.
Note
  • The call bit_shr(x, n) is equivalent to x >> n if x is an unsigned_value.
  • The types must share the same cardinal or be scalar and if \(N\) is the size in bits of the element type of T, all elements of n must belong to the interval: \([0, N[\) or the result is undefined.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, 4, 1, 1, 2, 2, 3, 3};
eve::wide wi2{0, -4, 1, -1, 2, -2, 3, -3};
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "-> bit_shr(wi0, wi1) = " << eve::bit_shr(wi0, wi1) << "\n";
std::cout << "-> bit_shr[ignore_last(2)](wi0, wi1) = " << eve::bit_shr[eve::ignore_last(2)](wi0, wi1) << "\n";
std::cout << "-> bit_shr[wi2 > 0](wi0, wi2) = " << eve::bit_shr[wi2 > 0](wi0, wi2) << "\n";
}

◆ bit_swap_adjacent

auto eve::bit_swap_adjacent = functor<bit_swap_adjacent_t>
inlineconstexpr

strict_elementwise_callable object swapping adjacent groups of n bits.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_swap_adjacent(unsigned_value auto x, integral_scalar_value auto n) noexcept; // 1
// Lanes masking
constexpr auto bit_swap_adjacent[conditional_expr auto c](unsigned_value auto x, integral_scalar_value auto n) noexcept; // 2
constexpr auto bit_swap_adjacent[logical_value auto m](unsigned_value auto x, integral_scalar_value auto n) noexcept; // 2
}
constexpr auto bit_swap_adjacent
strict_elementwise_callable object swapping adjacent groups of n bits.
Definition bit_swap_adjacent.hpp:72

Parameters

Return value

  1. Return x with pairs of contiguous groups of N bits swapped in each element.
    • If n is greater or equal to sizeof(x)*8 0 is returned.
    • If n is equal to 0 x is returned.
  2. The operation is performed conditionally.

Example

// revision 2
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "-> bit_swap_adjacent(wu0, 2) = " << eve::bit_swap_adjacent(wu0, 2) << "\n";
std::cout << "-> bit_swap_adjacent[ignore_last(2)](wu0, 2) = " << eve::bit_swap_adjacent[eve::ignore_last(2)](wu0, 2) << "\n";
std::cout << "-> bit_swap_adjacent[wu0 != 2u](wu0, 2) = " << eve::bit_swap_adjacent[wu0 != 2u](wu0, 2) << "\n";
std::cout << "-> bit_swap_adjacent(wu0, 2) = " << eve::bit_swap_adjacent(wu0, 2) << "\n";
}

Semantic Modifiers

◆ bit_swap_pairs

auto eve::bit_swap_pairs = functor<bit_swap_pairs_t>
inlineconstexpr

strict_elementwise_callable object swapping pairs.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_swap_pairs(integral_value auto x,
integral_value auto i0, integral_value auto i1) noexcept; // 1
// Lanes masking
constexpr auto bit_swap_pairs[conditional_expr auto c](integral_value auto x,
integral_value auto i0, integral_value auto i1) noexcept; // 2
constexpr auto bit_swap_pairs[logical_value auto m](integral_value auto x,
integral_value i0, integral_value auto i1) noexcept; // 2
}
constexpr auto bit_swap_pairs
strict_elementwise_callable object swapping pairs.
Definition bit_swap_pairs.hpp:93

Parameters

Return value

  1. Return x with bit i0 and i1 swapped in each element of x. Assert if i0 or i1 are out of range.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide<int, eve::fixed<4>> wi0{2, 4, 9, 5};
eve::wide<int, eve::fixed<4>> wi1{1, 3, 3, 3};
eve::wide<int, eve::fixed<4>> wi2{0, 2, 1, 2};
eve::wide<int, eve::fixed<4>> wi3{0, -2, -1, 7};
std::cout << std::showbase << std::hex;
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wi2 = " << wi2 << "\n\n";
std::cout << "-> bit_swap_pairs(wi0, wi1, wi2) = " << eve::bit_swap_pairs(wi0, wi1, wi2) << "\n";
std::cout << "-> bit_swap_pairs[ignore_last(2)](wi0, wi1, wi2) = " << eve::bit_swap_pairs[eve::ignore_last(2)](wi0, wi1, wi2) << "\n";
std::cout << "-> bit_swap_pairs[wi3 > 0](wi0, wi1, wi3) = " << eve::bit_swap_pairs[wi3 >= 0](wi0, wi1, wi3) << "\n\n";
std::cout << "-> bit_swap_pairs(wi0, 3, 2) = " << eve::bit_swap_pairs(wi0, 3, 2) << "\n";
std::cout << "-> bit_swap_pairs[ignore_last(2)](wi0, 3, 2) = " << eve::bit_swap_pairs[eve::ignore_last(2)](wi0, 3, 2) << "\n";
std::cout << "-> bit_swap_pairs[wi3 > 0](wi0, 3, 2) = " << eve::bit_swap_pairs[wi3 >= 0](wi0, 3, 2) << "\n\n";
auto i3 = eve::index_t<3>{};
auto i2 = eve::index_t<2>{};
std::cout << "-> bit_swap_pairs(wi0, i3, i2) = " << eve::bit_swap_pairs(wi0, i3, i2) << "\n";
std::cout << "-> bit_swap_pairs[ignore_last(2)](wi0, i3, i2) = " << eve::bit_swap_pairs[eve::ignore_last(2)](wi0, i3, i2) << "\n";
std::cout << "-> bit_swap_pairs[wi3 > 0](wi0, i3, i2) = " << eve::bit_swap_pairs[wi3 >= 0](wi0, i3, i2) << "\n\n";
}

◆ bit_ternary

auto eve::bit_ternary = functor<bit_ternary_t>
inlineconstexpr

callable object implementing ternary logic.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
constexpr auto bit_ternary(integral_constant k, auto u, auto v, auto w) noexcept; // 1
}
constexpr auto bit_ternary
callable object implementing ternary logic.
Definition bit_ternary.hpp:99

Parameters

  • k: integral constant whose bits are the result of a lookup table for the ternary operation. The consteval function mfb (make from bits) can be used to generate this constant from its bits (see below).
  • u, v, w, : first argument.

Return value

  1. Bitwise ternary logict provides the capability to implement any three-operand binary function; the specific ternary function is specified by value of k. For each bit in each integer, the corresponding bit from a, b, and c are used according to ik, and the result is output.
  2. The operation is performed conditionally. Note that the element type of the output is always the one of a and if any parameter is simd, its number of lanes is the number of lanes of the output
  3. The operation is performed conditionally.

The following table is the pattern of a truth table: if op is a ternary bit operator the result column is the desired bit output when calling op pn the x, y and z bit values.

x y z result
0 0 0 a
0 0 1 b
0 1 0 c
0 1 1 d
1 0 0 e
1 0 1 f
1 1 0 g
1 1 1 h

A programmer as only to supply the result column, i.e. defines values of bits a through h in a single 8-bit value

k = .(a << 7) + (b << 6) + (c << 5) + (d << 4) + (e << 3) + (f << 2) + (g << 1) + h

(the consteval function eve::truth_table can be used to do that operation: see the example)

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
eve::wide wu1{7u, 3u, 5u, 4u, 3u, 2u, 1u, 0u};
eve::wide wu2{6u, 5u, 4u, 3u, 2u, 1u, 0u, ~0u};
std::integral_constant<std::uint8_t, 0xff> iff;
std::integral_constant<std::uint8_t, 0x80> i80;
std::integral_constant<std::uint8_t, 0xac> iac;
std::cout << std::hex << std::endl;
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "<- wu2 = " << wu2 << "\n";
std::cout << "<- iff = " << std::bitset<8>(iff) << std::endl;
std::cout << "<- i80 = " << std::bitset<8>(i80) << std::endl;
std::cout << "<- iac = " << std::bitset<8>(iac) << std::endl;
std::cout << "-> bit_ternary(eve::truth_table<1,1,1,1,1,1,1,1>(), wu0, wu1, wu2) = " << (eve::bit_ternary(eve::truth_table<1,1,1,1,1,1,1,1>(), wu0, wu1, wu2)) << "\n";
std::cout << "-> bit_ternary(iff, wu0, wu1, wu2) = " << (eve::bit_ternary(iff, wu0, wu1, wu2)) << "\n";
std::cout << "-> bit_ternary(eve::truth_table<1,0,0,0,0,0,0,0>(), wu0, wu1, wu2) = " << (eve::bit_ternary(eve::truth_table<1,0,0,0,0,0,0,0>(), wu0, wu1, wu2)) << "\n";
std::cout << "-> bit_ternary(i80, wu0, wu1, wu2) = " << (eve::bit_ternary(i80, wu0, wu1, wu2)) << "\n";
std::cout << "-> bit_ternary(eve::truth_table<1,0,1,0,1,1,0,0>(), wu0, wu1, wu2))= " << (eve::bit_ternary(eve::truth_table<1,0,1,0,1,1,0,0>(), wu0, wu1, wu2)) << "\n";
std::cout << "-> bit_ternary(iac, wu0, wu1, wu2) = " << (eve::bit_ternary(iac, wu0, wu1, wu2)) << "\n";
}

◆ bit_unset

auto eve::bit_unset = functor<bit_unset_t>
inlineconstexpr

strict_elementwise_callable object setting to 01 the ith bit of each element.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_unset(integral_value auto x, integral_value auto n) noexcept; // 1
// Lanes masking
constexpr auto bit_unset[conditional_expr auto c](integral_value, auto x integral_value auto n) noexcept; // 2
constexpr auto bit_unset[logical_value auto m](integral_value auto x, integral_value auto n) noexcept; // 2
}
constexpr auto bit_unset
strict_elementwise_callable object setting to 01 the ith bit of each element.
Definition bit_unset.hpp:69

Parameters

Return value

  1. The value of the parameter is returned with the ith bit set to 0 if the index is out of range the call will assert.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide pi = {1, 3, 7, 15, 31, 63, 127, 255};
std::cout << "<- pi = " << pi << '\n';
std::cout << "-> bit_unset(pi, 1) = " << eve::bit_unset(pi, 1) << '\n';
std::cout << "-> bit_unset(pi, 2) = " << eve::bit_unset(pi, 2) << '\n';
std::cout << "-> bit_unset(pi, 3) = " << eve::bit_unset(pi, 3) << '\n';
std::cout << "-> bit_unset(pi, 4) = " << eve::bit_unset(pi, 4) << '\n';
std::cout << "-> bit_unset(pi, 8) = " << eve::bit_unset(pi, 8) << '\n';
std::cout << "-> bit_unset[pi > 15](pi, 1) = " << eve::bit_unset[pi > 15](pi, 1) << '\n';
std::cout << "-> bit_unset[pi > 15](pi, 2) = " << eve::bit_unset[pi > 15](pi, 2) << '\n';
std::cout << "-> bit_unset[pi > 15](pi, 3) = " << eve::bit_unset[pi > 15](pi, 3) << '\n';
std::cout << "-> bit_unset[pi > 15](pi, 4) = " << eve::bit_unset[pi > 15](pi, 4) << '\n';
std::cout << "-> bit_unset[pi > 15](pi, 8) = " << eve::bit_unset[pi > 15](pi, 8) << '\n';
}

◆ bit_width

auto eve::bit_width = functor<bit_width_t>
inlineconstexpr

elementwise_callable object Computing elementwise the number of bits needed to store the parameter.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto bit_width(unsigned_value auto x) noexcept; // 1
// Lanes masking
constexpr auto bit_width[conditional_expr auto c](unsigned_value auto x) noexcept; // 2
constexpr auto bit_width[logical_value auto m](unsigned_value auto x) noexcept; // 2
}
constexpr auto bit_width
elementwise_callable object Computing elementwise the number of bits needed to store the parameter.
Definition bit_width.hpp:69

Parameters

Return value

  1. The value of number of bits needed to store the value x, i.e. \(1+\lfloor\log2(x)\rfloor\) is returned.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> bit_width(wu0) = " << eve::bit_width(wu0) << "\n";
std::cout << "-> bit_width[ignore_last(2)](wu0) = " << eve::bit_width[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> bit_width[wu0 != 0](wu0) = " << eve::bit_width[wu0 != 0](wu0) << "\n";
}

◆ bit_xor

auto eve::bit_xor = functor<bit_xor_t>
inlineconstexpr

bit_callable object computing the bitwise XOR of its arguments.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto bit_xor(value auto x, value auto ... xs) noexcept; // 1
constexpr auto bit_xor(eve::non_empty_product_type auto const& tup) noexcept; // 2
// Lanes masking
constexpr auto bit_xor[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto bit_xor[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
}
constexpr auto bit_xor
bit_callable object computing the bitwise XOR of its arguments.
Definition bit_xor.hpp:86

Parameters

Return value

  1. The value of the bitwise XOR of its arguments converted to their common bit_value is returned.
  2. equivalent to the call on the elements of the tuple.
  3. The operation is performed conditionally. This is only supported when all parameters share the same number of lanes or are scalars.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wf1{0.0, -4.0, 1.0, -1.0, 2.0, -2.0, 3.0, -3.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, -4, 1, -1, 2, -2, 3, -3};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
eve::wide wu1{7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "-> bit_xor(wf0, wf1) = " << eve::bit_xor(wf0, wf1) << "\n";
std::cout << "-> bit_xor[ignore_last(2)](wf0, wf1) = " << eve::bit_xor[eve::ignore_last(2)](wf0, wf1) << "\n";
std::cout << "-> bit_xor[wf0 != 0](wf0, wf1) = " << eve::bit_xor[wf0 != 0](wf0, wf1) << "\n";
std::cout << "-> bit_xor(wu0, wu1) = " << eve::bit_xor(wu0, wu1) << "\n";
std::cout << "-> bit_xor(wi0, wi1) = " << eve::bit_xor(wi0, wi1) << "\n";
std::cout << "-> bit_xor(2.,1.,2.,3.,-3.,-4.,-6.0) = " << eve::bit_xor(2.0, 1.0, 2.0, 3.0, -3.0, -4., -6.0) << "\n";
std::cout << "->:bit_xor(2.1,2.,2.,2.,2.,2.,2.) = " << eve::bit_xor(2.1,2.,2.,2.,2.,2.,2.) << "\n";
}

◆ byte_reverse

auto eve::byte_reverse = functor<byte_reverse_t>
inlineconstexpr

elementwise_callable object reversing the byte order.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto byte_reverse(unsigned_value auto x) noexcept; // 1
// Lanes masking
constexpr auto byte_reverse[conditional_expr auto c](unsigned_value auto x) noexcept; // 2
constexpr auto byte_reverse[logical_value auto m](unsigned_value auto x) noexcept; // 2
}
constexpr auto byte_reverse
elementwise_callable object reversing the byte order.
Definition byte_reverse.hpp:78

Parameters

Return value

  1. The values of the parameter elements are returned with bytes in reversed order.
  2. The operation is performed conditionally.
Note
eve::byte_reverse is the functional equivalent to std::byte_swap. However, we decided to name it byte_reverse in order to keep a proper naming scheme aligned with the eve::bit_swap/eve::bit_reverse functions.

Example

// revision 1
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> byte_reverse(wu0) = " << eve::byte_reverse(wu0) << "\n";
std::cout << "-> byte_reverse[ignore_last(2)](wu0) = " << eve::byte_reverse[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> byte_reverse[wu0 != 2u](wu0) = " << eve::byte_reverse[wu0 != 2u](wu0) << "\n";
}

◆ byte_swap_adjacent

auto eve::byte_swap_adjacent = functor<byte_swap_adjacent_t>
inlineconstexpr

strict_elementwise_callable object that swap adjacent groups of N bytes.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
// Regular overload
constexpr auto byte_swap_adjacent(integral_value auto x, integral_value auto n) noexcept; // 1
// Lanes masking
constexpr auto byte_swap_adjacent[conditional_expr auto c](integral_value auto x,
integral_value auto n) noexcept; // 2
constexpr auto byte_swap_adjacent[logical_value auto m](integral_value auto x,
integral_value auto n) noexcept; // 2
}
constexpr auto byte_swap_adjacent
strict_elementwise_callable object that swap adjacent groups of N bytes.
Definition byte_swap_adjacent.hpp:77

Parameters

  • x : argument.
  • n : size of the groups of bytes to be swapped. Must be a power of 2 and less than the half size of the elements of x
  • c: Conditional expression masking the operation.
  • m: Logical value masking the operation.

Return value

  1. Return x with elementwise groups of N bytes swapped.
    • If N is greater to sizeof(x) 0 is returned.
    • If N is equal to sizeof(x) x is returned.
  2. The operation is performed conditionally.
Note
Take care that eve::byte_swap_adjacent is NOT the EVE functional equivalent to std::byteswap. eve::byte_reverse IS. As the name does not say, std::byteswap reverse the order of the bytes which is not an adjacent swapping except for 16 bits words.

Example

// revision 2
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "-> byte_swap_adjacent(wu0, 2) = " << eve::byte_swap_adjacent(wu0, 2) << "\n";
std::cout << "-> byte_swap_adjacent[ignore_last(2)](wu0, 2) = " << eve::byte_swap_adjacent[eve::ignore_last(2)](wu0, 2) << "\n";
std::cout << "-> byte_swap_adjacent[wu0 != 2u](wu0, 2) = " << eve::byte_swap_adjacent[wu0 != 2u](wu0, 2) << "\n";
std::cout << "-> byte_swap_adjacent(wu0, 2) = " << eve::byte_swap_adjacent(wu0, 2) << "\n";
}

◆ byte_swap_pairs

auto eve::byte_swap_pairs = functor<byte_swap_pairs_t>
inlineconstexpr

strict_elementwise_callable object swapping chosen pairs of bytes in each vector element.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto byte_swap_pairs(integral_value auto x,
index_t<I0> auto i0, index_t<I1> auto i1) noexcept; // 1
// Lanes masking
constexpr auto byte_swap_pairs[conditional_expr auto c](integral_value auto x,
index_t<I0> auto i0, index_t<I1> auto i1) noexcept; // 2
constexpr auto byte_swap_pairs[logical_value auto m](integral_value auto x,
index_t<I0> auto i0, index_t<I1> auto i1) noexcept; // 2
constexpr auto byte_swap_pairs
strict_elementwise_callable object swapping chosen pairs of bytes in each vector element.
Definition byte_swap_pairs.hpp:74

Parameters

Return value

  1. Return x byte i0 and i1 swapped in each element of x. Assert if i0 or i1 are out of range.
  2. The operation is performed conditionally.

Example

// revision 2
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> byte_swap_pairs(wu0, index_t<0>(), index_t<1>()) = " << eve::byte_swap_pairs(wu0, eve::index_t<0>(), eve::index_t<1>()) << "\n";
std::cout << "-> byte_swap_pairs[ignore_last(2)](wu0, index_t<0>(), index_t<1>()) = " << eve::byte_swap_pairs[eve::ignore_last(2)](wu0, eve::index_t<0>(), eve::index_t<1>()) << "\n";
std::cout << "-> byte_swap_pairs[wu0 != 0](wu0, index_t<0>(), index_t<1>()) = " << eve::byte_swap_pairs[wu0 != 0](wu0, eve::index_t<0>(), eve::index_t<1>()) << "\n";
}

◆ countl_one

auto eve::countl_one = functor<countl_one_t>
inlineconstexpr

elementwise_callable object computing the number of consecutive bits set in a value starting from left

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto countl_one(unsigned_value auto x) noexcept; // 1
// Lanes masking
constexpr auto countl_one[conditional_expr auto c](unsigned_value auto x) noexcept; // 2
constexpr auto countl_one[logical_value auto m](unsigned_value auto x) noexcept; // 2
}
constexpr auto countl_one
elementwise_callable object computing the number of consecutive bits set in a value starting from lef...
Definition countl_one.hpp:72

Parameters

Return value

  1. The value of the number of consecutive 1 ("one") bits in the value of x, starting from the most significant bit ("left"), with same type as x is returned.
  2. The operation is performed conditionally.

External references

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> countl_one(wu0) = " << eve::countl_one(wu0) << "\n";
std::cout << "-> countl_one[ignore_last(2)](wu0) = " << eve::countl_one[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> countl_one[wu0 != 0](wu0) = " << eve::countl_one[wu0 != 0](wu0) << "\n";
}

◆ countl_zero

auto eve::countl_zero = functor<countl_zero_t>
inlineconstexpr

elementwise_callable object computing the number of consecutive bits unset in a value starting from left

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto countl_zero(unsigned_value auto x) noexcept; // 1
// Lanes masking
constexpr auto countl_zero[conditional_expr auto c](unsigned_value auto x) noexcept; // 2
constexpr auto countl_zero[logical_value auto m](unsigned_value auto x) noexcept; // 2
}
constexpr auto countl_zero
elementwise_callable object computing the number of consecutive bits unset in a value starting from l...
Definition countl_zero.hpp:72

Parameters

Return value

  1. The value of the number of consecutive 0 ("zero") bits in the value of x, starting from the most significant bit ("left"), with same type as x is returned.
  2. The operation is performed conditionally.

External references

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> countl_zero(wu0) = " << eve::countl_zero(wu0) << "\n";
std::cout << "-> countl_zero[ignore_last(2)](wu0) = " << eve::countl_zero[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> countl_zero[wu0 != 0](wu0) = " << eve::countl_zero[wu0 != 0](wu0) << "\n";
}

◆ countr_one

auto eve::countr_one = functor<countr_one_t>
inlineconstexpr

elementwise_callable object computing the number of consecutive bits set in a value starting from right.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto countr_one(unsigned_value auto x) noexcept; // 1
// Lanes masking
constexpr auto countr_one[conditional_expr auto c](unsigned_value auto x) noexcept; // 2
constexpr auto countr_one[logical_value auto m](unsigned_value auto x) noexcept; // 2
}
constexpr auto countr_one
elementwise_callable object computing the number of consecutive bits set in a value starting from rig...
Definition countr_one.hpp:71

Parameters

Return value

1.The value of the number of consecutive 1 ("one") bits in the value of x, starting from the least significant bit ("right"), with same type as x, is returned.

  1. The operation is performed conditionally.

External references

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> countr_one(wu0) = " << eve::countr_one(wu0) << "\n";
std::cout << "-> countr_one[ignore_last(2)](wu0) = " << eve::countr_one[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> countr_one[wu0 != 0](wu0) = " << eve::countr_one[wu0 != 0](wu0) << "\n";
}

◆ countr_zero

auto eve::countr_zero = functor<countr_zero_t>
inlineconstexpr

elementwise_callable object computing the number of consecutive bits unset in a value starting from right.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto countr_zero(unsigned_value auto x) noexcept; // 1
// Lanes masking
constexpr auto countr_zero[conditional_expr auto c](unsigned_value auto x) noexcept; // 2
constexpr auto countr_zero[logical_value auto m](unsigned_value auto x) noexcept; // 2
}
constexpr auto countr_zero
elementwise_callable object computing the number of consecutive bits unset in a value starting from r...
Definition countr_zero.hpp:69

Parameters

Return value

The value of the number of consecutive 0 ("zero") bits in the value of x, starting from the least significant bit ("right"), with same type as x, is returned.

External references

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> countr_zero(wu0) = " << eve::countr_zero(wu0) << "\n";
std::cout << "-> countr_zero[ignore_last(2)](wu0) = " << eve::countr_zero[eve::ignore_last(2)](wu0) << "\n";
std::cout << "-> countr_zero[wu0 != 0](wu0) = " << eve::countr_zero[wu0 != 0](wu0) << "\n";
}

◆ firstbitset

auto eve::firstbitset = functor<firstbitset_t>
inlineconstexpr

Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit set in the input.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto firstbitset(integral_value auto x) noexcept; // 1
// Lanes masking
constexpr auto firstbitset[conditional_expr auto c](integral_value auto x) noexcept; // 2
constexpr auto firstbitset[logical_value auto m](integral_value auto x) noexcept; // 2
}
constexpr auto firstbitset
Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit set in...
Definition firstbitset.hpp:68

Parameters

Return value

  1. Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit set (beginning with the least significant bit) in the input.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "-> firstbitset(wi0) = " << eve::firstbitset(wi0) << "\n";
std::cout << "-> firstbitset[ignore_last(2)](wi0) = " << eve::firstbitset[eve::ignore_last(2)](wi0) << "\n";
std::cout << "-> firstbitset[wi0 != 0](wi0) = " << eve::firstbitset[wi0 != 0](wi0) << "\n";
}

◆ firstbitunset

auto eve::firstbitunset = functor<firstbitunset_t>
inlineconstexpr

Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit unset in the input.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto firstbitunset(integral_value auto x) noexcept; // 1
// Lanes masking
constexpr auto firstbitunset[conditional_expr auto c](integral_value auto x) noexcept; // 2
constexpr auto firstbitunset[logical_value auto m](integral_value auto x) noexcept; // 2
}
constexpr auto firstbitunset
Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit unset ...
Definition firstbitunset.hpp:68

Parameters

Return value

  1. Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit unset (beginning with the least significant bit) in the input.
  2. The operation is performed conditionally.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "-> firstbitunset(wi0) = " << eve::firstbitunset(wi0) << "\n";
std::cout << "-> firstbitunset[ignore_last(2)](wi0) = " << eve::firstbitunset[eve::ignore_last(2)](wi0) << "\n";
std::cout << "-> firstbitunset[wi0 != 0](wi0) = " << eve::firstbitunset[wi0 != 0](wi0) << "\n";
}

◆ hi

auto eve::hi = functor<hi_t>
inlineconstexpr

elementwise_callable computing the most significant half of each lane.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
constexpr auto hi(value auto x) noexcept;
}
constexpr auto hi
elementwise_callable computing the most significant half of each lane.
Definition hi.hpp:71

Parameters

Return value

  • Computes the elementwise higher significant half of the value bits, returning each element as an unsigned integer of half the size of the input element.
Note
If you also need the lower part lohi is more efficient.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> hi(wf0) = " << eve::hi(wf0) << "\n";
std::cout << "-> hi(wu0) = " << eve::hi(wu0) << "\n";
std::cout << "-> hi(wi0) = " << eve::hi(wi0) << "\n";
}

◆ lo

auto eve::lo = functor<lo_t>
inlineconstexpr

Computes the least significant half of each lane.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
constexpr auto lo(value auto x) noexcept;
}
constexpr auto lo
Computes the least significant half of each lane.
Definition lo.hpp:73

Parameters

Return value

  • Computes the elementwise lower significant half of the value bits, returning each element as an unsigned integer of half the size of the input element.
Note
If you also need the lower part hilo is more efficient.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> lo(wf0) = " << eve::lo(wf0) << "\n";
std::cout << "-> lo(wu0) = " << eve::lo(wu0) << "\n";
std::cout << "-> lo(wi0) = " << eve::lo(wi0) << "\n";
}

◆ lohi

auto eve::lohi = functor<lohi_t>
inlineconstexpr

elementwise_callable computing the lohi pair of values.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
constexpr auto lohi(value auto x) noexcept;
}
constexpr auto lohi
elementwise_callable computing the lohi pair of values.
Definition lohi.hpp:69

Parameters

Return value

  • Computes the elementwise the lower and higher parts of the input values, as a pair of unsigned integers of half size
  • The call [l, h] = lohi(x) is_semantically equivalent to l = lo(x); h = hi(x);

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0{0.0, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0, -4.0};
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> lo(wf0) = " << eve::lo(wf0) << "\n";
std::cout << "-> lo(wu0) = " << eve::lo(wu0) << "\n";
std::cout << "-> lo(wi0) = " << eve::lo(wi0) << "\n";
}

◆ popcount

auto eve::popcount = functor<popcount_t>
inlineconstexpr

elementwise_callable object computing elementwise the number of bits set in the parameter.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
constexpr auto popcount(unsigned_value auto x) noexcept;
}
constexpr auto popcount
elementwise_callable object computing elementwise the number of bits set in the parameter.
Definition popcount.hpp:61

Parameters

Return value

The value of number of bits set in the value x is returned.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> popcount(wu0) = " << eve::popcount(wu0) << "\n";
}

◆ rotl

auto eve::rotl = functor<rotl_t>
inlineconstexpr

Bitwise rotation to the left.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto rotl(unsigned_value auto x, integral_value auto n) noexcept; // 1
// Lanes masking
constexpr auto rotl[conditional_expr auto c](unsigned_value auto x, integral_value auto n) noexcept; // 3
constexpr auto rotl[logical_value auto m](unsigned_value auto x, integral_value auto n) noexcept; // 3
}
constexpr auto rotl
Bitwise rotation to the left.
Definition rotl.hpp:81

Parameters

Return value

  1. Bitwise rotation of each lane of x by n bits to the left. The types must share the same cardinal or be scalar and if N is the size in bits of the element type of T, all elements of n must belong to the interval: [0, N[ or the result is undefined.
  2. The operation is performed conditionally

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
wu0 = ~wu0;
eve::wide wu1{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "-> rotl(wu0, wu1) = " << eve::rotl(wu0, wu1) << "\n";
std::cout << "-> rotl[ignore_last(2)](wu0, wu1) = " << eve::rotl[eve::ignore_last(2)](wu0, wu1) << "\n";
std::cout << "-> rotl[wu0 != 0](wu0, wu1) = " << eve::rotl[wu0 != 0](wu0, wu1) << "\n";
}

◆ rotr

auto eve::rotr = functor<rotr_t>
inlineconstexpr

Bitwise rotation to the right.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto rotr(unsigned_value auto x, integral_value auto n) noexcept; // 2
// Lanes masking
constexpr auto rotr[conditional_expr auto c](unsigned_value auto x, integral_value auto n) noexcept; // 3
constexpr auto rotr[logical_value auto m](unsigned_value auto x, integral_value auto n) noexcept; // 3
}
constexpr auto rotr
Bitwise rotation to the right.
Definition rotr.hpp:83

Parameters

Return value

  1. Bitwise rotation of each lane of x by n bits to the right. The types must share the same cardinal or be scalar and if N is the size in bits of the element type of T, all elements of n must belong to the interval: [0, N[ or the result is undefined.
    1. The operation is performed conditionally

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
eve::wide wu1{7u, 6u, 5u, 4u, 3u, 2u, 1u, 0u};
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "<- wu1 = " << wu1 << "\n";
std::cout << "-> rotr(wu0, wu1) = " << eve::rotr(wu0, wu1) << "\n";
std::cout << "-> rotr[ignore_last(2)](wu0, wu1) = " << eve::rotr[eve::ignore_last(2)](wu0, wu1) << "\n";
std::cout << "-> rotr[wu0 != 0](wu0, wu1) = " << eve::rotr[wu0 != 0](wu0, wu1) << "\n";
}

◆ rshl

auto eve::rshl = functor<rshl_t>
inlineconstexpr

Computes the arithmetic left/right shift operation according to shift sign.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto rshl(integral_value auto x, integral_value auto n) noexcept; // 2
// Lanes masking
constexpr auto rshl[conditional_expr auto c](integral_value auto x, integral_value auto n) noexcept; // 3
constexpr auto rshl[logical_value auto m](integral_value auto x, integral_value auto n) noexcept; // 3
}
constexpr auto rshl
Computes the arithmetic left/right shift operation according to shift sign.
Definition rshl.hpp:83

Parameters

Return value

  1. The value of the arithmetic left/right shift operation according to shift sign is returned. This is equivalent to if_else(n>0, shl(x, n), shr(x, -n)) If Nis the size in bits of the element type of x, all elements of n must belong to the interval: ]-N, N[ or the result is undefined.
  2. The operation is performed conditionally

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, -4, 1, -1, 2, -2, 3, -3};
eve::wide wi2{1024, -4, 1, -1, 2, -2, 3, -3};
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "-> rshl(wi0, wi1) = " << eve::rshl(wi0, wi1) << "\n";
std::cout << "-> rshl[ignore_last(2)](wi0, wi1) = " << eve::rshl[eve::ignore_last(2)](wi0, wi1) << "\n";
std::cout << "-> rshl[wi0 != 0](wi0, wi1) = " << eve::rshl[wi0 != 0](wi0, wi1) << "\n";
std::cout << "-> rshl[wi2 < 32](wi0, wi2) = " << eve::rshl[wi2 < 32](wi0, wi2) << "\n";
}

◆ rshr

auto eve::rshr = functor<rshr_t>
inlineconstexpr

Computes the arithmetic right/left shift operation according to shift sign.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto rshr(integral_value auto x, integral_value auto n) noexcept; // 2
// Lanes masking
constexpr auto rshr[conditional_expr auto c](integral_value auto x, integral_value auto n) noexcept; // 3
constexpr auto rshr[logical_value auto m](integral_value auto x, integral_value auto n) noexcept; // 3
}
constexpr auto rshr
Computes the arithmetic right/left shift operation according to shift sign.
Definition rshr.hpp:82

Parameters

Return value

  1. The value of the arithmetic right/left shift operation according to shift sign is returned. This equivalent to if_else(n>0, shl(x, n), shr(x, -n)). If N is the size in bits of the element type of T, all elements of n must belong to the interval: ]-N, N[ or the result is undefined.
  2. The operation is performed conditionally

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, -4, 1, -1, 2, -2, 3, -3};
eve::wide wi2{1024, -4, 1, -1, 2, -2, 3, -3};
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "-> rshr(wi0, wi1) = " << eve::rshr(wi0, wi1) << "\n";
std::cout << "-> rshr[ignore_last(2)](wi0, wi1) = " << eve::rshr[eve::ignore_last(2)](wi0, wi1) << "\n";
std::cout << "-> rshr[wi0 != 0](wi0, wi1) = " << eve::rshr[wi0 != 0](wi0, wi1) << "\n";
std::cout << "-> rshl[wi2 < 32](wi0, wi2) = " << eve::rshr[wi2 < 32](wi0, wi2) << "\n";
}

◆ shl

auto eve::shl = functor<shl_t>
inlineconstexpr

Computes the arithmetic left shift operation.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto shl(integral_value auto x, integral_value auto n) noexcept; // 1
template< auto N >
constexpr auto shl(integral_value auto x, index_t<N> auto n) noexcept; // 2
// Lanes masking
constexpr auto shl[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3
constexpr auto shl[logical_value auto m](/* any of the above overloads */) noexcept; // 3
}
constexpr auto shl
Computes the arithmetic left shift operation.
Definition shl.hpp:94

Parameters

Return value

  1. The elementwise arithmetic left shift of the first parameter by the second one is returned. If Nis the size in bits of the element type of x, all elements of n must belong to the interval: ]0, N[ or the result is undefined.
  2. This call allows optimization for architectures that have an intrinsic requiring an immediate parameter
  3. The operation is performed conditionally
Note
Although the infix notation with << is supported, the << operator on standard scalar types is the original one and so can not be overloaded on standard floating parameters due to C++ limitations.
Warning
The behavior of this function is undefined if the shift value is out of the range [0, N[, where N is the number of bits of the input type. Use eve::rshl for a relative left shift that accepts negative shift values.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, 4, 1, 1, 2, 2, 3, 3};
eve::wide wi2{0, -4, 1, -1, 2, -2, 3, -3};
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "<- wi2 = " << wi2 << "\n";
std::cout << "-> shl(wi0, wi1) = " << eve::shl(wi0, wi1) << "\n";
std::cout << "-> shl(wi0, index_t<0>()) = " << eve::shl(wi0, eve::index_t<0>()) << "\n";
std::cout << "-> shl[ignore_last(2)](wi0, wi1) = " << eve::shl[eve::ignore_last(2)](wi0, wi1) << "\n";
std::cout << "-> shl[wi2 > 0](wi0, wi2) = " << eve::shl[wi2 > 0](wi0, wi2) << "\n";
}

◆ shr

auto eve::shr = functor<shr_t>
inlineconstexpr

Computes the arithmetic right shift operation.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto shr(integral_value auto x, integral_value auto n) noexcept; // 1
template< auto N >
constexpr auto shr(integral_value auto x, index_t<N> auto n) noexcept; // 2
// Lanes masking
constexpr auto shr[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3
constexpr auto shr[logical_value auto m](/* any of the above overloads */) noexcept; // 3
}
constexpr auto shr
Computes the arithmetic right shift operation.
Definition shr.hpp:94

Parameters

Return value

  1. The elementwise arithmetic right shift of the first parameter by the second one is returned. If Nis the size in bits of the element type of x, all elements of n must belong to the interval: ]0, N[ or the result is undefined.
  2. This call allows optimization for architectures that have an intrinsic requiring an immediate parameter
  3. The operation is performed conditionally
Note
Although the infix notation with << is supported, the << operator on standard scalar types is the original one and so can not be overloaded on standard floating parameters due to C++ limitations.
Warning
The behavior of this function is undefined if the shift value is out of the range [0, N[, where N is the number of bits of the input type. Use eve::rshr for a relative right shift that accepts negative shift values.

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wi0{0, 1, 2, 3, -1, -2, -3, -4};
eve::wide wi1{0, 4, 1, 1, 2, 2, 3, 3};
eve::wide wi2{0, -4, 1, -1, 2, -2, 3, -3};
std::cout << "<- wi0 = " << wi0 << "\n";
std::cout << "<- wi1 = " << wi1 << "\n";
std::cout << "-> shr(wi0, wi1) = " << eve::shr(wi0, wi1) << "\n";
std::cout << "-> shr(wi0, index_t<0>()) = " << eve::shr(wi0, eve::index_t<0>()) << "\n";
std::cout << "-> shr[ignore_last(2)](wi0, wi1) = " << eve::shr[eve::ignore_last(2)](wi0, wi1) << "\n";
std::cout << "-> shr[wi2 > 0](wi0, wi2) = " << eve::shr[wi2 > 0](wi0, wi2) << "\n";
}

◆ swap_pairs

auto eve::swap_pairs = functor<swap_pairs_t>
inlineconstexpr

swap chosen pair of elements.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template<simd_value T, std::ptrdiff_t I0, std::ptrdiff_t I1 >
T swap_pairs(T x, index_t<I0> i0, index_t<I1> i1);
constexpr auto swap_pairs
swap chosen pair of elements.
Definition swap_pairs.hpp:62

Parameters

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

Return value

Return x with element i0 and i1 swapped.

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:108