2namespace NATIVE_BACKEND_NAMESPACE::native {
4 template<
bool Flush = false,
unsigned Degree = 6,
float_register V, std::
size_t N>
5 requires (Degree >= 1 && Degree <= 7)
6 [[nodiscard]] hint_flatten hint_inline
constexpr hint_pure std::array<V, N> exp(std::array<V, N>
const & input)
noexcept {
7 if constexpr (N == 0)
return input;
9 auto const [masks, replacements, values, exponents] =
10 ::math::detail::exp_reduced<Flush, Degree>(::wide::promote(input));
11 auto const & [...in_range] = masks;
12 auto const & [...replacement] = replacements;
13 auto const & [...y] = values;
14 auto const & [...n] = exponents;
17 return {{::wide::detail::native_ops<V>::exp_scale(in_range, replacement, y, n)...}};
20 template<
bool Flush = false,
unsigned Degree = 6,
float_register V>
21 requires (Degree >= 1 && Degree <= 7)
22 [[nodiscard]] hint_inline
constexpr hint_pure V exp(V x)
noexcept {
23 return ::NATIVE_BACKEND_NAMESPACE::native::exp<Flush, Degree>(std::array{x})[0];
25#if NATIVE_HAS_ARM_NEON
26 [[nodiscard]] hint_inline
constexpr hint_pure float32x4_t exp(float32x4_t x)
noexcept {
27 return ::NATIVE_BACKEND_NAMESPACE::native::exp(fp32x4(x)).value;
29 template<std::
size_t N>
30 [[nodiscard]] hint_inline
constexpr hint_pure std::array<float32x4_t, N> exp(std::array<float32x4_t, N>
const & input)
noexcept {
31 if constexpr (N == 0)
return {};
33 auto const & [...value] = input;
34 auto const [...result] = ::NATIVE_BACKEND_NAMESPACE::native::exp(std::array{fp32x4(value)...});
35 return {{result.value...}};
43#define NATIVE_PROMOTED_MATH_ENTRY(name) \
44 template<std::size_t L, ::native::isa<> Arch> \
45 requires NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L> \
46 [[nodiscard]] hint_inline constexpr simd<float,L,Arch> name(simd<float,L,Arch> input) noexcept { \
47 return ::math::name(input); \
49 template<std::size_t L, std::size_t N, ::native::isa<> Arch> \
50 requires NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L> \
51 [[nodiscard]] hint_inline constexpr std::array<simd<float,L,Arch>,N> \
52 name(std::array<simd<float,L,Arch>,N> const & input) noexcept { return ::math::name(input); }
53 NATIVE_PROMOTED_MATH_ENTRY(
expm1)
55 NATIVE_PROMOTED_MATH_ENTRY(
log)
56 NATIVE_PROMOTED_MATH_ENTRY(
log2)
57 NATIVE_PROMOTED_MATH_ENTRY(
log1p)
58 NATIVE_PROMOTED_MATH_ENTRY(
tanh)
59#undef NATIVE_PROMOTED_MATH_ENTRY
62 template<
bool Flush = false, std::
size_t L, ::native::isa<> Arch>
63 requires NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L>
68 template<
bool Flush = false, std::
size_t L, std::
size_t N, ::native::isa<> Arch>
69 requires NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L>
70 [[nodiscard]] hint_inline
constexpr std::array<simd<float,L,Arch>,N>
74 template<
bool Flush, std::
size_t L, ::native::isa<> Arch>
75 requires NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L>
76 [[nodiscard]] hint_inline
constexpr simd<float,L,Arch>
80 template<
bool Flush, std::
size_t L, std::
size_t N, ::native::isa<> Arch>
81 requires NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L>
82 [[nodiscard]] hint_inline
constexpr std::array<simd<float,L,Arch>,N>
84 return ::math::exp2<Flush>(input);
88 template<std::
size_t L, ::native::isa<> Arch>
89 requires NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L>
90 [[nodiscard]] hint_inline
constexpr simd<float,L,Arch>
94 template<std::
size_t L, std::
size_t N, ::native::isa<> Arch>
95 requires NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L>
96 [[nodiscard]] hint_inline
constexpr std::array<simd<float,L,Arch>,N>
108 template<
bool Flush = false,
unsigned Degree = 6, std::
size_t L, ::native::isa<> Arch>
requires (Degree >= 1 && Degree <= 7) && NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L>
110 return ::NATIVE_BACKEND_NAMESPACE::native::exp<Flush, Degree>(input);
114 template<
bool Flush = false,
unsigned Degree = 6, std::
size_t L, std::
size_t N, ::native::isa<> Arch>
requires (Degree >= 1 && Degree <= 7) && NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L>
115 [[nodiscard]] hint_inline
constexpr std::array<simd<float,L,Arch>,N>
exp(std::array<
simd<float,L,Arch>,N>
const & input)
noexcept {
116 return ::NATIVE_BACKEND_NAMESPACE::native::exp<Flush, Degree>(input);
122 template<
bool Flush,
unsigned Degree = 6, std::
size_t L, std::
size_t N, ::native::isa<> Arch>
requires (Degree >= 1 && Degree <= 7) && NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L>
123 [[nodiscard]] hint_inline
constexpr std::array<simd<float,L,Arch>,N>
exp(
124 std::array<
simd<float,L,Arch>,N>
const & input, std::bool_constant<Flush>, std::integral_constant<unsigned, Degree> = {})
noexcept {
125 return ::NATIVE_BACKEND_NAMESPACE::native::exp<Flush, Degree>(input);
129 template<
bool Flush,
unsigned Degree = 6, std::
size_t L, ::native::isa<> Arch>
requires (Degree >= 1 && Degree <= 7) && NATIVE_ARCH_REQUIRES(Arch) && ::NATIVE_BACKEND_NAMESPACE::float_shape<L>
131 return ::NATIVE_BACKEND_NAMESPACE::native::exp<Flush, Degree>(input);
147#define NATIVE_POLYFILL_MATH_ENTRY(NAME) \
149 template<std::size_t L,isa<> A> requires NATIVE_ARCH_REQUIRES(A) && detail::polyfill_operation_shape<float,L,A> \
150 constexpr simd<float,L,A> NAME(simd<float,L,A> input) noexcept { return ::math::NAME(input); } \
152 template<std::size_t L,std::size_t N,isa<> A> requires NATIVE_ARCH_REQUIRES(A) && detail::polyfill_operation_shape<float,L,A> \
153 constexpr std::array<simd<float,L,A>,N> NAME(std::array<simd<float,L,A>,N> const & input) noexcept { return ::math::NAME(input); }
154 NATIVE_POLYFILL_MATH_ENTRY(
expm1)
156 NATIVE_POLYFILL_MATH_ENTRY(
log)
157 NATIVE_POLYFILL_MATH_ENTRY(
log2)
158 NATIVE_POLYFILL_MATH_ENTRY(
log1p)
159 NATIVE_POLYFILL_MATH_ENTRY(
tanh)
160 NATIVE_POLYFILL_MATH_ENTRY(
sin)
161 NATIVE_POLYFILL_MATH_ENTRY(
cos)
162#undef NATIVE_POLYFILL_MATH_ENTRY
164 template<std::
size_t L,isa<> A>
requires NATIVE_ARCH_REQUIRES(A) && detail::polyfill_operation_shape<float,L,A>
167 template<std::
size_t L,std::
size_t N,isa<> A>
requires NATIVE_ARCH_REQUIRES(A) && detail::polyfill_operation_shape<float,L,A>
170 template<
bool Flush=false,
unsigned Degree=6,std::
size_t L,isa<> A>
171 requires NATIVE_ARCH_REQUIRES(A) && detail::polyfill_operation_shape<float,L,A> && (Degree>=1 && Degree<=7)
174 template<
bool Flush=false,
unsigned Degree=6,std::
size_t L,std::
size_t N,isa<> A>
175 requires NATIVE_ARCH_REQUIRES(A) && detail::polyfill_operation_shape<float,L,A> && (Degree>=1 && Degree<=7)
178 template<
bool Flush,
unsigned Degree=6,
class V>
179 requires NATIVE_ARCH_REQUIRES(V::architecture) && detail::polyfill_operation_shape<float,V::lanes,V::architecture> && (Degree>=1 && Degree<=7)
180 constexpr V
exp(V input,std::bool_constant<Flush>,std::integral_constant<unsigned,Degree> = {})
noexcept {
return exp<Flush,Degree>(input); }
182 template<
bool Flush,
unsigned Degree=6,
class V,std::
size_t N>
183 requires NATIVE_ARCH_REQUIRES(V::architecture) && detail::polyfill_operation_shape<float,V::lanes,V::architecture> && (Degree>=1 && Degree<=7)
184 constexpr std::array<V,N>
exp(std::array<V,N>
const & input,std::bool_constant<Flush>,std::integral_constant<unsigned,Degree> = {})
noexcept {
return exp<Flush,Degree>(input); }
186 template<
bool Flush=false,std::
size_t L,isa<> A>
requires NATIVE_ARCH_REQUIRES(A) && detail::polyfill_operation_shape<float,L,A>
189 template<
bool Flush=false,std::
size_t L,std::
size_t N,isa<> A>
requires NATIVE_ARCH_REQUIRES(A) && detail::polyfill_operation_shape<float,L,A>
190 constexpr std::array<simd<float,L,A>,N>
exp2(std::array<
simd<float,L,A>,N>
const & input)
noexcept { return ::math::exp2<Flush>(input); }
192 template<
bool Flush,
class V>
requires NATIVE_ARCH_REQUIRES(V::architecture) && detail::polyfill_operation_shape<float,V::lanes,V::architecture>
193 constexpr V
exp2(V input,std::bool_constant<Flush>)
noexcept {
return exp2<Flush>(input); }
195 template<
bool Flush,
class V,std::
size_t N>
requires NATIVE_ARCH_REQUIRES(V::architecture) && detail::polyfill_operation_shape<float,V::lanes,V::architecture>
196 constexpr std::array<V,N>
exp2(std::array<V,N>
const & input,std::bool_constant<Flush>)
noexcept {
return exp2<Flush>(input); }
198 template<std::
size_t L,isa<> A>
requires NATIVE_ARCH_REQUIRES(A) && detail::polyfill_operation_shape<float,L,A>
201 template<std::
size_t L,std::
size_t N,isa<> A>
requires NATIVE_ARCH_REQUIRES(A) && detail::polyfill_operation_shape<float,L,A>
202 constexpr std::array<simd<float,L,A>,N>
atan2(std::array<
simd<float,L,A>,N>
const & y,std::array<
simd<float,L,A>,N>
const & x)
noexcept { return ::math::atan2(y,x); }
constexpr simd< float, L, Arch > atan2(simd< float, L, Arch > y, simd< float, L, Arch > x) noexcept
constexpr simd< float, L, Arch > exp2(simd< float, L, Arch > input) noexcept
constexpr simd< float, L, Arch > exp(simd< float, L, Arch > input) noexcept
Evaluate the binary32 range-reduced exponential approximation. Degree selects a polynomial from one t...
constexpr wide< R, N > cos(wide< R, N > const &input) noexcept([] { if constexpr(requires(std::array< R, N > const &a) { detail::wide_generic_detail::adl_cos(a);}) return noexcept(wide< R, N >{detail::wide_generic_detail::adl_cos(std::declval< std::array< R, N > const & >())});else return noexcept(wide< R, N >()) &&std::is_nothrow_move_constructible_v< wide< R, N > > &&(N==0||noexcept(std::declval< R & >()=detail::wide_generic_detail::adl_cos(std::declval< R const & >())));}())
constexpr wide< R, N > tanh(wide< R, N > const &input) noexcept([] { if constexpr(requires(std::array< R, N > const &a) { detail::wide_generic_detail::adl_tanh(a);}) return noexcept(wide< R, N >{detail::wide_generic_detail::adl_tanh(std::declval< std::array< R, N > const & >())});else return noexcept(wide< R, N >()) &&std::is_nothrow_move_constructible_v< wide< R, N > > &&(N==0||noexcept(std::declval< R & >()=detail::wide_generic_detail::adl_tanh(std::declval< R const & >())));}())
constexpr wide< R, N > sin(wide< R, N > const &input) noexcept([] { if constexpr(requires(std::array< R, N > const &a) { detail::wide_generic_detail::adl_sin(a);}) return noexcept(wide< R, N >{detail::wide_generic_detail::adl_sin(std::declval< std::array< R, N > const & >())});else return noexcept(wide< R, N >()) &&std::is_nothrow_move_constructible_v< wide< R, N > > &&(N==0||noexcept(std::declval< R & >()=detail::wide_generic_detail::adl_sin(std::declval< R const & >())));}())
constexpr wide< R, N > log(wide< R, N > const &input) noexcept([] { if constexpr(requires(std::array< R, N > const &a) { detail::wide_generic_detail::adl_log(a);}) return noexcept(wide< R, N >{detail::wide_generic_detail::adl_log(std::declval< std::array< R, N > const & >())});else return noexcept(wide< R, N >()) &&std::is_nothrow_move_constructible_v< wide< R, N > > &&(N==0||noexcept(std::declval< R & >()=detail::wide_generic_detail::adl_log(std::declval< R const & >())));}())
constexpr wide< R, N > log2(wide< R, N > const &input) noexcept([] { if constexpr(requires(std::array< R, N > const &a) { detail::wide_generic_detail::adl_log2(a);}) return noexcept(wide< R, N >{detail::wide_generic_detail::adl_log2(std::declval< std::array< R, N > const & >())});else return noexcept(wide< R, N >()) &&std::is_nothrow_move_constructible_v< wide< R, N > > &&(N==0||noexcept(std::declval< R & >()=detail::wide_generic_detail::adl_log2(std::declval< R const & >())));}())
constexpr wide< R, N > damping_gain(wide< R, N > const &input) noexcept([] { if constexpr(requires(std::array< R, N > const &a) { detail::wide_generic_detail::adl_damping_gain(a);}) return noexcept(wide< R, N >{detail::wide_generic_detail::adl_damping_gain(std::declval< std::array< R, N > const & >())});else return noexcept(wide< R, N >()) &&std::is_nothrow_move_constructible_v< wide< R, N > > &&(N==0||noexcept(std::declval< R & >()=detail::wide_generic_detail::adl_damping_gain(std::declval< R const & >())));}())
constexpr wide< R, N > expm1(wide< R, N > const &input) noexcept([] { if constexpr(requires(std::array< R, N > const &a) { detail::wide_generic_detail::adl_expm1(a);}) return noexcept(wide< R, N >{detail::wide_generic_detail::adl_expm1(std::declval< std::array< R, N > const & >())});else return noexcept(wide< R, N >()) &&std::is_nothrow_move_constructible_v< wide< R, N > > &&(N==0||noexcept(std::declval< R & >()=detail::wide_generic_detail::adl_expm1(std::declval< R const & >())));}())
constexpr wide< R, N > log1p(wide< R, N > const &input) noexcept([] { if constexpr(requires(std::array< R, N > const &a) { detail::wide_generic_detail::adl_log1p(a);}) return noexcept(wide< R, N >{detail::wide_generic_detail::adl_log1p(std::declval< std::array< R, N > const & >())});else return noexcept(wide< R, N >()) &&std::is_nothrow_move_constructible_v< wide< R, N > > &&(N==0||noexcept(std::declval< R & >()=detail::wide_generic_detail::adl_log1p(std::declval< R const & >())));}())
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...
constexpr auto sincos(simd< float, L, A > input) noexcept
Paired sine/cosine preserving the permitted logical lane shape.
Omitted architecture arguments use the native.simd provider's baseline.