You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
XSIMD_INLINE batch_bool<T, A> select(batch_bool<T, A> const& cond, batch_bool<T, A> const& true_br, batch_bool<T, A> const& false_br, requires_arch<common>)
225
+
{
226
+
using register_type = typename batch_bool<T, A>::register_type;
227
+
// Do not cast, but rather reinterpret the masks as batches.
228
+
constauto true_v = batch<T, A> { static_cast<register_type>(true_br) };
229
+
constauto false_v = batch<T, A> { static_cast<register_type>(false_br) };
230
+
return batch_bool<T, A> { select(cond, true_v, false_v) };
XSIMD_INLINE batch_bool<T, A> select(batch_bool<T, A> const& cond, batch_bool<T, A> const& true_br, batch_bool<T, A> const& false_br, requires_arch<common>)
XSIMD_INLINE batch_bool<T, A> select(batch_bool_constant<T, A, Values...> const& cond, batch_bool<T, A> const& true_br, batch_bool<T, A> const& false_br, requires_arch<common>)
Copy file name to clipboardExpand all lines: include/xsimd/types/xsimd_api.hpp
+42Lines changed: 42 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2138,6 +2138,27 @@ namespace xsimd
2138
2138
return kernel::select<A>(cond, true_br, false_br, A {});
2139
2139
}
2140
2140
2141
+
/**
2142
+
* @ingroup batch_bool_logical
2143
+
*
2144
+
* Ternary operator for conditions: selects values from the batches \c true_br or \c false_br
2145
+
* depending on the boolean values in the constant batch \c cond. Equivalent to
2146
+
* \code{.cpp}
2147
+
* for(std::size_t i = 0; i < N; ++i)
2148
+
* res[i] = cond[i] ? true_br[i] : false_br[i];
2149
+
* \endcode
2150
+
* @param cond batch condition.
2151
+
* @param true_br batch values for truthy condition.
2152
+
* @param false_br batch value for falsy condition.
2153
+
* @return the result of the selection.
2154
+
*/
2155
+
template <classT, classA>
2156
+
XSIMD_INLINE batch_bool<T, A> select(batch_bool<T, A> const& cond, batch_bool<T, A> const& true_br, batch_bool<T, A> const& false_br) noexcept
2157
+
{
2158
+
detail::static_check_supported_config<T, A>();
2159
+
return kernel::select<A>(cond, true_br, false_br, A {});
2160
+
}
2161
+
2141
2162
/**
2142
2163
* @ingroup batch_cond
2143
2164
*
@@ -2180,6 +2201,27 @@ namespace xsimd
2180
2201
return kernel::select<A>(cond, true_br, false_br, A {});
2181
2202
}
2182
2203
2204
+
/**
2205
+
* @ingroup batch_cond
2206
+
*
2207
+
* Ternary operator for mask batches: selects values from the masks \c true_br or \c false_br
2208
+
* depending on the boolean values in the constant batch \c cond. Equivalent to
2209
+
* \code{.cpp}
2210
+
* for(std::size_t i = 0; i < N; ++i)
2211
+
* res[i] = cond[i] ? true_br[i] : false_br[i];
2212
+
* \endcode
2213
+
* @param cond constant batch condition.
2214
+
* @param true_br batch values for truthy condition.
2215
+
* @param false_br batch value for falsy condition.
2216
+
* @return the result of the selection.
2217
+
*/
2218
+
template <classT, classA, bool... Values>
2219
+
XSIMD_INLINE batch_bool<T, A> select(batch_bool_constant<T, A, Values...> const& cond, batch_bool<T, A> const& true_br, batch_bool<T, A> const& false_br) noexcept
2220
+
{
2221
+
detail::static_check_supported_config<T, A>();
2222
+
return kernel::select<A>(cond, true_br, false_br, A {});
0 commit comments