native 0.0.1
Vectors, masks and wide register packs for C++26
Loading...
Searching...
No Matches
exp.h
1#pragma once
2#include "native/simd.h"
3#include "native/wide_math.h"
4#define NATIVE_BACKEND_BODY "native/simd/math/exp_body.h"
5#include "native/simd/for_each_backend.h"
6#undef NATIVE_BACKEND_BODY
7
8#if NATIVE_HOST_WASM && (!defined(NATIVE_PROFILE) || NATIVE_PROFILE != 0)
9#pragma clang attribute push(__attribute__((target("simd128"))), apply_to=function)
10namespace native {
12 template<bool Flush = false, unsigned Degree = 6, isa<> A> requires(Degree >= 1 && Degree <= 7 && A.has(wasm_feature::simd128))
14 return ::math::exp<Flush, Degree>(x);
15 }
17 template<bool Flush = false, unsigned Degree = 6, std::size_t N, isa<> A> requires(Degree >= 1 && Degree <= 7 && A.has(wasm_feature::simd128))
18 native_nodiscard native_inline constexpr auto exp(std::array<simd<float,4,A>,N> const & x) noexcept {
19 return ::math::exp<Flush, Degree>(x);
20 }
21 template<bool Flush, unsigned Degree = 6, isa<> A> requires(Degree >= 1 && Degree <= 7 && A.has(wasm_feature::simd128))
22 native_nodiscard native_inline constexpr auto exp(simd<float,4,A> x, std::bool_constant<Flush>, std::integral_constant<unsigned, Degree> = {}) noexcept {
23 return ::math::exp<Flush, Degree>(x);
24 }
25 template<bool Flush, unsigned Degree = 6, std::size_t N, isa<> A> requires(Degree >= 1 && Degree <= 7 && A.has(wasm_feature::simd128))
26 native_nodiscard native_inline constexpr auto exp(std::array<simd<float,4,A>,N> const & x,
27 std::bool_constant<Flush>, std::integral_constant<unsigned, Degree> = {}) noexcept {
28 return ::math::exp<Flush, Degree>(x);
29 }
31 template<bool Flush = false, isa<> A> requires(A.has(wasm_feature::simd128))
33 return ::math::exp2<Flush>(x);
34 }
36 template<bool Flush = false, std::size_t N, isa<> A> requires(A.has(wasm_feature::simd128))
37 native_nodiscard native_inline constexpr auto exp2(std::array<simd<float,4,A>,N> const & x) noexcept {
38 return ::math::exp2<Flush>(x);
39 }
40 template<bool Flush, isa<> A> requires(A.has(wasm_feature::simd128))
41 native_nodiscard native_inline constexpr auto exp2(simd<float,4,A> x, std::bool_constant<Flush>) noexcept {
42 return ::math::exp2<Flush>(x);
43 }
44 template<bool Flush, std::size_t N, isa<> A> requires(A.has(wasm_feature::simd128))
45 native_nodiscard native_inline constexpr auto exp2(std::array<simd<float,4,A>,N> const & x,
46 std::bool_constant<Flush>) noexcept {
47 return ::math::exp2<Flush>(x);
48 }
49#define NATIVE_WASM_MATH(name) \
50 template<isa<> A> requires(A.has(wasm_feature::simd128)) \
51 native_nodiscard native_inline constexpr auto name(simd<float,4,A> x) noexcept { \
52 return ::math::name(x); \
53 } \
54 template<std::size_t N, isa<> A> requires(A.has(wasm_feature::simd128)) \
55 native_nodiscard native_inline constexpr auto name(std::array<simd<float,4,A>,N> const & x) noexcept { \
56 return ::math::name(x); \
57 }
59 NATIVE_WASM_MATH(sin)
60 NATIVE_WASM_MATH(cos)
61 NATIVE_WASM_MATH(sincos)
63 NATIVE_WASM_MATH(expm1)
64 NATIVE_WASM_MATH(damping_gain)
65 NATIVE_WASM_MATH(log)
66 NATIVE_WASM_MATH(log2)
67 NATIVE_WASM_MATH(log1p)
68 NATIVE_WASM_MATH(tanh)
69#undef NATIVE_WASM_MATH
71 template<isa<> A> requires(A.has(wasm_feature::simd128))
73 return ::math::atan2(y,x);
74 }
76 template<std::size_t N, isa<> A> requires(A.has(wasm_feature::simd128))
77 native_nodiscard native_inline constexpr auto atan2(std::array<simd<float,4,A>,N> const & y,
78 std::array<simd<float,4,A>,N> const & x) noexcept { return ::math::atan2(y,x); }
79}
80#pragma clang attribute pop
81#endif
#define native_inline
inline [[always_inline]]
Definition attributes.h:212
#define native_nodiscard
C++17 [[nodiscard]].
Definition attributes.h:189
constexpr simd< float, L, Arch > atan2(simd< float, L, Arch > y, simd< float, L, Arch > x) noexcept
Definition exp_body.h:91
constexpr simd< float, L, Arch > exp2(simd< float, L, Arch > input) noexcept
Definition exp_body.h:65
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...
Definition exp_body.h:109
constexpr auto sincos(wide< R, N > const &input) noexcept([] { if constexpr(requires(std::array< R, N > const &x) { detail::wide_generic_detail::adl_sincos(x);}) return noexcept(detail::wide_generic_detail::adl_sincos(std::declval< std::array< R, N > const & >())) &&std::is_nothrow_move_constructible_v< std::array< R, N > >;else return noexcept(wide< R, N >()) &&std::is_nothrow_move_constructible_v< wide< R, N > > &&(N==0||(noexcept(detail::wide_generic_detail::adl_sincos(std::declval< R const & >())) &&noexcept(std::declval< R & >()=std::declval< decltype(detail::wide_generic_detail::adl_sincos(std::declval< R const & >())) & >().first) &&noexcept(std::declval< R & >()=std::declval< decltype(detail::wide_generic_detail::adl_sincos(std::declval< R const & >())) & >().second)));}())
Definition wide.h:1263
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 & >())));}())
Definition wide.h:1024
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 & >())));}())
Definition wide.h:1193
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 & >())));}())
Definition wide.h:1003
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 & >())));}())
Definition wide.h:1130
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 & >())));}())
Definition wide.h:1151
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 & >())));}())
Definition wide.h:1109
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 & >())));}())
Definition wide.h:1088
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 & >())));}())
Definition wide.h:1172
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...
Omitted architecture arguments use the native.simd provider's baseline.