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

Detailed Description

Types and operations to defines conditional mask expressions.

Masking lanes from an eve::simd_value is a frequent operations. To simplify and optimize such code, EVE provides objects and functions to define conditions with a high-level of flexibility including: alternative value, index-based relative conditions and more.

See also: Conditional operations

Classes

struct  eve::or_< C, V >
 Conditional/Alternative wrapper. More...
struct  eve::if_< C >
 Extensible wrapper for SIMD conditional. More...
struct  eve::ignore_all_
 Conditional expression selecting no lane from a eve::simd_value. More...
struct  eve::ignore_none_
 Conditional expression selecting all lanes from a eve::simd_value. More...
struct  eve::keep_first
 Conditional expression selecting the k first lanes from a eve::simd_value. More...
struct  eve::ignore_last
 Conditional expression ignoring the k last lanes from a eve::simd_value. More...
struct  eve::keep_last
 Conditional expression keeping the k last lanes from a eve::simd_value. More...
struct  eve::ignore_first
 Conditional expression ignoring the k first lanes from a eve::simd_value. More...
struct  eve::keep_between
 Conditional expression keeping all lanes between two position. More...
struct  eve::ignore_extrema
 Conditional expression ignoring lanes at both extrema of a eve::simd_value. More...

Functions

template<eve::relative_conditional_expr C>
constexpr auto eve::drop_alternative (C c)
 Returns a conditional without an alternative.
template<eve::relative_conditional_expr C>
auto eve::map_alternative (C c, auto op)
 Computes a transformed conditional.
template<eve::relative_conditional_expr C, typename Tgt>
auto eve::bit_cast_alternative (C c, as< Tgt > tgt)
 Computes a transformed conditional.
template<eve::relative_conditional_expr C, typename T>
constexpr auto eve::reverse_conditional (C c, eve::as< T > tgt)
 Computes the reverse of a given eve::relative_conditional_expr.

Variables

constexpr ignore_all_ eve::ignore_all = {}
 Object representing the eve::ignore_all_ conditional expression.
constexpr ignore_none_ eve::ignore_none = {}
 Object representing the eve::ignore_none_ conditional expression.

Function Documentation

◆ bit_cast_alternative()

template<eve::relative_conditional_expr C, typename Tgt>
auto eve::bit_cast_alternative ( C c,
as< Tgt > tgt )

Computes a transformed conditional.

Required header: #include <eve/conditional.hpp>

Creates a eve::conditional_expr by bitcasting the alternative value of c to a new type, Tgt, if any is present.

Parameters
ceve::conditional_expr to transform
tgtTarget type
Returns
A eve::conditional_expr of the same kind that c which alternative value, if any is replaced by the bitcast of c.alternative to Tgt

◆ drop_alternative()

auto eve::drop_alternative ( C c)
constexpr

Returns a conditional without an alternative.

Required header: #include <eve/conditional.hpp>

Parameters
ceve::conditional_expr

◆ map_alternative()

auto eve::map_alternative ( C c,
auto op )

Computes a transformed conditional.

Required header: #include <eve/conditional.hpp>

Creates a eve::conditional_expr by applying an arbitrary operation op on c, thus modifying its alternate value if any is present.

Parameters
ceve::conditional_expr to transform
opUnary callable object to apply
Returns
A eve::conditional_expr of the same kind that c which alternative value, if any is replaced by op(c.alternative)

◆ reverse_conditional()

template<eve::relative_conditional_expr C, typename T>
auto eve::reverse_conditional ( C c,
eve::as< T > tgt )
constexpr

Computes the reverse of a given eve::relative_conditional_expr.

Required header: #include <eve/conditional.hpp>

For a given eve::relative_conditional_expr c, optimally computes the reverse eve::relative_conditional_expr for a given type T. For example, ignoring the first N lanes get reversed as ignoring the last N lanes.

Parameters
cCondition to reverse
tgtWrapped type of the expected output
Returns
The exact semantic opposite of c with the same internal state.

Example

#include <iostream>
#include <eve/wide.hpp>
#include <eve/conditional.hpp>
int main()
{
std::cout << eve::ignore_all << " -> "
std::cout << eve::ignore_none << " -> "
std::cout << eve::keep_first(1) << " -> "
std::cout << eve::ignore_last(1) << " -> "
}
constexpr ignore_all_ ignore_all
Object representing the eve::ignore_all_ conditional expression.
Definition conditional.hpp:209
constexpr auto reverse_conditional(C c, eve::as< T > tgt)
Computes the reverse of a given eve::relative_conditional_expr.
Definition conditional.hpp:823
constexpr ignore_none_ ignore_none
Object representing the eve::ignore_none_ conditional expression.
Definition conditional.hpp:273
Lightweight type-wrapper.
Definition as.hpp:29
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition conditional.hpp:361
Conditional expression selecting the k first lanes from a eve::simd_value.
Definition conditional.hpp:283