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

◆ first_true

callable_first_true_ eve::first_true = {}
inlineconstexpr
#include <eve/module/core.hpp>

Should you check for any?

The function is considering the case when nothing is set to be likely, checking for eve::any before hand is not going to be helpful. At the moment there isn't a function that would do it otherwise.

What if I know there is a match?

We would recommend *evefirst_true(m) - this is likely to trigger compiler optimizations, based on it being UB otherwise.

Callable Signatures

template <logical_simd_value L>
std::optional<std::ptrdiff_t> first_true(L m); // (1)
template <logical_simd_value L>
std::optional<std::ptrdiff_t> first_true(top_bits<L> m); // (2)
template <relative_conditional_expr C, logical_simd_value L>
std::optional<std::ptrdiff_t> first_true[C ignore](L m); // (3)
std::optional<std::ptrdiff_t> first_true(bool m); // (4)
constexpr callable_first_true_ first_true
A function to find a first true value, if there is one.
Definition first_true.hpp:65
The cheapest to get bitset for simd logical.
Definition forward.hpp:16

Parameters

Return value

Returns std::nullopt if eve::none(m). Otherwise returns 0 based index.

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 << "-> first_true(wu0 >= maximum(wu0)/2) = " << *eve::first_true(wu0 >= eve::maximum(wu0)/2) << "\n";
std::cout << "-> first_true[ignore_first(4)](wu0 <= maximum(wu0)/2 > 1u) = " << *eve::first_true[eve::ignore_first(4)](wu0 > 1u) << "\n";
}
constexpr callable_maximum_ maximum
Computes the maximal value in a simd vector.
Definition maximum.hpp:55
Conditional expression ignoring the k first lanes from a eve::simd_value.
Definition conditional.hpp:459
Wrapper for SIMD registers.
Definition wide.hpp:70