25 #ifndef _GLIBCXX_SIMD_ALG_H
26 #define _GLIBCXX_SIMD_ALG_H 1
28 #ifdef _GLIBCXX_SYSHDR
29 #pragma GCC system_header
32 #if __cplusplus >= 202400L
37 #pragma GCC diagnostic push
38 #pragma GCC diagnostic ignored "-Wpsabi"
41 namespace std _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
46 template<
typename _Tp,
typename _Ap>
47 [[__gnu__::__always_inline__]]
48 constexpr basic_vec<_Tp, _Ap>
49 min(
const basic_vec<_Tp, _Ap>& __a,
const basic_vec<_Tp, _Ap>& __b) noexcept
50 {
return __select_impl(__a < __b, __a, __b); }
52 template<
typename _Tp,
typename _Ap>
53 [[__gnu__::__always_inline__]]
54 constexpr basic_vec<_Tp, _Ap>
55 max(
const basic_vec<_Tp, _Ap>& __a,
const basic_vec<_Tp, _Ap>& __b) noexcept
56 {
return __select_impl(__a < __b, __b, __a); }
58 template<
typename _Tp,
typename _Ap>
59 [[__gnu__::__always_inline__]]
60 constexpr pair<basic_vec<_Tp, _Ap>, basic_vec<_Tp, _Ap>>
61 minmax(
const basic_vec<_Tp, _Ap>& __a,
const basic_vec<_Tp, _Ap>& __b) noexcept
62 {
return {
min(__a, __b),
max(__a, __b)}; }
64 template<
typename _Tp,
typename _Ap>
65 [[__gnu__::__always_inline__]]
66 constexpr basic_vec<_Tp, _Ap>
67 clamp(
const basic_vec<_Tp, _Ap>& __v,
const basic_vec<_Tp, _Ap>& __lo,
68 const basic_vec<_Tp, _Ap>& __hi)
70 __glibcxx_simd_precondition(none_of(__lo > __hi),
"lower bound is larger than upper bound");
71 return max(__lo,
min(__hi, __v));
74 template<
typename _Tp,
typename _Up>
76 select(
bool __c,
const _Tp& __a,
const _Up& __b)
77 -> remove_cvref_t<decltype(__c ? __a : __b)>
78 {
return __c ? __a : __b; }
80 template<
size_t _Bytes,
typename _Ap,
typename _Tp,
typename _Up>
81 [[__gnu__::__always_inline__]]
83 select(
const basic_mask<_Bytes, _Ap>& __c,
const _Tp& __a,
const _Up& __b)
84 noexcept -> decltype(__select_impl(__c, __a, __b))
85 {
return __select_impl(__c, __a, __b); }
93 _GLIBCXX_END_NAMESPACE_VERSION
96 #pragma GCC diagnostic pop
constexpr const _Tp & clamp(const _Tp &, const _Tp &, const _Tp &)
Returns the value clamped between lo and hi.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
constexpr pair< const _Tp &, const _Tp & > minmax(const _Tp &, const _Tp &)
Determines min and max at once as an ordered pair.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.