native 0.0.1
Vectors, masks and wide register packs for C++26
Loading...
Searching...
No Matches
wide.h
1// SPDX-FileCopyrightText: 2026 Edward Kmett <ekmett@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
3#pragma once
4// The module supplies these dependencies in its global fragment.
5#ifndef NATIVE_WIDE_MODULE
6#include <hint.h>
7#include "native/isa.h"
8#include "native/value_traits.h"
9#include "native/wide_pack.h"
10
11#include <array>
12#include <concepts>
13#include <cmath>
14#include <cstddef>
15#include <functional>
16#include <tuple>
17#include <type_traits>
18#include <utility>
19#endif
20
21namespace native {
22 template<class T, std::size_t N> struct wide;
23 namespace detail {
24 template<class T> struct wide_traits {
25 using element_type = T;
26 static constexpr bool value = false;
27 static constexpr std::size_t size = 0;
28 };
29 template<class T, std::size_t N> struct wide_traits<wide<T, N>> {
30 using element_type = T;
31 static constexpr bool value = true;
32 static constexpr std::size_t size = N;
33 };
34 }
35
36 namespace detail {
37 template<class T, class = void> struct wide_features {
38 static constexpr isa<> value=scalar;
39 };
40 template<class T> struct wide_features<T,std::void_t<decltype(T::architecture)>> {
41 static constexpr isa<> value=value_architecture_v<T>;
42 };
43 template<class T,std::size_t N> struct wide_features<wide<T,N>> : wide_features<T> {};
44 template<class T,std::size_t N> struct wide_features<std::array<T,N>> : wide_features<T> {};
45 template<class T,class U> struct wide_features<std::pair<T,U>> {
46 static constexpr isa<> value=wide_features<std::remove_cvref_t<T>>::value &
47 wide_features<std::remove_cvref_t<U>>::value;
48 };
49 // Only operands with a SIMD architecture participate. Scalar/custom values
50 // retain the generic ADL path. Arrays and nested packs contribute their
51 // element features; mixed conversions use the union of both endpoints.
52 template<class... T> inline constexpr auto wide_target=[] {
53 constexpr isa<> bits=(scalar & ... & wide_features<std::remove_cvref_t<T>>::value);
54 constexpr auto index=abi_lookup<bits,wide_kernel_policies>::index;
55 static_assert(index>=0,"wide operands require an available host declaration scope");
56 return host_kernel_profiles::indices[index];
57 }();
58 template<class T> inline constexpr bool wide_equivalent_default=
59 value_traits<std::remove_cv_t<T>>::aggregate_default;
60 // MSVC's array can own a T with an attributed nontrivial constructor,
61 // including a dummy element at N == 0.
62 // Aggregate-initialize that storage in T's target scope, bypassing the
63 // library's unattributed implicit array constructor. Leave trivial/deleted
64 // defaults on the original defaulted path. Nonempty packs opt in only when
65 // their concrete element guarantees equivalent default/value initialization.
66 template<class T,std::size_t N> inline constexpr bool wide_target_default =
67 (N == 0 || wide_equivalent_default<T>) && std::is_default_constructible_v<T> &&
68 !std::is_trivially_default_constructible_v<T> &&
69 std::is_default_constructible_v<std::array<T,N>> &&
70 !std::is_trivially_default_constructible_v<std::array<T,N>>;
71 }
85 template<class T, std::size_t N>
86 struct wide {
87 // Packed library aggregates can underalign arrays of native mask types.
88 alignas(T) std::array<T, N> registers;
89
91 constexpr wide() requires (!detail::wide_target_default<T,N>) = default;
93 template<std::size_t I> requires (I < N)
94 [[nodiscard]] hint_inline constexpr T & get() & noexcept hint_lifetimebound { return registers[I]; }
96 template<std::size_t I> requires (I < N)
97 [[nodiscard]] hint_inline constexpr T const & get() const & noexcept hint_lifetimebound { return registers[I]; }
99 template<std::size_t I> requires (I < N)
100 [[nodiscard]] hint_inline constexpr T && get() && noexcept hint_lifetimebound { return std::move(registers[I]); }
102 template<std::size_t I> requires (I < N)
103 [[nodiscard]] hint_inline constexpr T const && get() const && noexcept hint_lifetimebound { return std::move(registers[I]); }
104
105 private:
106 struct conversion_tag {};
107#define NATIVE_WIDE_INDEX 15
108#define NATIVE_WIDE_DETAIL detail::wide_generic_detail
109#define NATIVE_WIDE_TARGET
110// SPDX-FileCopyrightText: 2026 Edward Kmett <ekmett@gmail.com>
111// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
112// Intentionally repeatable under one target family.
113 public:
115 NATIVE_WIDE_TARGET hint_inline constexpr wide()
116 noexcept(std::is_nothrow_default_constructible_v<std::array<T,N>>)
117 requires (detail::wide_target<T> == NATIVE_WIDE_INDEX) && detail::wide_target_default<T,N>
118 : registers{} {}
119
120 NATIVE_WIDE_TARGET hint_inline constexpr wide(std::array<T, N> values)
121 noexcept(std::is_nothrow_move_constructible_v<std::array<T, N>>)
122 requires (detail::wide_target<T> == NATIVE_WIDE_INDEX)
123 : registers(std::move(values)) {}
124
125 template<class... U> requires (detail::wide_target<T,U...> == NATIVE_WIDE_INDEX) && (sizeof...(U) == N && N != 0) &&
126 (std::constructible_from<T,U &&> && ...) &&
127 (N != 1 || ((!detail::wide_traits<std::remove_cvref_t<U>>::value &&
128 !std::same_as<std::remove_cvref_t<U>,std::array<T,N>>) && ...))
129 explicit(N == 1) NATIVE_WIDE_TARGET hint_inline constexpr wide(U &&... values)
130 noexcept((std::is_nothrow_constructible_v<T,U &&> && ...))
131 : registers{T(std::forward<U>(values))...} {}
132
133 template<class U> requires (detail::wide_target<T,U> == NATIVE_WIDE_INDEX) && (N != 1) && (!detail::wide_traits<std::remove_cvref_t<U>>::value) &&
134 (!std::same_as<std::remove_cvref_t<U>,std::array<T, N>>) &&
135 std::constructible_from<T,U const &> && (N == 0 || std::copy_constructible<T>)
136 explicit NATIVE_WIDE_TARGET hint_inline constexpr wide(U const & value)
137 noexcept(std::is_nothrow_constructible_v<T,U const &> &&
138 (N == 0 || std::is_nothrow_copy_constructible_v<T>))
139 : wide(T(value), std::make_index_sequence<N>{}) {}
140
142 template<class U> requires (detail::wide_target<T,U> == NATIVE_WIDE_INDEX) && (!std::same_as<T,U>) && std::constructible_from<T,U const &>
143 explicit(!std::is_convertible_v<U const &,T>) NATIVE_WIDE_TARGET hint_inline constexpr wide(wide<U,N> const & source)
144 noexcept(N == 0 || std::is_nothrow_constructible_v<T,U const &>)
145 : wide(conversion_tag{}, source, std::make_index_sequence<N>{}) {}
146
147 template<class U> requires (detail::wide_target<T,U> == NATIVE_WIDE_INDEX) && (!std::same_as<T,U>) && std::constructible_from<T,U &&>
148 explicit(!std::is_convertible_v<U &&,T>) NATIVE_WIDE_TARGET hint_inline constexpr wide(wide<U,N> && source)
149 noexcept(N == 0 || std::is_nothrow_constructible_v<T,U &&>)
150 : wide(conversion_tag{}, std::move(source), std::make_index_sequence<N>{}) {}
151
153 [[nodiscard]] static NATIVE_WIDE_TARGET hint_inline constexpr wide broadcast(T const & value)
154 noexcept(N == 0 || std::is_nothrow_copy_constructible_v<T>)
155 requires (detail::wide_target<T> == NATIVE_WIDE_INDEX) && (N == 0 || std::copy_constructible<T>) {
156 return wide(value, std::make_index_sequence<N>{});
157 }
158
160 template<class F> requires (detail::wide_target<T> == NATIVE_WIDE_INDEX)
161 NATIVE_WIDE_TARGET hint_inline constexpr decltype(auto) apply(F && f) noexcept(noexcept(std::apply(std::forward<F>(f), registers))) {
162 return apply_indices(std::forward<F>(f), registers, std::make_index_sequence<N>{});
163 }
164
166 template<class F> requires (detail::wide_target<T> == NATIVE_WIDE_INDEX)
167 NATIVE_WIDE_TARGET hint_inline constexpr decltype(auto) apply(F && f) const noexcept(noexcept(std::apply(std::forward<F>(f), registers))) {
168 return apply_indices(std::forward<F>(f), registers, std::make_index_sequence<N>{});
169 }
170 private:
171 template<class W, std::size_t... I> requires (detail::wide_target<T,W> == NATIVE_WIDE_INDEX)
172 NATIVE_WIDE_TARGET hint_inline constexpr wide(conversion_tag, W && source, std::index_sequence<I...>)
173 noexcept((std::is_nothrow_constructible_v<T,
174 decltype(std::get<I>(std::forward<W>(source).registers))> && ...))
175 : registers{T(std::get<I>(std::forward<W>(source).registers))...} {}
176 template<class U, std::size_t... I> requires (detail::wide_target<T> == NATIVE_WIDE_INDEX) && std::same_as<std::remove_cvref_t<U>,T>
177 NATIVE_WIDE_TARGET hint_inline constexpr wide(U && value, std::index_sequence<I...>)
178 noexcept(N == 0 || std::is_nothrow_copy_constructible_v<T>)
179 : registers{((void)I,static_cast<T const &>(value))...} {}
180 // Keep the callable on the force-inline path. MSVC can outline std::invoke
181 // inside std::apply even when both the caller and functor are force-inline.
182 template<class F, class A, std::size_t ... I> requires (detail::wide_target<A> == NATIVE_WIDE_INDEX)
183 static NATIVE_WIDE_TARGET hint_inline constexpr decltype(auto) apply_indices(F && f, A & a, std::index_sequence<I...>) {
184 if constexpr (std::is_member_pointer_v<std::remove_reference_t<F>>)
185 return std::invoke(std::forward<F>(f), std::get<I>(a)...);
186 else
187 return std::forward<F>(f)(std::get<I>(a)...);
188 }
189
190#undef NATIVE_WIDE_TARGET
191#undef NATIVE_WIDE_DETAIL
192#undef NATIVE_WIDE_INDEX
193
194#if defined(__x86_64__) || defined(_M_X64)
195#define NATIVE_WIDE_INDEX 10
196#define NATIVE_WIDE_DETAIL detail::wide_avx2_detail
197#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_1)
198
199#undef NATIVE_WIDE_TARGET
200#undef NATIVE_WIDE_DETAIL
201#undef NATIVE_WIDE_INDEX
202#endif
203
204#if defined(__x86_64__) || defined(_M_X64)
205#define NATIVE_WIDE_INDEX 9
206#define NATIVE_WIDE_DETAIL detail::wide_avx512_base_detail
207#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_2)
208
209#undef NATIVE_WIDE_TARGET
210#undef NATIVE_WIDE_DETAIL
211#undef NATIVE_WIDE_INDEX
212#endif
213
214#if defined(__x86_64__) || defined(_M_X64)
215#define NATIVE_WIDE_INDEX 7
216#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_detail
217#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_3)
218
219#undef NATIVE_WIDE_TARGET
220#undef NATIVE_WIDE_DETAIL
221#undef NATIVE_WIDE_INDEX
222#endif
223
224#if defined(__x86_64__) || defined(_M_X64)
225#define NATIVE_WIDE_INDEX 8
226#define NATIVE_WIDE_DETAIL detail::wide_avx512_vl_detail
227#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_4)
228
229#undef NATIVE_WIDE_TARGET
230#undef NATIVE_WIDE_DETAIL
231#undef NATIVE_WIDE_INDEX
232#endif
233
234#if defined(__x86_64__) || defined(_M_X64)
235#define NATIVE_WIDE_INDEX 3
236#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_vl_detail
237#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_5)
238
239#undef NATIVE_WIDE_TARGET
240#undef NATIVE_WIDE_DETAIL
241#undef NATIVE_WIDE_INDEX
242#endif
243
244#if defined(__x86_64__) || defined(_M_X64)
245#define NATIVE_WIDE_INDEX 5
246#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_bf16_detail
247#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_7)
248
249#undef NATIVE_WIDE_TARGET
250#undef NATIVE_WIDE_DETAIL
251#undef NATIVE_WIDE_INDEX
252#endif
253
254#if defined(__x86_64__) || defined(_M_X64)
255#define NATIVE_WIDE_INDEX 1
256#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_vl_bf16_detail
257#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_9)
258
259#undef NATIVE_WIDE_TARGET
260#undef NATIVE_WIDE_DETAIL
261#undef NATIVE_WIDE_INDEX
262#endif
263
264#if defined(__x86_64__) || defined(_M_X64)
265#define NATIVE_WIDE_INDEX 6
266#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_fp16_detail
267#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_11)
268
269#undef NATIVE_WIDE_TARGET
270#undef NATIVE_WIDE_DETAIL
271#undef NATIVE_WIDE_INDEX
272#endif
273
274#if defined(__x86_64__) || defined(_M_X64)
275#define NATIVE_WIDE_INDEX 2
276#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_vl_fp16_detail
277#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_13)
278
279#undef NATIVE_WIDE_TARGET
280#undef NATIVE_WIDE_DETAIL
281#undef NATIVE_WIDE_INDEX
282#endif
283
284#if defined(__x86_64__) || defined(_M_X64)
285#define NATIVE_WIDE_INDEX 4
286#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_bf16_fp16_detail
287#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_15)
288
289#undef NATIVE_WIDE_TARGET
290#undef NATIVE_WIDE_DETAIL
291#undef NATIVE_WIDE_INDEX
292#endif
293
294#if defined(__x86_64__) || defined(_M_X64)
295#define NATIVE_WIDE_INDEX 0
296#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_vl_bf16_fp16_detail
297#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_17)
298
299#undef NATIVE_WIDE_TARGET
300#undef NATIVE_WIDE_DETAIL
301#undef NATIVE_WIDE_INDEX
302#endif
303
304#if defined(__aarch64__) || defined(_M_ARM64)
305#define NATIVE_WIDE_INDEX 14
306#define NATIVE_WIDE_DETAIL detail::wide_neon_detail
307#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_20)
308
309#undef NATIVE_WIDE_TARGET
310#undef NATIVE_WIDE_DETAIL
311#undef NATIVE_WIDE_INDEX
312#endif
313
314#if defined(__aarch64__) || defined(_M_ARM64)
315#define NATIVE_WIDE_INDEX 12
316#define NATIVE_WIDE_DETAIL detail::wide_neon_bf16_detail
317#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_21)
318
319#undef NATIVE_WIDE_TARGET
320#undef NATIVE_WIDE_DETAIL
321#undef NATIVE_WIDE_INDEX
322#endif
323
324#if defined(__aarch64__) || defined(_M_ARM64)
325#define NATIVE_WIDE_INDEX 13
326#define NATIVE_WIDE_DETAIL detail::wide_neon_fp16_detail
327#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_22)
328
329#undef NATIVE_WIDE_TARGET
330#undef NATIVE_WIDE_DETAIL
331#undef NATIVE_WIDE_INDEX
332#endif
333
334#if defined(__aarch64__) || defined(_M_ARM64)
335#define NATIVE_WIDE_INDEX 11
336#define NATIVE_WIDE_DETAIL detail::wide_neon_half_detail
337#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_23)
338
339#undef NATIVE_WIDE_TARGET
340#undef NATIVE_WIDE_DETAIL
341#undef NATIVE_WIDE_INDEX
342#endif
343
344#if NATIVE_HOST_WASM
345#define NATIVE_WIDE_INDEX 16
346#define NATIVE_WIDE_DETAIL detail::wide_wasm_detail
347#define NATIVE_WIDE_TARGET hint_target(NATIVE_KERNEL_TARGET_WASM)
348
349#undef NATIVE_WIDE_TARGET
350#undef NATIVE_WIDE_DETAIL
351#undef NATIVE_WIDE_INDEX
352#endif
353
354 };
355
356 template<class T, class... U> requires (std::same_as<T,U> && ...)
357 wide(T,U...) -> wide<T,1 + sizeof...(U)>;
358
359#define NATIVE_WIDE_INDEX 15
360#define NATIVE_WIDE_DETAIL detail::wide_generic_detail
361// SPDX-FileCopyrightText: 2026 Edward Kmett <ekmett@gmail.com>
362// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
363// Intentionally repeatable; each family owns its force-inline ADL helpers.
364 namespace NATIVE_WIDE_DETAIL {
365 using namespace ::native::detail;
366 template<class T> using wide_element_t = typename wide_traits<T>::element_type;
367 template<class A, class B> concept wide_arguments =
368 (wide_traits<A>::value || wide_traits<B>::value) &&
369 (!wide_traits<A>::value || !wide_traits<B>::value || wide_traits<A>::size == wide_traits<B>::size);
370 template<class A, class B> inline constexpr std::size_t wide_size =
371 wide_traits<A>::value ? wide_traits<A>::size : wide_traits<B>::size;
372
373 template<std::size_t I, class T>
374 hint_inline constexpr decltype(auto) wide_element(T const & value) {
375 if constexpr (wide_traits<T>::value) return value.registers[I];
376 else return (value);
377 }
378 template<class A, class B, class F, std::size_t... I>
379 hint_inline constexpr auto wide_binary(A const & a, B const & b, F f, std::index_sequence<I...>) {
380 using R = std::remove_cvref_t<decltype(f(std::declval<wide_element_t<A> const &>(),
381 std::declval<wide_element_t<B> const &>()))>;
382 return wide<R, sizeof...(I)>{{f(wide_element<I>(a), wide_element<I>(b))...}};
383 }
384 template<class T, std::size_t N, class F, std::size_t... I>
385 hint_inline constexpr auto wide_unary(wide<T, N> const & a, F f, std::index_sequence<I...>) {
386 using R = std::remove_cvref_t<decltype(f(std::declval<T const &>()))>;
387 return wide<R, N>{{f(a.registers[I])...}};
388 }
389 template<class T, std::size_t N, class B, class F, std::size_t... I>
390 hint_inline constexpr wide<T, N> & wide_mutate(wide<T, N> & a, B const & b, F f, std::index_sequence<I...>) {
391 if constexpr (wide_traits<B>::value) (f(a.registers[I], b.registers[I]), ...);
392 else if constexpr (N != 0) {
393 // A broadcast can alias a destination register. Snapshot it before
394 // publishing any lane, just as a register broadcast takes a value.
395 auto value = b;
396 (f(a.registers[I], value), ...);
397 }
398 return a;
399 }
400 }
401
402 namespace NATIVE_WIDE_DETAIL {
403 using namespace ::native::detail;
404 template<class A> hint_inline constexpr decltype(auto) wide_storage(A const & a) noexcept {
405 if constexpr (wide_traits<A>::value) return (a.registers);
406 else return (a);
407 }
408 struct wide_add {
409 template<class A,class B> hint_inline constexpr auto operator()(A const & a,B const & b) const
410 noexcept(noexcept(a + b)) -> decltype(a + b) { return a + b; }
411 template<class A,class B> hint_inline constexpr auto batch(A const & a,B const & b) const
412 noexcept(noexcept(add(a,b))) -> decltype(add(a,b)) { return add(a,b); }
413 };
414 struct wide_sub {
415 template<class A,class B> hint_inline constexpr auto operator()(A const & a,B const & b) const
416 noexcept(noexcept(a - b)) -> decltype(a - b) { return a - b; }
417 template<class A,class B> hint_inline constexpr auto batch(A const & a,B const & b) const
418 noexcept(noexcept(sub(a,b))) -> decltype(sub(a,b)) { return sub(a,b); }
419 };
420 struct wide_mul {
421 template<class A,class B> hint_inline constexpr auto operator()(A const & a,B const & b) const
422 noexcept(noexcept(a * b)) -> decltype(a * b) { return a * b; }
423 template<class A,class B> hint_inline constexpr auto batch(A const & a,B const & b) const
424 noexcept(noexcept(mul(a,b))) -> decltype(mul(a,b)) { return mul(a,b); }
425 };
426 template<class A,class B,class F> concept wide_batch = requires(A const & a,B const & b) {
427 wide{F{}.batch(wide_storage(a),wide_storage(b))};
428 };
429 template<class A,class B,class F> concept wide_batch_assignable = wide_batch<A,B,F> &&
430 requires(A & a,B const & b) { a = wide{F{}.batch(wide_storage(a),wide_storage(b))}; };
431 template<class A,class B,class F>
432 hint_inline constexpr auto wide_dispatch(A const & a,B const & b,F f)
433 noexcept([] {
434 if constexpr (wide_batch<A,B,F>)
435 return noexcept(wide{F{}.batch(wide_storage(std::declval<A const &>()),wide_storage(std::declval<B const &>()))});
436 else return false;
437 }()) {
438 if constexpr (wide_batch<A,B,F>) return wide{f.batch(wide_storage(a),wide_storage(b))};
439 else return wide_binary(a,b,f,std::make_index_sequence<wide_size<A,B>>{});
440 }
441 }
442
443 // Reject non-pack operands before ISA routing: routing itself combines and
444 // compares ISA values whose ADL also sees these generic binary operators.
447 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
448 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a + b; }
449 [[nodiscard]] hint_inline constexpr auto operator+(A const & a, B const & b)
450 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_dispatch(a,b,NATIVE_WIDE_DETAIL::wide_add{}))) {
451 return NATIVE_WIDE_DETAIL::wide_dispatch(a,b,NATIVE_WIDE_DETAIL::wide_add{});
452 }
453
456 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
457 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a - b; }
458 [[nodiscard]] hint_inline constexpr auto operator-(A const & a, B const & b)
459 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_dispatch(a,b,NATIVE_WIDE_DETAIL::wide_sub{}))) {
460 return NATIVE_WIDE_DETAIL::wide_dispatch(a,b,NATIVE_WIDE_DETAIL::wide_sub{});
461 }
462
465 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
466 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a * b; }
467 [[nodiscard]] hint_inline constexpr auto operator*(A const & a, B const & b)
468 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_dispatch(a,b,NATIVE_WIDE_DETAIL::wide_mul{}))) {
469 return NATIVE_WIDE_DETAIL::wide_dispatch(a,b,NATIVE_WIDE_DETAIL::wide_mul{});
470 }
471
474 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
475 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a / b; }
476 [[nodiscard]] hint_inline constexpr auto operator/(A const & a, B const & b) {
477 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x / y) { return x / y; },
478 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
479 }
480
483 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
484 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a % b; }
485 [[nodiscard]] hint_inline constexpr auto operator%(A const & a, B const & b) {
486 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x % y) { return x % y; },
487 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
488 }
489
492 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
493 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a & b; }
494 [[nodiscard]] hint_inline constexpr auto operator&(A const & a, B const & b) {
495 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x & y) { return x & y; },
496 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
497 }
498
501 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
502 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a | b; }
503 [[nodiscard]] hint_inline constexpr auto operator|(A const & a, B const & b) {
504 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x | y) { return x | y; },
505 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
506 }
507
510 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
511 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a ^ b; }
512 [[nodiscard]] hint_inline constexpr auto operator^(A const & a, B const & b) {
513 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x ^ y) { return x ^ y; },
514 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
515 }
516
519 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
520 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a << b; }
521 [[nodiscard]] hint_inline constexpr auto operator<<(A const & a, B const & b) {
522 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x << y) { return x << y; },
523 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
524 }
525
528 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
529 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a >> b; }
530 [[nodiscard]] hint_inline constexpr auto operator>>(A const & a, B const & b) {
531 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x >> y) { return x >> y; },
532 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
533 }
534
537 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
538 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a == b; }
539 [[nodiscard]] hint_inline constexpr auto operator==(A const & a, B const & b) {
540 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x == y) { return x == y; },
541 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
542 }
543
546 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
547 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a != b; }
548 [[nodiscard]] hint_inline constexpr auto operator!=(A const & a, B const & b) {
549 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x != y) { return x != y; },
550 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
551 }
552
555 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
556 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a < b; }
557 [[nodiscard]] hint_inline constexpr auto operator<(A const & a, B const & b) {
558 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x < y) { return x < y; },
559 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
560 }
561
564 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
565 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a > b; }
566 [[nodiscard]] hint_inline constexpr auto operator>(A const & a, B const & b) {
567 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x > y) { return x > y; },
568 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
569 }
570
573 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
574 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a <= b; }
575 [[nodiscard]] hint_inline constexpr auto operator<=(A const & a, B const & b) {
576 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x <= y) { return x <= y; },
577 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
578 }
579
582 template<class A, class B> requires NATIVE_WIDE_DETAIL::wide_arguments<A, B> && (::native::detail::wide_target<A,B> == NATIVE_WIDE_INDEX) &&
583 requires(NATIVE_WIDE_DETAIL::wide_element_t<A> const & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a >= b; }
584 [[nodiscard]] hint_inline constexpr auto operator>=(A const & a, B const & b) {
585 return NATIVE_WIDE_DETAIL::wide_binary(a, b, [](auto const & x, auto const & y) -> decltype(x >= y) { return x >= y; },
586 std::make_index_sequence<NATIVE_WIDE_DETAIL::wide_size<A, B>>{});
587 }
588
591 template<class T, std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && requires(T const & a) { +a; }
592 [[nodiscard]] hint_inline constexpr auto operator+(wide<T, N> const & a) {
593 return NATIVE_WIDE_DETAIL::wide_unary(a, [](auto const & x) -> decltype(+x) { return +x; }, std::make_index_sequence<N>{});
594 }
595
598 template<class T, std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && requires(T const & a) { -a; }
599 [[nodiscard]] hint_inline constexpr auto operator-(wide<T, N> const & a) {
600 return NATIVE_WIDE_DETAIL::wide_unary(a, [](auto const & x) -> decltype(-x) { return -x; }, std::make_index_sequence<N>{});
601 }
602
605 template<class T, std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && requires(T const & a) { ~a; }
606 [[nodiscard]] hint_inline constexpr auto operator~(wide<T, N> const & a) {
607 return NATIVE_WIDE_DETAIL::wide_unary(a, [](auto const & x) -> decltype(~x) { return ~x; }, std::make_index_sequence<N>{});
608 }
609
612 template<class T, std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && requires(T const & a) { !a; }
613 [[nodiscard]] hint_inline constexpr auto operator!(wide<T, N> const & a) {
614 return NATIVE_WIDE_DETAIL::wide_unary(a, [](auto const & x) -> decltype(!x) { return !x; }, std::make_index_sequence<N>{});
615 }
616
619 template<class T, std::size_t N, class B> requires (::native::detail::wide_target<T,B> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_arguments<wide<T, N>, B> &&
620 (NATIVE_WIDE_DETAIL::wide_batch_assignable<wide<T,N>,B,NATIVE_WIDE_DETAIL::wide_add> ||
621 ((NATIVE_WIDE_DETAIL::wide_traits<B>::value || std::copy_constructible<B>) &&
622 requires(T & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a += b; })))
623 hint_inline constexpr wide<T, N> & operator+=(wide<T, N> & a, B const & b)
624 noexcept([] {
625 if constexpr (NATIVE_WIDE_DETAIL::wide_batch_assignable<wide<T,N>,B,NATIVE_WIDE_DETAIL::wide_add>)
626 return noexcept(std::declval<wide<T,N> &>() = NATIVE_WIDE_DETAIL::wide_dispatch(
627 std::declval<wide<T,N> const &>(),std::declval<B const &>(),NATIVE_WIDE_DETAIL::wide_add{}));
628 else return false;
629 }()) {
630 if constexpr (NATIVE_WIDE_DETAIL::wide_batch_assignable<wide<T,N>,B,NATIVE_WIDE_DETAIL::wide_add>)
631 return a = NATIVE_WIDE_DETAIL::wide_dispatch(a,b,NATIVE_WIDE_DETAIL::wide_add{});
632 else return NATIVE_WIDE_DETAIL::wide_mutate(a, b, [](auto & x, auto const & y) { x += y; }, std::make_index_sequence<N>{});
633 }
634
637 template<class T, std::size_t N, class B> requires (::native::detail::wide_target<T,B> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_arguments<wide<T, N>, B> &&
638 (NATIVE_WIDE_DETAIL::wide_batch_assignable<wide<T,N>,B,NATIVE_WIDE_DETAIL::wide_sub> ||
639 ((NATIVE_WIDE_DETAIL::wide_traits<B>::value || std::copy_constructible<B>) &&
640 requires(T & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a -= b; })))
641 hint_inline constexpr wide<T, N> & operator-=(wide<T, N> & a, B const & b)
642 noexcept([] {
643 if constexpr (NATIVE_WIDE_DETAIL::wide_batch_assignable<wide<T,N>,B,NATIVE_WIDE_DETAIL::wide_sub>)
644 return noexcept(std::declval<wide<T,N> &>() = NATIVE_WIDE_DETAIL::wide_dispatch(
645 std::declval<wide<T,N> const &>(),std::declval<B const &>(),NATIVE_WIDE_DETAIL::wide_sub{}));
646 else return false;
647 }()) {
648 if constexpr (NATIVE_WIDE_DETAIL::wide_batch_assignable<wide<T,N>,B,NATIVE_WIDE_DETAIL::wide_sub>)
649 return a = NATIVE_WIDE_DETAIL::wide_dispatch(a,b,NATIVE_WIDE_DETAIL::wide_sub{});
650 else return NATIVE_WIDE_DETAIL::wide_mutate(a, b, [](auto & x, auto const & y) { x -= y; }, std::make_index_sequence<N>{});
651 }
652
655 template<class T, std::size_t N, class B> requires (::native::detail::wide_target<T,B> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_arguments<wide<T, N>, B> &&
656 (NATIVE_WIDE_DETAIL::wide_batch_assignable<wide<T,N>,B,NATIVE_WIDE_DETAIL::wide_mul> ||
657 ((NATIVE_WIDE_DETAIL::wide_traits<B>::value || std::copy_constructible<B>) &&
658 requires(T & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a *= b; })))
659 hint_inline constexpr wide<T, N> & operator*=(wide<T, N> & a, B const & b)
660 noexcept([] {
661 if constexpr (NATIVE_WIDE_DETAIL::wide_batch_assignable<wide<T,N>,B,NATIVE_WIDE_DETAIL::wide_mul>)
662 return noexcept(std::declval<wide<T,N> &>() = NATIVE_WIDE_DETAIL::wide_dispatch(
663 std::declval<wide<T,N> const &>(),std::declval<B const &>(),NATIVE_WIDE_DETAIL::wide_mul{}));
664 else return false;
665 }()) {
666 if constexpr (NATIVE_WIDE_DETAIL::wide_batch_assignable<wide<T,N>,B,NATIVE_WIDE_DETAIL::wide_mul>)
667 return a = NATIVE_WIDE_DETAIL::wide_dispatch(a,b,NATIVE_WIDE_DETAIL::wide_mul{});
668 else return NATIVE_WIDE_DETAIL::wide_mutate(a, b, [](auto & x, auto const & y) { x *= y; }, std::make_index_sequence<N>{});
669 }
670
673 template<class T, std::size_t N, class B> requires (::native::detail::wide_target<T,B> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_arguments<wide<T, N>, B> &&
674 (NATIVE_WIDE_DETAIL::wide_traits<B>::value || std::copy_constructible<B>) &&
675 requires(T & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a /= b; }
676 hint_inline constexpr wide<T, N> & operator/=(wide<T, N> & a, B const & b) {
677 return NATIVE_WIDE_DETAIL::wide_mutate(a, b, [](auto & x, auto const & y) { x /= y; }, std::make_index_sequence<N>{});
678 }
679
682 template<class T, std::size_t N, class B> requires (::native::detail::wide_target<T,B> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_arguments<wide<T, N>, B> &&
683 (NATIVE_WIDE_DETAIL::wide_traits<B>::value || std::copy_constructible<B>) &&
684 requires(T & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a %= b; }
685 hint_inline constexpr wide<T, N> & operator%=(wide<T, N> & a, B const & b) {
686 return NATIVE_WIDE_DETAIL::wide_mutate(a, b, [](auto & x, auto const & y) { x %= y; }, std::make_index_sequence<N>{});
687 }
688
691 template<class T, std::size_t N, class B> requires (::native::detail::wide_target<T,B> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_arguments<wide<T, N>, B> &&
692 (NATIVE_WIDE_DETAIL::wide_traits<B>::value || std::copy_constructible<B>) &&
693 requires(T & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a &= b; }
694 hint_inline constexpr wide<T, N> & operator&=(wide<T, N> & a, B const & b) {
695 return NATIVE_WIDE_DETAIL::wide_mutate(a, b, [](auto & x, auto const & y) { x &= y; }, std::make_index_sequence<N>{});
696 }
697
700 template<class T, std::size_t N, class B> requires (::native::detail::wide_target<T,B> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_arguments<wide<T, N>, B> &&
701 (NATIVE_WIDE_DETAIL::wide_traits<B>::value || std::copy_constructible<B>) &&
702 requires(T & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a |= b; }
703 hint_inline constexpr wide<T, N> & operator|=(wide<T, N> & a, B const & b) {
704 return NATIVE_WIDE_DETAIL::wide_mutate(a, b, [](auto & x, auto const & y) { x |= y; }, std::make_index_sequence<N>{});
705 }
706
709 template<class T, std::size_t N, class B> requires (::native::detail::wide_target<T,B> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_arguments<wide<T, N>, B> &&
710 (NATIVE_WIDE_DETAIL::wide_traits<B>::value || std::copy_constructible<B>) &&
711 requires(T & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a ^= b; }
712 hint_inline constexpr wide<T, N> & operator^=(wide<T, N> & a, B const & b) {
713 return NATIVE_WIDE_DETAIL::wide_mutate(a, b, [](auto & x, auto const & y) { x ^= y; }, std::make_index_sequence<N>{});
714 }
715
718 template<class T, std::size_t N, class B> requires (::native::detail::wide_target<T,B> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_arguments<wide<T, N>, B> &&
719 (NATIVE_WIDE_DETAIL::wide_traits<B>::value || std::copy_constructible<B>) &&
720 requires(T & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a <<= b; }
721 hint_inline constexpr wide<T, N> & operator<<=(wide<T, N> & a, B const & b) {
722 return NATIVE_WIDE_DETAIL::wide_mutate(a, b, [](auto & x, auto const & y) { x <<= y; }, std::make_index_sequence<N>{});
723 }
724
727 template<class T, std::size_t N, class B> requires (::native::detail::wide_target<T,B> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_arguments<wide<T, N>, B> &&
728 (NATIVE_WIDE_DETAIL::wide_traits<B>::value || std::copy_constructible<B>) &&
729 requires(T & a, NATIVE_WIDE_DETAIL::wide_element_t<B> const & b) { a >>= b; }
730 hint_inline constexpr wide<T, N> & operator>>=(wide<T, N> & a, B const & b) {
731 return NATIVE_WIDE_DETAIL::wide_mutate(a, b, [](auto & x, auto const & y) { x >>= y; }, std::make_index_sequence<N>{});
732 }
733
734 namespace NATIVE_WIDE_DETAIL {
735 using namespace ::native::detail;
736 using std::abs;
737 using std::sqrt;
738 using std::fma;
739 using std::sin;
740 using std::cos;
741 using std::exp;
742 using std::exp2;
743 using std::expm1;
744 using std::log;
745 using std::log2;
746 using std::log1p;
747 using std::tanh;
748 using std::atan2;
749 template<class... A> hint_inline constexpr auto adl_abs(A const &... a)
750 noexcept(noexcept(abs(a...))) -> decltype(abs(a...)) { return abs(a...); }
751 template<class... A> hint_inline constexpr auto adl_sqrt(A const &... a)
752 noexcept(noexcept(sqrt(a...))) -> decltype(sqrt(a...)) { return sqrt(a...); }
753 template<class... A> hint_inline constexpr auto adl_fma(A const &... a)
754 noexcept(noexcept(fma(a...))) -> decltype(fma(a...)) { return fma(a...); }
755 template<class... A> hint_inline constexpr auto adl_sin(A const &... a)
756 noexcept(noexcept(sin(a...))) -> decltype(sin(a...)) { return sin(a...); }
757 template<class... A> hint_inline constexpr auto adl_cos(A const &... a)
758 noexcept(noexcept(cos(a...))) -> decltype(cos(a...)) { return cos(a...); }
759 template<class... A> hint_inline constexpr auto adl_expm1(A const &... a)
760 noexcept(noexcept(expm1(a...))) -> decltype(expm1(a...)) { return expm1(a...); }
761 template<class... A> hint_inline constexpr auto adl_damping_gain(A const &... a)
762 noexcept(noexcept(damping_gain(a...))) -> decltype(damping_gain(a...)) { return damping_gain(a...); }
763 template<class... A> hint_inline constexpr auto adl_log(A const &... a)
764 noexcept(noexcept(log(a...))) -> decltype(log(a...)) { return log(a...); }
765 template<class... A> hint_inline constexpr auto adl_log2(A const &... a)
766 noexcept(noexcept(log2(a...))) -> decltype(log2(a...)) { return log2(a...); }
767 template<class... A> hint_inline constexpr auto adl_log1p(A const &... a)
768 noexcept(noexcept(log1p(a...))) -> decltype(log1p(a...)) { return log1p(a...); }
769 template<class... A> hint_inline constexpr auto adl_atan2(A const &... a)
770 noexcept(noexcept(atan2(a...))) -> decltype(atan2(a...)) { return atan2(a...); }
771 template<class... A> hint_inline constexpr auto adl_tanh(A const &... a)
772 noexcept(noexcept(tanh(a...))) -> decltype(tanh(a...)) { return tanh(a...); }
773 template<bool Flush,unsigned Degree,class A>
774 requires requires(A const & a) { exp(a,std::bool_constant<Flush>{},std::integral_constant<unsigned,Degree>{}); }
775 hint_inline constexpr auto adl_exp(A const & a)
776 noexcept(noexcept(exp(a,std::bool_constant<Flush>{},std::integral_constant<unsigned,Degree>{})))
777 -> decltype(exp(a,std::bool_constant<Flush>{},std::integral_constant<unsigned,Degree>{})) {
778 return exp(a,std::bool_constant<Flush>{},std::integral_constant<unsigned,Degree>{});
779 }
780 template<bool Flush,unsigned Degree,class A>
781 requires (Degree == 6) &&
782 (!requires(A const & a) { exp(a,std::bool_constant<Flush>{},std::integral_constant<unsigned,Degree>{}); }) &&
783 requires(A const & a) { exp(a,std::bool_constant<Flush>{}); }
784 hint_inline constexpr auto adl_exp(A const & a)
785 noexcept(noexcept(exp(a,std::bool_constant<Flush>{}))) -> decltype(exp(a,std::bool_constant<Flush>{})) {
786 return exp(a,std::bool_constant<Flush>{});
787 }
788 template<bool Flush,unsigned Degree,class A>
789 requires (!Flush && Degree == 6) &&
790 (!requires(A const & a) { exp(a,std::bool_constant<Flush>{},std::integral_constant<unsigned,Degree>{}); }) &&
791 (!requires(A const & a) { exp(a,std::bool_constant<Flush>{}); })
792 hint_inline constexpr auto adl_exp(A const & a) noexcept(noexcept(exp(a))) -> decltype(exp(a)) { return exp(a); }
793 template<bool Flush,class A> requires requires(A const & a) { exp2(a,std::bool_constant<Flush>{}); }
794 hint_inline constexpr auto adl_exp2(A const & a) noexcept(noexcept(exp2(a,std::bool_constant<Flush>{}))) -> decltype(exp2(a,std::bool_constant<Flush>{})) { return exp2(a,std::bool_constant<Flush>{}); }
795 template<bool Flush,class A> requires (!Flush) && (!requires(A const & a) { exp2(a,std::bool_constant<Flush>{}); })
796 hint_inline constexpr auto adl_exp2(A const & a) noexcept(noexcept(exp2(a))) -> decltype(exp2(a)) { return exp2(a); }
797 template<class A> hint_inline constexpr auto adl_sincos(A const & a)
798 noexcept(noexcept(sincos(a))) -> decltype(sincos(a)) { return sincos(a); }
799 template<class M,class T> hint_inline constexpr auto adl_select(M const & m,T const & a,T const & b)
800 noexcept(noexcept(select(m,a,b))) -> decltype(select(m,a,b)) { return select(m,a,b); }
801 }
802 namespace NATIVE_WIDE_DETAIL {
803 using namespace ::native::detail;
804 // Restrict standard fallbacks: some STLs leave their templates unconstrained.
805 template<class T> requires std::is_arithmetic_v<T>
806 hint_inline constexpr auto isfinite(T const & x)
807 noexcept(noexcept(std::isfinite(x))) -> decltype(std::isfinite(x)) { return std::isfinite(x); }
808 template<class T> requires std::is_arithmetic_v<T>
809 hint_inline constexpr auto isinf(T const & x)
810 noexcept(noexcept(std::isinf(x))) -> decltype(std::isinf(x)) { return std::isinf(x); }
811 template<class T> requires std::is_arithmetic_v<T>
812 hint_inline constexpr auto isnan(T const & x)
813 noexcept(noexcept(std::isnan(x))) -> decltype(std::isnan(x)) { return std::isnan(x); }
814 template<class T> requires std::is_arithmetic_v<T>
815 hint_inline constexpr auto signbit(T const & x)
816 noexcept(noexcept(std::signbit(x))) -> decltype(std::signbit(x)) { return std::signbit(x); }
817 template<class T> requires std::is_arithmetic_v<T>
818 hint_inline constexpr auto copysign(T const & x,T const & y)
819 noexcept(noexcept(std::copysign(x,y))) -> decltype(std::copysign(x,y)) { return std::copysign(x,y); }
820 template<class T> requires std::is_floating_point_v<T>
821 hint_inline constexpr auto floor(T const & x)
822 noexcept(noexcept(std::floor(x))) -> decltype(std::floor(x)) { return std::floor(x); }
823 struct wide_floor {
824 template<class T> hint_inline constexpr auto operator()(T const & x) const
825 noexcept(noexcept(floor(x))) -> decltype(floor(x)) { return floor(x); }
826 };
827 template<class T> requires std::is_floating_point_v<T>
828 hint_inline constexpr auto ceil(T const & x)
829 noexcept(noexcept(std::ceil(x))) -> decltype(std::ceil(x)) { return std::ceil(x); }
830 struct wide_ceil {
831 template<class T> hint_inline constexpr auto operator()(T const & x) const
832 noexcept(noexcept(ceil(x))) -> decltype(ceil(x)) { return ceil(x); }
833 };
834 template<class T> requires std::is_floating_point_v<T>
835 hint_inline constexpr auto trunc(T const & x)
836 noexcept(noexcept(std::trunc(x))) -> decltype(std::trunc(x)) { return std::trunc(x); }
837 struct wide_trunc {
838 template<class T> hint_inline constexpr auto operator()(T const & x) const
839 noexcept(noexcept(trunc(x))) -> decltype(trunc(x)) { return trunc(x); }
840 };
841 struct wide_isfinite {
842 template<class... T> hint_inline constexpr auto operator()(T const &... x) const
843 noexcept(noexcept(isfinite(x...))) -> decltype(isfinite(x...)) { return isfinite(x...); }
844 };
845 struct wide_isinf {
846 template<class... T> hint_inline constexpr auto operator()(T const &... x) const
847 noexcept(noexcept(isinf(x...))) -> decltype(isinf(x...)) { return isinf(x...); }
848 };
849 struct wide_isnan {
850 template<class... T> hint_inline constexpr auto operator()(T const &... x) const
851 noexcept(noexcept(isnan(x...))) -> decltype(isnan(x...)) { return isnan(x...); }
852 };
853 struct wide_signbit {
854 template<class... T> hint_inline constexpr auto operator()(T const &... x) const
855 noexcept(noexcept(signbit(x...))) -> decltype(signbit(x...)) { return signbit(x...); }
856 };
857 struct wide_copysign {
858 template<class... T> hint_inline constexpr auto operator()(T const &... x) const
859 noexcept(noexcept(copysign(x...))) -> decltype(copysign(x...)) { return copysign(x...); }
860 };
861 template<class F,class... T>
862 using wide_result = std::remove_cvref_t<std::invoke_result_t<F,T const &...>>;
863 template<std::size_t N,class F,class... T> concept wide_value_operation =
864 std::invocable<F,T const &...> && std::is_object_v<wide_result<F,T...>> &&
865 std::is_move_constructible_v<std::array<wide_result<F,T...>,N>> &&
866 (N == 0 || requires(T const &... x) { std::array<wide_result<F,T...>,1>{F{}(x...)}; });
867
868 // Each lane is constructed directly from its ADL result; no default
869 // construction or assignment is required. The array then moves into wide.
870 template<class F,class T,std::size_t N> requires wide_value_operation<N,F,T>
871 hint_inline constexpr auto wide_map(wide<T,N> const & input)
872 noexcept([] {
873 if constexpr (N == 0) return true;
874 else return noexcept(wide<wide_result<F,T>,1>{
875 std::array<wide_result<F,T>,1>{F{}(std::declval<T const &>())}});
876 }()) {
877 auto const & [...x] = input;
878 return wide<wide_result<F,T>,N>{std::array<wide_result<F,T>,N>{F{}(x)...}};
879 }
880 template<class F,class T,std::size_t N> requires wide_value_operation<N,F,T,T>
881 hint_inline constexpr auto wide_map(wide<T,N> const & a,wide<T,N> const & b)
882 noexcept([] {
883 if constexpr (N == 0) return true;
884 else return noexcept(wide<wide_result<F,T,T>,1>{
885 std::array<wide_result<F,T,T>,1>{F{}(std::declval<T const &>(),std::declval<T const &>())}});
886 }()) {
887 auto const & [...x] = a;
888 auto const & [...y] = b;
889 return wide<wide_result<F,T,T>,N>{std::array<wide_result<F,T,T>,N>{F{}(x,y)...}};
890 }
891 }
895 template<class T,std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_value_operation<N,NATIVE_WIDE_DETAIL::wide_isfinite,T>
896 [[nodiscard]] hint_inline constexpr auto isfinite(wide<T,N> const & input)
897 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_isfinite>(input))) {
898 return NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_isfinite>(input);
899 }
900
902 template<class T,std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_value_operation<N,NATIVE_WIDE_DETAIL::wide_isinf,T>
903 [[nodiscard]] hint_inline constexpr auto isinf(wide<T,N> const & input)
904 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_isinf>(input))) {
905 return NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_isinf>(input);
906 }
907
909 template<class T,std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_value_operation<N,NATIVE_WIDE_DETAIL::wide_isnan,T>
910 [[nodiscard]] hint_inline constexpr auto isnan(wide<T,N> const & input)
911 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_isnan>(input))) {
912 return NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_isnan>(input);
913 }
914
916 template<class T,std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_value_operation<N,NATIVE_WIDE_DETAIL::wide_signbit,T>
917 [[nodiscard]] hint_inline constexpr auto signbit(wide<T,N> const & input)
918 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_signbit>(input))) {
919 return NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_signbit>(input);
920 }
921
924 template<class T,std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_value_operation<N,NATIVE_WIDE_DETAIL::wide_copysign,T,T> &&
925 std::same_as<NATIVE_WIDE_DETAIL::wide_result<NATIVE_WIDE_DETAIL::wide_copysign,T,T>,T>
926 [[nodiscard]] hint_inline constexpr wide<T,N> copysign(wide<T,N> const & a,wide<T,N> const & b)
927 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_copysign>(a,b))) {
928 return NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_copysign>(a,b);
929 }
930
933 template<class T,std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_value_operation<N,NATIVE_WIDE_DETAIL::wide_floor,T> &&
934 std::same_as<NATIVE_WIDE_DETAIL::wide_result<NATIVE_WIDE_DETAIL::wide_floor,T>,T>
935 [[nodiscard]] hint_inline constexpr wide<T,N> floor(wide<T,N> const & input)
936 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_floor>(input))) {
937 return NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_floor>(input);
938 }
939
941 template<class T,std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_value_operation<N,NATIVE_WIDE_DETAIL::wide_ceil,T> &&
942 std::same_as<NATIVE_WIDE_DETAIL::wide_result<NATIVE_WIDE_DETAIL::wide_ceil,T>,T>
943 [[nodiscard]] hint_inline constexpr wide<T,N> ceil(wide<T,N> const & input)
944 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_ceil>(input))) {
945 return NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_ceil>(input);
946 }
947
949 template<class T,std::size_t N> requires (::native::detail::wide_target<T> == NATIVE_WIDE_INDEX) && NATIVE_WIDE_DETAIL::wide_value_operation<N,NATIVE_WIDE_DETAIL::wide_trunc,T> &&
950 std::same_as<NATIVE_WIDE_DETAIL::wide_result<NATIVE_WIDE_DETAIL::wide_trunc,T>,T>
951 [[nodiscard]] hint_inline constexpr wide<T,N> trunc(wide<T,N> const & input)
952 noexcept(noexcept(NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_trunc>(input))) {
953 return NATIVE_WIDE_DETAIL::wide_map<NATIVE_WIDE_DETAIL::wide_trunc>(input);
954 }
955
957 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX)
958 [[nodiscard]] hint_inline constexpr wide<R,N> broadcast(R value) noexcept(noexcept(wide<R,N>::broadcast(value))) {
959 return wide<R,N>::broadcast(value);
960 }
961
963 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_abs(x); }
964 [[nodiscard]] hint_inline constexpr wide<R,N> abs(wide<R,N> const & input)
965 noexcept([] {
966 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_abs(a); })
967 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_abs(std::declval<std::array<R,N> const &>())});
968 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
969 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_abs(std::declval<R const &>())));
970 }()) {
971 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_abs(input.registers); })
972 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_abs(input.registers)};
973 else {
974 wide<R,N> result;
975 auto & [...value] = result;
976 auto const & [...x] = input;
977 ([&] { value = NATIVE_WIDE_DETAIL::adl_abs(x); }(), ...);
978 return result;
979 }
980 }
981
984 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_sqrt(x); }
985 [[nodiscard]] hint_inline constexpr wide<R,N> sqrt(wide<R,N> const & input)
986 noexcept([] {
987 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_sqrt(a); })
988 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_sqrt(std::declval<std::array<R,N> const &>())});
989 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
990 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_sqrt(std::declval<R const &>())));
991 }()) {
992 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_sqrt(input.registers); })
993 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_sqrt(input.registers)};
994 else {
995 wide<R,N> result;
996 auto & [...value] = result;
997 auto const & [...x] = input;
998 ([&] { value = NATIVE_WIDE_DETAIL::adl_sqrt(x); }(), ...);
999 return result;
1000 }
1001 }
1002
1005 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_sin(x); }
1006 [[nodiscard]] hint_inline constexpr wide<R,N> sin(wide<R,N> const & input)
1007 noexcept([] {
1008 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_sin(a); })
1009 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_sin(std::declval<std::array<R,N> const &>())});
1010 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1011 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_sin(std::declval<R const &>())));
1012 }()) {
1013 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_sin(input.registers); })
1014 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_sin(input.registers)};
1015 else {
1016 wide<R,N> result;
1017 auto & [...value] = result;
1018 auto const & [...x] = input;
1019 ([&] { value = NATIVE_WIDE_DETAIL::adl_sin(x); }(), ...);
1020 return result;
1021 }
1022 }
1023
1026 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_cos(x); }
1027 [[nodiscard]] hint_inline constexpr wide<R,N> cos(wide<R,N> const & input)
1028 noexcept([] {
1029 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_cos(a); })
1030 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_cos(std::declval<std::array<R,N> const &>())});
1031 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1032 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_cos(std::declval<R const &>())));
1033 }()) {
1034 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_cos(input.registers); })
1035 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_cos(input.registers)};
1036 else {
1037 wide<R,N> result;
1038 auto & [...value] = result;
1039 auto const & [...x] = input;
1040 ([&] { value = NATIVE_WIDE_DETAIL::adl_cos(x); }(), ...);
1041 return result;
1042 }
1043 }
1044
1048 template<bool Flush = false,unsigned Degree = 6,class R,std::size_t N> requires (Degree >= 1 && Degree <= 7) && (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_exp<Flush,Degree>(x); }
1049 [[nodiscard]] hint_inline constexpr wide<R,N> exp(wide<R,N> const & input)
1050 noexcept([] {
1051 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_exp<Flush,Degree>(a); })
1052 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_exp<Flush,Degree>(std::declval<std::array<R,N> const &>())});
1053 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1054 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_exp<Flush,Degree>(std::declval<R const &>())));
1055 }()) {
1056 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_exp<Flush,Degree>(input.registers); })
1057 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_exp<Flush,Degree>(input.registers)};
1058 else {
1059 wide<R,N> result;
1060 auto & [...value] = result;
1061 auto const & [...x] = input;
1062 ([&] { value = NATIVE_WIDE_DETAIL::adl_exp<Flush,Degree>(x); }(), ...);
1063 return result;
1064 }
1065 }
1066
1069 template<bool Flush = false,class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_exp2<Flush>(x); }
1070 [[nodiscard]] hint_inline constexpr wide<R,N> exp2(wide<R,N> const & input)
1071 noexcept([] {
1072 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_exp2<Flush>(a); })
1073 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_exp2<Flush>(std::declval<std::array<R,N> const &>())});
1074 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1075 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_exp2<Flush>(std::declval<R const &>())));
1076 }()) {
1077 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_exp2<Flush>(input.registers); })
1078 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_exp2<Flush>(input.registers)};
1079 else {
1080 wide<R,N> result;
1081 auto & [...value] = result;
1082 auto const & [...x] = input;
1083 ([&] { value = NATIVE_WIDE_DETAIL::adl_exp2<Flush>(x); }(), ...);
1084 return result;
1085 }
1086 }
1087
1090 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_expm1(x); }
1091 [[nodiscard]] hint_inline constexpr wide<R,N> expm1(wide<R,N> const & input)
1092 noexcept([] {
1093 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_expm1(a); })
1094 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_expm1(std::declval<std::array<R,N> const &>())});
1095 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1096 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_expm1(std::declval<R const &>())));
1097 }()) {
1098 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_expm1(input.registers); })
1099 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_expm1(input.registers)};
1100 else {
1101 wide<R,N> result;
1102 auto & [...value] = result;
1103 auto const & [...x] = input;
1104 ([&] { value = NATIVE_WIDE_DETAIL::adl_expm1(x); }(), ...);
1105 return result;
1106 }
1107 }
1108
1111 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_damping_gain(x); }
1112 [[nodiscard]] hint_inline constexpr wide<R,N> damping_gain(wide<R,N> const & input)
1113 noexcept([] {
1114 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_damping_gain(a); })
1115 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_damping_gain(std::declval<std::array<R,N> const &>())});
1116 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1117 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_damping_gain(std::declval<R const &>())));
1118 }()) {
1119 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_damping_gain(input.registers); })
1120 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_damping_gain(input.registers)};
1121 else {
1122 wide<R,N> result;
1123 auto & [...value] = result;
1124 auto const & [...x] = input;
1125 ([&] { value = NATIVE_WIDE_DETAIL::adl_damping_gain(x); }(), ...);
1126 return result;
1127 }
1128 }
1129
1132 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_log(x); }
1133 [[nodiscard]] hint_inline constexpr wide<R,N> log(wide<R,N> const & input)
1134 noexcept([] {
1135 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_log(a); })
1136 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_log(std::declval<std::array<R,N> const &>())});
1137 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1138 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_log(std::declval<R const &>())));
1139 }()) {
1140 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_log(input.registers); })
1141 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_log(input.registers)};
1142 else {
1143 wide<R,N> result;
1144 auto & [...value] = result;
1145 auto const & [...x] = input;
1146 ([&] { value = NATIVE_WIDE_DETAIL::adl_log(x); }(), ...);
1147 return result;
1148 }
1149 }
1150
1153 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_log2(x); }
1154 [[nodiscard]] hint_inline constexpr wide<R,N> log2(wide<R,N> const & input)
1155 noexcept([] {
1156 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_log2(a); })
1157 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_log2(std::declval<std::array<R,N> const &>())});
1158 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1159 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_log2(std::declval<R const &>())));
1160 }()) {
1161 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_log2(input.registers); })
1162 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_log2(input.registers)};
1163 else {
1164 wide<R,N> result;
1165 auto & [...value] = result;
1166 auto const & [...x] = input;
1167 ([&] { value = NATIVE_WIDE_DETAIL::adl_log2(x); }(), ...);
1168 return result;
1169 }
1170 }
1171
1174 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_log1p(x); }
1175 [[nodiscard]] hint_inline constexpr wide<R,N> log1p(wide<R,N> const & input)
1176 noexcept([] {
1177 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_log1p(a); })
1178 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_log1p(std::declval<std::array<R,N> const &>())});
1179 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1180 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_log1p(std::declval<R const &>())));
1181 }()) {
1182 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_log1p(input.registers); })
1183 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_log1p(input.registers)};
1184 else {
1185 wide<R,N> result;
1186 auto & [...value] = result;
1187 auto const & [...x] = input;
1188 ([&] { value = NATIVE_WIDE_DETAIL::adl_log1p(x); }(), ...);
1189 return result;
1190 }
1191 }
1192
1195 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_tanh(x); }
1196 [[nodiscard]] hint_inline constexpr wide<R,N> tanh(wide<R,N> const & input)
1197 noexcept([] {
1198 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_tanh(a); })
1199 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_tanh(std::declval<std::array<R,N> const &>())});
1200 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1201 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_tanh(std::declval<R const &>())));
1202 }()) {
1203 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_tanh(input.registers); })
1204 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_tanh(input.registers)};
1205 else {
1206 wide<R,N> result;
1207 auto & [...value] = result;
1208 auto const & [...x] = input;
1209 ([&] { value = NATIVE_WIDE_DETAIL::adl_tanh(x); }(), ...);
1210 return result;
1211 }
1212 }
1213
1216 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_atan2(x,x); }
1217 [[nodiscard]] hint_inline constexpr wide<R,N> atan2(wide<R,N> const & y,wide<R,N> const & x)
1218 noexcept([] {
1219 if constexpr (requires(std::array<R,N> const & a) { NATIVE_WIDE_DETAIL::adl_atan2(a,a); })
1220 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_atan2(std::declval<std::array<R,N> const &>(),
1221 std::declval<std::array<R,N> const &>())});
1222 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1223 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_atan2(
1224 std::declval<R const &>(),std::declval<R const &>())));
1225 }()) {
1226 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_atan2(y.registers,x.registers); })
1227 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_atan2(y.registers,x.registers)};
1228 else {
1229 wide<R,N> result;
1230 auto & [...value] = result;
1231 auto const & [...a] = y;
1232 auto const & [...b] = x;
1233 ([&] { value = NATIVE_WIDE_DETAIL::adl_atan2(a,b); }(), ...);
1234 return result;
1235 }
1236 }
1237
1240 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_fma(x,x,x); }
1241 [[nodiscard]] hint_inline constexpr wide<R,N> fma(wide<R,N> const & a,wide<R,N> const & b,wide<R,N> const & c)
1242 noexcept([] {
1243 if constexpr (requires(std::array<R,N> const & x) { NATIVE_WIDE_DETAIL::adl_fma(x,x,x); })
1244 return noexcept(wide<R,N>{NATIVE_WIDE_DETAIL::adl_fma(std::declval<std::array<R,N> const &>(),
1245 std::declval<std::array<R,N> const &>(),std::declval<std::array<R,N> const &>())});
1246 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1247 (N == 0 || noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_fma(
1248 std::declval<R const &>(),std::declval<R const &>(),std::declval<R const &>())));
1249 }()) {
1250 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_fma(a.registers,b.registers,c.registers); })
1251 return wide<R,N>{NATIVE_WIDE_DETAIL::adl_fma(a.registers,b.registers,c.registers)};
1252 else {
1253 wide<R,N> result;
1254 auto & [...value] = result;
1255 auto const & [...x] = a;
1256 auto const & [...y] = b;
1257 auto const & [...z] = c;
1258 ([&] { value = NATIVE_WIDE_DETAIL::adl_fma(x,y,z); }(), ...);
1259 return result;
1260 }
1261 }
1262
1265 template<class R,std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX) && requires(R const & x) { NATIVE_WIDE_DETAIL::adl_sincos(x); }
1266 [[nodiscard]] hint_inline constexpr auto sincos(wide<R,N> const & input)
1267 noexcept([] {
1268 if constexpr (requires(std::array<R,N> const & x) { NATIVE_WIDE_DETAIL::adl_sincos(x); })
1269 return noexcept(NATIVE_WIDE_DETAIL::adl_sincos(std::declval<std::array<R,N> const &>())) &&
1270 std::is_nothrow_move_constructible_v<std::array<R,N>>;
1271 else return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1272 (N == 0 || (noexcept(NATIVE_WIDE_DETAIL::adl_sincos(std::declval<R const &>())) && noexcept(std::declval<R &>() = std::declval<decltype(NATIVE_WIDE_DETAIL::adl_sincos(std::declval<R const &>())) &>().first) &&
1273 noexcept(std::declval<R &>() = std::declval<decltype(NATIVE_WIDE_DETAIL::adl_sincos(std::declval<R const &>())) &>().second)));
1274 }()) {
1275 if constexpr (requires { NATIVE_WIDE_DETAIL::adl_sincos(input.registers); }) {
1276 auto [sine,cosine] = NATIVE_WIDE_DETAIL::adl_sincos(input.registers);
1277 return std::pair{wide<R,N>{std::move(sine)},wide<R,N>{std::move(cosine)}};
1278 } else {
1279 wide<R,N> sine,cosine;
1280 auto & [...s] = sine;
1281 auto & [...c] = cosine;
1282 auto const & [...x] = input;
1283 ([&] { auto pair = NATIVE_WIDE_DETAIL::adl_sincos(x); s = pair.first; c = pair.second; }(), ...);
1284 return std::pair{std::move(sine),std::move(cosine)};
1285 }
1286 }
1287
1289 template <class R, std::size_t N> requires (::native::detail::wide_target<R> == NATIVE_WIDE_INDEX)
1290 [[nodiscard]] hint_inline constexpr wide<R, N> select(wide<decltype(R{} == R{}), N> const & masks,
1291 wide<R, N> const & a, wide<R, N> const & b)
1292 noexcept([] {
1293 if constexpr (N == 0)
1294 return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>>;
1295 else if constexpr (std::is_same_v<decltype(R{} == R{}), bool>)
1296 return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1297 noexcept(std::declval<R &>() = std::declval<R const &>());
1298 else
1299 return noexcept(wide<R,N>()) && std::is_nothrow_move_constructible_v<wide<R,N>> &&
1300 noexcept(std::declval<R &>() = NATIVE_WIDE_DETAIL::adl_select(
1301 std::declval<decltype(R{} == R{}) const &>(),
1302 std::declval<R const &>(), std::declval<R const &>()));
1303 }()) {
1304 wide<R, N> result;
1305 auto & [...value] = result;
1306 auto const & [...mask] = masks;
1307 auto const & [...x] = a;
1308 auto const & [...y] = b;
1309 if constexpr (std::is_same_v<decltype(R{} == R{}), bool>)
1310 ([&] { value = mask ? x : y; }(), ...);
1311 else
1312 ([&] { value = NATIVE_WIDE_DETAIL::adl_select(mask, x, y); }(), ...);
1313 return result;
1314 }
1315
1316#undef NATIVE_WIDE_DETAIL
1317#undef NATIVE_WIDE_INDEX
1318
1319#if defined(__x86_64__) || defined(_M_X64)
1320#define NATIVE_WIDE_INDEX 10
1321#define NATIVE_WIDE_DETAIL detail::wide_avx2_detail
1322#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_1))), apply_to=function)
1323
1324#pragma clang attribute pop
1325#undef NATIVE_WIDE_DETAIL
1326#undef NATIVE_WIDE_INDEX
1327#endif
1328
1329#if defined(__x86_64__) || defined(_M_X64)
1330#define NATIVE_WIDE_INDEX 9
1331#define NATIVE_WIDE_DETAIL detail::wide_avx512_base_detail
1332#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_2))), apply_to=function)
1333
1334#pragma clang attribute pop
1335#undef NATIVE_WIDE_DETAIL
1336#undef NATIVE_WIDE_INDEX
1337#endif
1338
1339#if defined(__x86_64__) || defined(_M_X64)
1340#define NATIVE_WIDE_INDEX 7
1341#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_detail
1342#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_3))), apply_to=function)
1343
1344#pragma clang attribute pop
1345#undef NATIVE_WIDE_DETAIL
1346#undef NATIVE_WIDE_INDEX
1347#endif
1348
1349#if defined(__x86_64__) || defined(_M_X64)
1350#define NATIVE_WIDE_INDEX 8
1351#define NATIVE_WIDE_DETAIL detail::wide_avx512_vl_detail
1352#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_4))), apply_to=function)
1353
1354#pragma clang attribute pop
1355#undef NATIVE_WIDE_DETAIL
1356#undef NATIVE_WIDE_INDEX
1357#endif
1358
1359#if defined(__x86_64__) || defined(_M_X64)
1360#define NATIVE_WIDE_INDEX 3
1361#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_vl_detail
1362#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_5))), apply_to=function)
1363
1364#pragma clang attribute pop
1365#undef NATIVE_WIDE_DETAIL
1366#undef NATIVE_WIDE_INDEX
1367#endif
1368
1369#if defined(__x86_64__) || defined(_M_X64)
1370#define NATIVE_WIDE_INDEX 5
1371#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_bf16_detail
1372#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_7))), apply_to=function)
1373
1374#pragma clang attribute pop
1375#undef NATIVE_WIDE_DETAIL
1376#undef NATIVE_WIDE_INDEX
1377#endif
1378
1379#if defined(__x86_64__) || defined(_M_X64)
1380#define NATIVE_WIDE_INDEX 1
1381#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_vl_bf16_detail
1382#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_9))), apply_to=function)
1383
1384#pragma clang attribute pop
1385#undef NATIVE_WIDE_DETAIL
1386#undef NATIVE_WIDE_INDEX
1387#endif
1388
1389#if defined(__x86_64__) || defined(_M_X64)
1390#define NATIVE_WIDE_INDEX 6
1391#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_fp16_detail
1392#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_11))), apply_to=function)
1393
1394#pragma clang attribute pop
1395#undef NATIVE_WIDE_DETAIL
1396#undef NATIVE_WIDE_INDEX
1397#endif
1398
1399#if defined(__x86_64__) || defined(_M_X64)
1400#define NATIVE_WIDE_INDEX 2
1401#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_vl_fp16_detail
1402#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_13))), apply_to=function)
1403
1404#pragma clang attribute pop
1405#undef NATIVE_WIDE_DETAIL
1406#undef NATIVE_WIDE_INDEX
1407#endif
1408
1409#if defined(__x86_64__) || defined(_M_X64)
1410#define NATIVE_WIDE_INDEX 4
1411#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_bf16_fp16_detail
1412#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_15))), apply_to=function)
1413
1414#pragma clang attribute pop
1415#undef NATIVE_WIDE_DETAIL
1416#undef NATIVE_WIDE_INDEX
1417#endif
1418
1419#if defined(__x86_64__) || defined(_M_X64)
1420#define NATIVE_WIDE_INDEX 0
1421#define NATIVE_WIDE_DETAIL detail::wide_avx512_bw_vl_bf16_fp16_detail
1422#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_17))), apply_to=function)
1423
1424#pragma clang attribute pop
1425#undef NATIVE_WIDE_DETAIL
1426#undef NATIVE_WIDE_INDEX
1427#endif
1428
1429#if defined(__aarch64__) || defined(_M_ARM64)
1430#define NATIVE_WIDE_INDEX 14
1431#define NATIVE_WIDE_DETAIL detail::wide_neon_detail
1432#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_20))), apply_to=function)
1433
1434#pragma clang attribute pop
1435#undef NATIVE_WIDE_DETAIL
1436#undef NATIVE_WIDE_INDEX
1437#endif
1438
1439#if defined(__aarch64__) || defined(_M_ARM64)
1440#define NATIVE_WIDE_INDEX 12
1441#define NATIVE_WIDE_DETAIL detail::wide_neon_bf16_detail
1442#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_21))), apply_to=function)
1443
1444#pragma clang attribute pop
1445#undef NATIVE_WIDE_DETAIL
1446#undef NATIVE_WIDE_INDEX
1447#endif
1448
1449#if defined(__aarch64__) || defined(_M_ARM64)
1450#define NATIVE_WIDE_INDEX 13
1451#define NATIVE_WIDE_DETAIL detail::wide_neon_fp16_detail
1452#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_22))), apply_to=function)
1453
1454#pragma clang attribute pop
1455#undef NATIVE_WIDE_DETAIL
1456#undef NATIVE_WIDE_INDEX
1457#endif
1458
1459#if defined(__aarch64__) || defined(_M_ARM64)
1460#define NATIVE_WIDE_INDEX 11
1461#define NATIVE_WIDE_DETAIL detail::wide_neon_half_detail
1462#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_23))), apply_to=function)
1463
1464#pragma clang attribute pop
1465#undef NATIVE_WIDE_DETAIL
1466#undef NATIVE_WIDE_INDEX
1467#endif
1468
1469#if NATIVE_HOST_WASM
1470#define NATIVE_WIDE_INDEX 16
1471#define NATIVE_WIDE_DETAIL detail::wide_wasm_detail
1472#pragma clang attribute push(__attribute__((target(NATIVE_KERNEL_TARGET_WASM))), apply_to=function)
1473
1474#pragma clang attribute pop
1475#undef NATIVE_WIDE_DETAIL
1476#undef NATIVE_WIDE_INDEX
1477#endif
1478
1479}
1480namespace std {
1481 // Structured binding lookup needs the primary names visible even when the
1482 // importer has not separately included <tuple>.
1483 using ::std::tuple_size;
1484 using ::std::tuple_element;
1485 using ::std::get;
1486 template<class T, size_t N>
1487 struct tuple_size<::native::wide<T, N>> : integral_constant<size_t, N> {};
1488 template<size_t I, class T, size_t N>
1489 struct tuple_element<I, ::native::wide<T, N>> : tuple_element<I, array<T, N>> {};
1490}
1491namespace wide::detail {
1492 // The legacy class belongs to native.wide. Specialize its adapter here rather
1493 // than forward-declaring that class in a global module fragment.
1494 template<class T,std::size_t N> struct shape<::native::wide<T,N>> : array_shape<T,N> {
1495 static constexpr auto kind=family::legacy;
1496 template<class R> using rebind=::native::wide<R,N>;
1497#if NATIVE_HOST_WASM
1498 // Let generic demotion reach the caller before inlining SIMD128 constructors.
1499 template<class R> requires (::native::detail::wide_target<R> == 16)
1500 hint_target("simd128") static inline constexpr rebind<R> restore(std::array<R,N> const & values) {
1501 return rebind<R>{values};
1502 }
1503#endif
1504 };
1505}
typename mask_traits< std::remove_cvref_t< T > >::type mask
Definition mask_traits.h:22
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, N, Arch > ceil(simd< float, N, Arch > x) noexcept
constexpr simd< float, L, Arch > exp2(simd< float, L, Arch > input) noexcept
Definition exp_body.h:65
constexpr auto abs(simd< float, N, Arch > a) noexcept
constexpr simd< float, N, Arch > trunc(simd< float, N, Arch > x) 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...
Definition exp_body.h:109
constexpr simd< float, N, Arch > floor(simd< float, N, Arch > x) noexcept
constexpr wide< T, N > copysign(wide< T, N > const &a, wide< T, N > const &b) noexcept(noexcept(detail::wide_generic_detail::wide_map< detail::wide_generic_detail::wide_copysign >(a, b)))
Definition wide.h:926
constexpr auto operator!(wide< T, N > const &a)
Definition wide.h:613
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:1027
constexpr auto operator~(wide< T, N > const &a)
Definition wide.h:606
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:1196
constexpr auto isnan(wide< T, N > const &input) noexcept(noexcept(detail::wide_generic_detail::wide_map< detail::wide_generic_detail::wide_isnan >(input)))
Definition wide.h:910
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:1006
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:1133
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:1154
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:1112
constexpr auto isfinite(wide< T, N > const &input) noexcept(noexcept(detail::wide_generic_detail::wide_map< detail::wide_generic_detail::wide_isfinite >(input)))
Definition wide.h:896
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:1091
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:1175
constexpr auto isinf(wide< T, N > const &input) noexcept(noexcept(detail::wide_generic_detail::wide_map< detail::wide_generic_detail::wide_isinf >(input)))
Definition wide.h:903
constexpr auto signbit(wide< T, N > const &input) noexcept(noexcept(detail::wide_generic_detail::wide_map< detail::wide_generic_detail::wide_signbit >(input)))
Definition wide.h:917
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...
void operator%=(simd< T, N, A > &, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator-(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
constexpr auto sincos(simd< float, L, A > input) noexcept
Paired sine/cosine preserving the permitted logical lane shape.
Definition exp_body.h:165
constexpr simd< T, N, A > sqrt(simd< T, N, A > v) noexcept
Compute correctly rounded square roots; negative finite lanes produce NaN.
void operator/(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator>>=(simd< T, N, A > &, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator>>(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
wide(T, U...) -> wide< T, 1+sizeof...(U)>
Deduce the common element type and the number of homogeneous constructor arguments.
void operator*=(simd< T, N, A > &, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator==(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator%(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator>=(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator>(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator&=(simd< T, N, A > &, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
constexpr simd< T, N, A > broadcast(simd< T, N, A > value, imm_t< I >) noexcept
Broadcast one compile-time-selected logical lane.
void operator/=(simd< T, N, A > &, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator|(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator+=(simd< T, N, A > &, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator*(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator-=(simd< T, N, A > &, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
constexpr simd< fp16, 32, Arch > fma(simd< fp16, 32, Arch > a, simd< fp16, 32, Arch > b, simd< fp16, 32, Arch > c) noexcept
void operator<=(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator^=(simd< T, N, A > &, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator<<(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator&(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator^(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator+(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
constexpr simd< T, N, A > select(M mask, simd< T, N, A > a, simd< T, N, A > b) noexcept
Bridge a matching compact mask to native half's existing vector-mask selection.
void operator!=(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator<(simd< T, N, A >, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator|=(simd< T, N, A > &, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
void operator<<=(simd< T, N, A > &, simd< U, M, B >)=delete
Reject mixed architectures and mismatched short-vector widths before native conversions can participa...
Standard-library adaptations documented here for SIMD value types.
constexpr bool isnan(::native::fp16 x) noexcept
Classify the stored bits as NaN without performing a floating-point conversion.
Own N values of T, including an empty pack when N == 0. registers is the underlying array....
Definition wide.h:86
constexpr wide(U const &value) noexcept(std::is_nothrow_constructible_v< T, U const & > &&(N==0||std::is_nothrow_copy_constructible_v< T >))
Convert one value to T, then copy it across the pack.
Definition wide.h:136
constexpr decltype(auto) apply(F &&f) noexcept(noexcept(std::apply(std::forward< F >(f), registers)))
Invoke f with all elements as arguments; the empty pack calls f().
Definition wide.h:161
constexpr T const & get() const &noexcept
Access element I, preserving constness and the value category of the pack.
Definition wide.h:97
constexpr decltype(auto) apply(F &&f) const noexcept(noexcept(std::apply(std::forward< F >(f), registers)))
Invoke f with all elements as arguments; the empty pack calls f().
Definition wide.h:167
static constexpr wide broadcast(T const &value) noexcept(N==0||std::is_nothrow_copy_constructible_v< T >)
Copy value to every element; an empty pack makes no copies.
Definition wide.h:153
constexpr T & get() &noexcept
Access element I, preserving constness and the value category of the pack.
Definition wide.h:94
constexpr T const && get() const &&noexcept
Access element I, preserving constness and the value category of the pack.
Definition wide.h:103
constexpr T && get() &&noexcept
Access element I, preserving constness and the value category of the pack.
Definition wide.h:100
constexpr wide(wide< U, N > const &source) noexcept(N==0||std::is_nothrow_constructible_v< T, U const & >)
Convert each element of a same-size pack; explicitness follows the element conversion.
Definition wide.h:143
constexpr wide() noexcept(std::is_nothrow_default_constructible_v< std::array< T, N > >)
Retain opted-in array initialization in the element's target scope.
Definition wide.h:115
constexpr wide()=default
Default-initialize the underlying array. Use wide{} for value initialization.
constexpr wide(std::array< T, N > values) noexcept(std::is_nothrow_move_constructible_v< std::array< T, N > >)
Take an array of exactly the pack extent.
Definition wide.h:120
constexpr wide(U &&... values) noexcept((std::is_nothrow_constructible_v< T, U && > &&...))
Construct one element from each argument, preserving argument order.
Definition wide.h:129
constexpr wide(wide< U, N > &&source) noexcept(N==0||std::is_nothrow_constructible_v< T, U && >)
Convert each element of a same-size pack; explicitness follows the element conversion.
Definition wide.h:148