16#include <xvec/detail/config.hpp>
17#include <xvec/detail/utilities.hpp>
19#if defined(__INTEL_CLANG_COMPILER) && !defined(_XVEC_FORCE_SCALAR)
20 #include <xvec/x86/math.hpp>
22 #include <xvec/generic/math.hpp>
25namespace _XVEC_NAMESPACE::simd
49template<detail::math_
floating_po
int _Vp>
constexpr detail::deduced_vec_t<_Vp>
abs(
const _Vp& v) {
return detail::abs(target, v); }
56template<vec_
signed_
integral _Vp>
constexpr _Vp
abs(
const _Vp& v) {
return detail::abs(target, v); }
63template<detail::math_
floating_po
int _Vp>
64constexpr detail::deduced_vec_t<_Vp>
copysign(
const _Vp& magnitude,
const _Vp& sign)
66 using detail::vec_as_container;
71 constexpr auto signBit =
vec_as_container(_Vp(
typename _Vp::value_type(-0.0)));
73 return std::bit_cast<_Vp>(tAbs | tSign);
85template<detail::math_
floating_po
int _Vp>
constexpr detail::deduced_vec_t<_Vp>
rcp (
const _Vp& v) {
return detail::rcp(target, v); }
91template<detail::math_
floating_po
int _Vp>
constexpr detail::deduced_vec_t<_Vp>
rsqrt(
const _Vp& v) {
return detail::rsqrt(target, v); }
102template<detail::math_
floating_po
int _Vp>
constexpr detail::deduced_vec_t<_Vp>
sqrt (
const _Vp& v) {
return detail::sqrt(target, v); }
110template<detail::math_
floating_po
int _Vp>
constexpr detail::deduced_vec_t<_Vp>
111 fma (
const _Vp& lhs,
const _Vp& rhs,
const _Vp& acc) {
return detail::fma(target, lhs, rhs, acc); }
124template<vec_complex _Vp>
125constexpr _Vp
fma (
const _Vp& lhs,
const _Vp& rhs,
const _Vp& acc)
126 {
return detail::fma(target, lhs, rhs, acc); }
135template<detail::math_
floating_po
int _Vp>
136constexpr detail::deduced_vec_t<_Vp>
fmaddsub(
const _Vp& lhs,
const _Vp& rhs,
const _Vp& acc)
137 {
return detail::fmaddsub(target, lhs, rhs, acc); }
146template<detail::math_
floating_po
int _Vp>
147constexpr detail::deduced_vec_t<_Vp>
fmsubadd(
const _Vp& lhs,
const _Vp& rhs,
const _Vp& acc)
148 {
return detail::fmsubadd(target, lhs, rhs, acc); }
159template<detail::math_
floating_po
int _Vp>
160constexpr detail::deduced_vec_t<_Vp>
ceil(
const _Vp& v) {
161 #if __has_builtin(__builtin_elementwise_ceil)
162 return __builtin_elementwise_ceil(v.to_builtin());
172template<detail::math_
floating_po
int _Vp>
173constexpr detail::deduced_vec_t<_Vp>
floor(
const _Vp& v)
175 #if __has_builtin(__builtin_elementwise_floor)
176 return __builtin_elementwise_floor(v.to_builtin());
186template<detail::math_
floating_po
int _Vp>
187constexpr detail::deduced_vec_t<_Vp>
trunc(
const _Vp& v) {
188 #if __has_builtin(__builtin_elementwise_trunc)
189 return __builtin_elementwise_trunc(v.to_builtin());
199template<detail::math_
floating_po
int _Vp>
200constexpr detail::deduced_vec_t<_Vp>
rint(
const _Vp& v) {
201 #if __has_builtin(__builtin_elementwise_rint)
202 return __builtin_elementwise_rint(v.to_builtin());
212template<detail::math_
floating_po
int _Vp>
213constexpr detail::deduced_vec_t<_Vp>
round(
const _Vp& v) {
214 #if __has_builtin(__builtin_elementwise_roundeven)
215 return __builtin_elementwise_round(v.to_builtin());
227template<math_
floating_po
int _Vp>
232 constexpr auto expMask =
vec_as_container(std::numeric_limits<_Vp>::infinity());
237 using _Tp =
typename _Vp::value_type;
238 constexpr auto fm = std::bit_cast<container_for_type<_Tp>>(std::numeric_limits<_Tp>::min()) - 1;
239 constexpr auto fractionMask =
typename _Vp::traits::element_container_type(fm);
245 return ((asC & expMask) == expMask) & ((asC & fractionMask) != std::uint8_t(0));
250template<detail::math_
floating_po
int _Vp>
252 {
return !
isnan(tag, v) && (
abs(v) > std::numeric_limits<_Vp>::max()); }
256template<detail::math_
floating_po
int _Vp>
262template<detail::math_
floating_po
int _Vp>
265 return (
abs(v) >= std::numeric_limits<_Vp>::min()) &&
266 (
abs(v) <= std::numeric_limits<_Vp>::max());
271template<detail::math_
floating_po
int _Vp>
274 constexpr auto signBit =
vec_as_container(_Vp(
typename _Vp::value_type(-0.0)));
276 return detail::deduced_mask_t<_Vp>(m);
290template<detail::math_
floating_po
int _Vp>
297template<detail::math_
floating_po
int _Vp>
304template<detail::math_
floating_po
int _Vp>
311template<detail::math_
floating_po
int _Vp>
319template<detail::math_
floating_po
int _Vp>
330template<vec_
integral _Vp>
331constexpr typename _Vp::mask_type
signbit(
const _Vp& v) {
333 return typename _Vp::mask_type(
false);
345template<detail::math_
floating_po
int _Vp>
346constexpr detail::deduced_mask_t<_Vp>
isgreater(
const _Vp& x,
const _Vp& y) {
return x > y; }
352template<detail::math_
floating_po
int _Vp>
353constexpr detail::deduced_mask_t<_Vp>
isgreaterequal(
const _Vp& x,
const _Vp& y) {
return x >= y; }
359template<detail::math_
floating_po
int _Vp>
360constexpr detail::deduced_mask_t<_Vp>
isless(
const _Vp& x,
const _Vp& y) {
return x < y; }
366template<detail::math_
floating_po
int _Vp>
367constexpr detail::deduced_mask_t<_Vp>
islessequal(
const _Vp& x,
const _Vp& y) {
return x <= y; }
373template<detail::math_
floating_po
int _Vp>
374constexpr detail::deduced_mask_t<_Vp>
islessgreater(
const _Vp& x,
const _Vp& y) {
return (x < y) | (x > y); }
380template<detail::math_
floating_po
int _Vp>
387_XVEC_UNARY_MATHS_OP(exp);
388_XVEC_UNARY_MATHS_OP(exp2);
389_XVEC_UNARY_MATHS_OP(expm1);
390_XVEC_UNARY_MATHS_OP(log);
391_XVEC_UNARY_MATHS_OP(log2);
392_XVEC_UNARY_MATHS_OP(log1p);
395_XVEC_UNARY_MATHS_OP(sin); _XVEC_UNARY_MATHS_OP(asin);
396_XVEC_UNARY_MATHS_OP(cos); _XVEC_UNARY_MATHS_OP(acos);
397_XVEC_UNARY_MATHS_OP(tan); _XVEC_UNARY_MATHS_OP(atan);
399_XVEC_UNARY_MATHS_OP(sinh); _XVEC_UNARY_MATHS_OP(asinh);
400_XVEC_UNARY_MATHS_OP(cosh); _XVEC_UNARY_MATHS_OP(acosh);
401_XVEC_UNARY_MATHS_OP(tanh); _XVEC_UNARY_MATHS_OP(atanh);
405_XVEC_UNARY_MATHS_OP(cbrt);
406_XVEC_BINARY_MATHS_OP(hypot);
407_XVEC_BINARY_MATHS_OP(pow);
410_XVEC_UNARY_MATHS_OP(erf);
411_XVEC_UNARY_MATHS_OP(erfc);
417namespace _XVEC_NAMESPACE
420 using simd::copysign;
431 using simd::isfinite;
432 using simd::isnormal;
434 using simd::isgreater;
435 using simd::isgreaterequal;
437 using simd::islessequal;
438 using simd::islessgreater;
439 using simd::isunordered;
475#undef _XVEC_UNARY_MATHS_OP
476#undef _XVEC_BINARY_MATHS_OP
478#undef _XVEC_SSE_UNARY_MATHS_OP
479#undef _XVEC_SSE_BINARY_MATHS_OP
480#undef _XVEC_AVX_UNARY_MATHS_OP
481#undef _XVEC_AVX_BINARY_MATHS_OP
482#undef _XVEC_AVX512_UNARY_MATHS_OP
483#undef _XVEC_AVX512_BINARY_MATHS_OP
484#undef _XVEC_AVX512FP16_UNARY_MATHS_OP
485#undef _XVEC_AVX512FP16_BINARY_MATHS_OP
constexpr auto abs(const _Vc &value)
Compute the magnitude of each complex element.
Definition std_complex.hpp:55
constexpr auto vec_as_container(const _Vp &v)
Generate a variable containing the iota sequence (i.e., 0, 1, 2, ... size-1) for the given simd::vec ...
Definition generic_impl.hpp:116
constexpr detail::deduced_mask_t< _Vp > isless(const _Vp &x, const _Vp &y)
Compare corresponding elements using less-than.
Definition std_math.hpp:360
constexpr detail::deduced_mask_t< _Vp > isgreaterequal(const _Vp &x, const _Vp &y)
Compare corresponding elements using greater-than-or-equal.
Definition std_math.hpp:353
constexpr detail::deduced_vec_t< _Vp > rint(const _Vp &v)
Round each element to an integer using the current rounding mode.
Definition std_math.hpp:200
constexpr detail::deduced_vec_t< _Vp > sqrt(const _Vp &v)
Compute the square root of each element.
Definition std_math.hpp:102
constexpr detail::deduced_mask_t< _Vp > isnormal(const _Vp &v)
Identify normal floating-point elements.
Definition std_math.hpp:312
constexpr detail::deduced_mask_t< _Vp > islessequal(const _Vp &x, const _Vp &y)
Compare corresponding elements using less-than-or-equal.
Definition std_math.hpp:367
constexpr detail::deduced_mask_t< _Vp > signbit(const _Vp &v)
Identify elements whose sign bit is set. This includes negative zero and negative values of infinity ...
Definition std_math.hpp:320
constexpr detail::deduced_vec_t< _Vp > fma(const _Vp &lhs, const _Vp &rhs, const _Vp &acc)
Compute (lhs * rhs) + acc element-wise with a single rounding.
Definition std_math.hpp:111
constexpr detail::deduced_mask_t< _Vp > isgreater(const _Vp &x, const _Vp &y)
Compare corresponding elements using greater-than.
Definition std_math.hpp:346
constexpr detail::deduced_mask_t< _Vp > isfinite(const _Vp &v)
Identify finite elements.
Definition std_math.hpp:305
constexpr detail::deduced_mask_t< _Vp > isunordered(const _Vp &x, const _Vp &y)
Identify unordered element pairs.
Definition std_math.hpp:381
constexpr detail::deduced_mask_t< _Vp > islessgreater(const _Vp &x, const _Vp &y)
Identify corresponding elements that compare less or greater.
Definition std_math.hpp:374
constexpr detail::deduced_mask_t< _Vp > isnan(const _Vp &v)
Identify elements representing NaN.
Definition std_math.hpp:298
constexpr detail::deduced_vec_t< _Vp > copysign(const _Vp &magnitude, const _Vp &sign)
Combine corresponding magnitudes and signs.
Definition std_math.hpp:64
constexpr detail::deduced_mask_t< _Vp > isinf(const _Vp &v)
Identify elements representing positive or negative infinity.
Definition std_math.hpp:291
constexpr detail::deduced_vec_t< _Vp > fmaddsub(const _Vp &lhs, const _Vp &rhs, const _Vp &acc)
Compute lhs * rhs - acc at even indexes and lhs * rhs + acc at odd indexes. Each expression is comput...
Definition std_math.hpp:136
_Vc floor(const _Vc &value)
Round the real and imaginary components of each element downward.
Definition std_complex.hpp:73
_Vc round(const _Vc &value)
Apply round independently to the real and imaginary components.
Definition std_complex.hpp:87
constexpr detail::deduced_vec_t< _Vp > rcp(const _Vp &v)
Compute the approximate reciprocal of each element.
Definition std_math.hpp:85
constexpr detail::deduced_vec_t< _Vp > fmsubadd(const _Vp &lhs, const _Vp &rhs, const _Vp &acc)
Compute lhs * rhs + acc at even indexes and lhs * rhs - acc at odd indexes. Each expression is comput...
Definition std_math.hpp:147
_Vc trunc(const _Vc &value)
Truncate the real and imaginary components of each element.
Definition std_complex.hpp:80
constexpr detail::deduced_vec_t< _Vp > rsqrt(const _Vp &v)
Compute the approximate reciprocal square root of each element.
Definition std_math.hpp:91
_Vc ceil(const _Vc &value)
Round the real and imaginary components of each element upward.
Definition std_complex.hpp:66
constexpr detail::deduced_mask_t< _Vp > isnormal(generic_tag, const _Vp &v)
Definition std_math.hpp:263
constexpr basic_vec< _Tp, _Abi > rsqrt(x86_sse_tag, const basic_vec< _Tp, _Abi > &v)
Constants which specify to the compiler intrinsic which FP classification operation to perform.
Definition x86_impl.hpp:1493
constexpr basic_vec< _Tp, _Abi > sqrt(x86_sse_tag, const basic_vec< _Tp, _Abi > &v)
Constants which specify to the compiler intrinsic which FP classification operation to perform.
Definition x86_impl.hpp:1544
constexpr detail::deduced_mask_t< _Vp > isinf(generic_tag tag, const _Vp &v)
Definition std_math.hpp:251
constexpr detail::deduced_mask_t< _Vp > signbit(generic_tag, const _Vp &v)
Definition std_math.hpp:272
constexpr basic_vec< _Tp, _Abi > rcp(x86_sse_tag, const basic_vec< _Tp, _Abi > &v)
Constants which specify to the compiler intrinsic which FP classification operation to perform.
Definition x86_impl.hpp:1443
constexpr deduced_mask_t< _Vp > isnan(generic_tag, const _Vp &v)
Definition std_math.hpp:228
constexpr basic_vec< _Tp, _Abi > round_op(x86_tag, const basic_vec< _Tp, _Abi > &v)
Rounding operations (ceil, floor, etc.).
Definition x86_impl.hpp:353
constexpr detail::deduced_mask_t< _Vp > isfinite(generic_tag tag, const _Vp &v)
Definition std_math.hpp:257
Definition target_config.hpp:23