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
@@ -2099,6 +2099,27 @@ namespace xsimd
2099
2099
return kernel::select<A>(cond, true_br, false_br, A {});
2100
2100
}
2101
2101
2102
+
/**
2103
+
* @ingroup batch_bool_logical
2104
+
*
2105
+
* Ternary operator for conditions: selects values from the batches \c true_br or \c false_br
2106
+
* depending on the boolean values in the constant batch \c cond. Equivalent to
2107
+
* \code{.cpp}
2108
+
* for(std::size_t i = 0; i < N; ++i)
2109
+
* res[i] = cond[i] ? true_br[i] : false_br[i];
2110
+
* \endcode
2111
+
* @param cond batch condition.
2112
+
* @param true_br batch values for truthy condition.
2113
+
* @param false_br batch value for falsy condition.
2114
+
* @return the result of the selection.
2115
+
*/
2116
+
template <classT, classA>
2117
+
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
2118
+
{
2119
+
detail::static_check_supported_config<T, A>();
2120
+
return kernel::select<A>(cond, true_br, false_br, A {});
2121
+
}
2122
+
2102
2123
/**
2103
2124
* @ingroup batch_cond
2104
2125
*
@@ -2141,6 +2162,27 @@ namespace xsimd
2141
2162
return kernel::select<A>(cond, true_br, false_br, A {});
2142
2163
}
2143
2164
2165
+
/**
2166
+
* @ingroup batch_cond
2167
+
*
2168
+
* Ternary operator for mask batches: selects values from the masks \c true_br or \c false_br
2169
+
* depending on the boolean values in the constant batch \c cond. Equivalent to
2170
+
* \code{.cpp}
2171
+
* for(std::size_t i = 0; i < N; ++i)
2172
+
* res[i] = cond[i] ? true_br[i] : false_br[i];
2173
+
* \endcode
2174
+
* @param cond constant batch condition.
2175
+
* @param true_br batch values for truthy condition.
2176
+
* @param false_br batch value for falsy condition.
2177
+
* @return the result of the selection.
2178
+
*/
2179
+
template <classT, classA, bool... Values>
2180
+
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
2181
+
{
2182
+
detail::static_check_supported_config<T, A>();
2183
+
return kernel::select<A>(cond, true_br, false_br, A {});
0 commit comments