std::experi...or==,!=,,>=(3)
π C++ Standard Libary: std::experi...or==,!=,,>=(3) π
Manual page for std::experimental::simd::operator==,!=,<,<=,>,>= β and yeah, the βLibaryβ spelling is straight from the header, donβt come for me π. This is the C++ Standard Library page for all the element-wise comparison operators on std::experimental::simd.
π NAME π
std::experimental::simd::operator==,!=,,>=βstd::experimental::simd::operator==,!=,,>=
β¨ Synopsis β¨
Six friend functions, each one noexcept, each one tagged (parallelism TS v2). Numbered like the original:
friend simd_mask operator==( const simd& lhs, const simd& rhs ) noexcept;β (1)(parallelism TS v2)friend simd_mask operator!=( const simd& lhs, const simd& rhs ) noexcept;β (2)(parallelism TS v2)friend simd_mask operator<( const simd& lhs, const simd& rhs ) noexcept;β (3)(parallelism TS v2)friend simd_mask operator<=( const simd& lhs, const simd& rhs ) noexcept;β (4)(parallelism TS v2)friend simd_mask operator>( const simd& lhs, const simd& rhs ) noexcept;β (5)(parallelism TS v2)friend simd_mask operator>=( const simd& lhs, const simd& rhs ) noexcept;β (6)(parallelism TS v2)
Okay so the tea β: these apply the given comparison element-wise to each corresponding element of the operands. You get back a simd_mask such that for all i in the range of [0, size()) the i^th element equals:
lhs[i] == rhs[i].lhs[i] != rhs[i].lhs[i] < rhs[i].lhs[i] <= rhs[i].lhs[i] > rhs[i].lhs[i] >= rhs[i].
π«Ά Parameters π«Ά
lhsβ left operands. The left side of the comparison, bestie.rhsβ right operands. The right side, obviously.
πΈ Example πΈ
Run this code, bestie β hereβs the whole example, no skips π:
// Run this code
#include <cassert>
#include <iostream>
#include <initializer_list>
#include <iterator>
#include <experimental/simd>
namespace stdx = std::experimental;
int main()
{
using V = stdx::fixed_size_simd<int, 4>;
using M = stdx::fixed_size_simd_mask<int, 4>;
auto assert_equivalence = [](M&& x, std::initializer_list<int>&& y)
{
for (decltype(M::size()) i{}; i != M::size(); ++i)
assert(x[i] == std::cbegin(y)[i]);
};
V a{2}, b, c{3};
b[0] = 1, b[1] = 2, b[2] = 3, b[3] = 4;
// a == {2, 2, 2, 2}
// b == {1, 2, 3, 4}
// c == {3, 3, 3, 3}
assert_equivalence(a == a, {1, 1, 1, 1});
assert_equivalence(a == b, {0, 1, 0, 0});
assert_equivalence(b == c, {0, 0, 1, 0});
assert_equivalence(a == c, {0, 0, 0, 0});
assert_equivalence(a != a, {0, 0, 0, 0});
assert_equivalence(a != b, {1, 0, 1, 1});
assert_equivalence(b != c, {1, 1, 0, 1});
assert_equivalence(a != c, {1, 1, 1, 1});
assert_equivalence(a < a, {0, 0, 0, 0});
assert_equivalence(a < b, {0, 0, 1, 1});
assert_equivalence(b < c, {1, 1, 0, 0});
assert_equivalence(a < c, {1, 1, 1, 1});
}
π¦ See also π¦
all_of,any_of,none_of,some_ofβ reductions ofsimd_masktobool(function template)(parallelism TS v2)popcountβ reduction ofsimd_maskto the number oftruevalues (function template)(parallelism TS v2)find_first_set,find_last_setβ reductions ofsimd_maskto the index of the first or lasttruevalue (function template)(parallelism TS v2)simd_maskβ data-parallel type with the element typebool(class template)(parallelism TS v2)
Source/version: http://cppreference.com Β· date: 2024.06.10 Β· page: std::experi...or==,!=,,>=(3). Stay slay, bestie π
πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms