ycpp 0.1.0__cp315-cp315t-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ycpp/__init__.py +110 -0
- ycpp/_array.py +318 -0
- ycpp/_awareness.py +268 -0
- ycpp/_doc.py +718 -0
- ycpp/_event.py +188 -0
- ycpp/_id_map.py +620 -0
- ycpp/_map.py +267 -0
- ycpp/_provider.py +180 -0
- ycpp/_snapshot.py +28 -0
- ycpp/_sticky_index.py +59 -0
- ycpp/_stream.py +91 -0
- ycpp/_sync.py +192 -0
- ycpp/_text.py +239 -0
- ycpp/_transaction.py +287 -0
- ycpp/_typed.py +122 -0
- ycpp/_undo.py +201 -0
- ycpp/_update.py +18 -0
- ycpp/_xml.py +452 -0
- ycpp/_ycpp.cp315t-win_amd64.lib +0 -0
- ycpp/_ycpp.cp315t-win_amd64.pyd +0 -0
- ycpp-0.1.0.data/headers/fast_float/ascii_number.h +766 -0
- ycpp-0.1.0.data/headers/fast_float/bigint.h +638 -0
- ycpp-0.1.0.data/headers/fast_float/constexpr_feature_detect.h +53 -0
- ycpp-0.1.0.data/headers/fast_float/decimal_to_binary.h +212 -0
- ycpp-0.1.0.data/headers/fast_float/digit_comparison.h +455 -0
- ycpp-0.1.0.data/headers/fast_float/fast_float.h +91 -0
- ycpp-0.1.0.data/headers/fast_float/fast_table.h +708 -0
- ycpp-0.1.0.data/headers/fast_float/float_common.h +1432 -0
- ycpp-0.1.0.data/headers/fast_float/parse_number.h +488 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_arithmetic.hpp +267 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_bit.hpp +230 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_cast.hpp +43 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_complex.hpp +112 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_details.hpp +386 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_logical.hpp +240 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_math.hpp +2601 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_memory.hpp +1006 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_rounding.hpp +72 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_swizzle.hpp +260 -0
- ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_trigo.hpp +996 -0
- ycpp-0.1.0.data/headers/xsimd/arch/utils/shifts.hpp +82 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx.hpp +2111 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx2.hpp +1591 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512bw.hpp +724 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512cd.hpp +28 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512dq.hpp +270 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512er.hpp +17 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512f.hpp +2919 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512ifma.hpp +17 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512pf.hpp +17 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vbmi.hpp +76 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vbmi2.hpp +130 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp +17 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vnni_avx512vbmi2.hpp +17 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avxvnni.hpp +17 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_common.hpp +26 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_common_fwd.hpp +127 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_constants.hpp +393 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_emulated.hpp +787 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_avx.hpp +93 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_avx2.hpp +46 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_sse.hpp +97 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma4.hpp +92 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_i8mm_neon64.hpp +17 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_isa.hpp +146 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_neon.hpp +3580 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_neon64.hpp +1614 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_rvv.hpp +1515 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_scalar.hpp +1210 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse2.hpp +2333 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse3.hpp +66 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse4_1.hpp +510 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse4_2.hpp +44 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_ssse3.hpp +186 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sve.hpp +1186 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_vsx.hpp +916 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_vxe.hpp +787 -0
- ycpp-0.1.0.data/headers/xsimd/arch/xsimd_wasm.hpp +1819 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_arch.hpp +242 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_config.hpp +620 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features.hpp +50 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_arm.hpp +132 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_ppc.hpp +54 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_riscv.hpp +95 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_s390x.hpp +56 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_x86.hpp +1044 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpuid.hpp +144 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_getauxval.hpp +159 -0
- ycpp-0.1.0.data/headers/xsimd/config/xsimd_macros.hpp +76 -0
- ycpp-0.1.0.data/headers/xsimd/math/xsimd_rem_pio2.hpp +707 -0
- ycpp-0.1.0.data/headers/xsimd/memory/xsimd_aligned_allocator.hpp +349 -0
- ycpp-0.1.0.data/headers/xsimd/memory/xsimd_alignment.hpp +102 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_all_registers.hpp +57 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_api.hpp +3106 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx2_register.hpp +44 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512bw_register.hpp +51 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512cd_register.hpp +51 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512dq_register.hpp +51 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512er_register.hpp +51 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512f_register.hpp +77 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512ifma_register.hpp +51 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512pf_register.hpp +51 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vbmi2_register.hpp +51 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vbmi_register.hpp +51 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp +54 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vnni_avx512vbmi2_register.hpp +53 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx_register.hpp +64 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_avxvnni_register.hpp +44 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch.hpp +1665 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch_constant.hpp +571 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch_fwd.hpp +41 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_common_arch.hpp +49 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_emulated_register.hpp +80 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_avx2_register.hpp +50 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_avx_register.hpp +50 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_sse_register.hpp +50 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma4_register.hpp +50 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_i8mm_neon64_register.hpp +55 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_neon64_register.hpp +55 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_neon_register.hpp +130 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_register.hpp +96 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_rvv_register.hpp +491 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse2_register.hpp +59 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse3_register.hpp +49 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse4_1_register.hpp +48 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse4_2_register.hpp +48 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_ssse3_register.hpp +48 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_sve_register.hpp +216 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_traits.hpp +408 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_utils.hpp +462 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_vsx_register.hpp +77 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_vxe_register.hpp +86 -0
- ycpp-0.1.0.data/headers/xsimd/types/xsimd_wasm_register.hpp +59 -0
- ycpp-0.1.0.data/headers/xsimd/utils/bits.hpp +122 -0
- ycpp-0.1.0.data/headers/xsimd/utils/xsimd_type_traits.hpp +145 -0
- ycpp-0.1.0.data/headers/xsimd/xsimd.hpp +43 -0
- ycpp-0.1.0.dist-info/DELVEWHEEL +2 -0
- ycpp-0.1.0.dist-info/METADATA +15 -0
- ycpp-0.1.0.dist-info/RECORD +142 -0
- ycpp-0.1.0.dist-info/WHEEL +4 -0
- ycpp.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
- ycpp.libs/msvcp140_1-226498d4bfcb4f07974757b596ebec45.dll +0 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/***************************************************************************
|
|
2
|
+
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
|
|
3
|
+
* Martin Renou *
|
|
4
|
+
* Copyright (c) QuantStack *
|
|
5
|
+
* Copyright (c) Serge Guelton *
|
|
6
|
+
* *
|
|
7
|
+
* Distributed under the terms of the BSD 3-Clause License. *
|
|
8
|
+
* *
|
|
9
|
+
* The full license is in the file LICENSE, distributed with this software. *
|
|
10
|
+
****************************************************************************/
|
|
11
|
+
|
|
12
|
+
#ifndef XSIMD_COMMON_ARITHMETIC_HPP
|
|
13
|
+
#define XSIMD_COMMON_ARITHMETIC_HPP
|
|
14
|
+
|
|
15
|
+
#include <complex>
|
|
16
|
+
#include <limits>
|
|
17
|
+
#include <type_traits>
|
|
18
|
+
|
|
19
|
+
#include "../../types/xsimd_batch_constant.hpp"
|
|
20
|
+
#include "./xsimd_common_details.hpp"
|
|
21
|
+
|
|
22
|
+
namespace xsimd
|
|
23
|
+
{
|
|
24
|
+
|
|
25
|
+
namespace kernel
|
|
26
|
+
{
|
|
27
|
+
|
|
28
|
+
using namespace types;
|
|
29
|
+
|
|
30
|
+
// bitwise_lshift
|
|
31
|
+
template <class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
32
|
+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
33
|
+
{
|
|
34
|
+
return detail::apply([](T x, T y) noexcept
|
|
35
|
+
{ return x << y; },
|
|
36
|
+
self, other);
|
|
37
|
+
}
|
|
38
|
+
template <size_t shift, class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
39
|
+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
40
|
+
{
|
|
41
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
42
|
+
static_assert(shift < bits, "Shift must be less than the number of bits in T");
|
|
43
|
+
return bitwise_lshift(self, shift, A {});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// bitwise_rshift
|
|
47
|
+
template <class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
48
|
+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
49
|
+
{
|
|
50
|
+
return detail::apply([](T x, T y) noexcept
|
|
51
|
+
{ return x >> y; },
|
|
52
|
+
self, other);
|
|
53
|
+
}
|
|
54
|
+
template <size_t shift, class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
55
|
+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
56
|
+
{
|
|
57
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
58
|
+
static_assert(shift < bits, "Shift must be less than the number of bits in T");
|
|
59
|
+
return bitwise_rshift(self, shift, A {});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// decr
|
|
63
|
+
template <class A, class T>
|
|
64
|
+
XSIMD_INLINE batch<T, A> decr(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
65
|
+
{
|
|
66
|
+
return self - T(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// decr_if
|
|
70
|
+
template <class A, class T, class Mask>
|
|
71
|
+
XSIMD_INLINE batch<T, A> decr_if(batch<T, A> const& self, Mask const& mask, requires_arch<common>) noexcept
|
|
72
|
+
{
|
|
73
|
+
return select(mask, decr(self), self);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// div
|
|
77
|
+
template <class A, class T, class = std::enable_if_t<std::is_integral<T>::value>>
|
|
78
|
+
XSIMD_INLINE batch<T, A> div(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
79
|
+
{
|
|
80
|
+
return detail::apply([](T x, T y) noexcept -> T
|
|
81
|
+
{ return x / y; },
|
|
82
|
+
self, other);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// fma
|
|
86
|
+
template <class A, class T>
|
|
87
|
+
XSIMD_INLINE batch<T, A> fma(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<common>) noexcept
|
|
88
|
+
{
|
|
89
|
+
return x * y + z;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
template <class A, class T>
|
|
93
|
+
XSIMD_INLINE batch<std::complex<T>, A> fma(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<common>) noexcept
|
|
94
|
+
{
|
|
95
|
+
auto res_r = fms(x.real(), y.real(), fms(x.imag(), y.imag(), z.real()));
|
|
96
|
+
auto res_i = fma(x.real(), y.imag(), fma(x.imag(), y.real(), z.imag()));
|
|
97
|
+
return { res_r, res_i };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// fms
|
|
101
|
+
template <class A, class T>
|
|
102
|
+
XSIMD_INLINE batch<T, A> fms(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<common>) noexcept
|
|
103
|
+
{
|
|
104
|
+
return x * y - z;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
template <class A, class T>
|
|
108
|
+
XSIMD_INLINE batch<std::complex<T>, A> fms(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<common>) noexcept
|
|
109
|
+
{
|
|
110
|
+
auto res_r = fms(x.real(), y.real(), fma(x.imag(), y.imag(), z.real()));
|
|
111
|
+
auto res_i = fma(x.real(), y.imag(), fms(x.imag(), y.real(), z.imag()));
|
|
112
|
+
return { res_r, res_i };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// fnma
|
|
116
|
+
template <class A, class T>
|
|
117
|
+
XSIMD_INLINE batch<T, A> fnma(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<common>) noexcept
|
|
118
|
+
{
|
|
119
|
+
return -x * y + z;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
template <class A, class T>
|
|
123
|
+
XSIMD_INLINE batch<std::complex<T>, A> fnma(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<common>) noexcept
|
|
124
|
+
{
|
|
125
|
+
auto res_r = -fms(x.real(), y.real(), fma(x.imag(), y.imag(), z.real()));
|
|
126
|
+
auto res_i = -fma(x.real(), y.imag(), fms(x.imag(), y.real(), z.imag()));
|
|
127
|
+
return { res_r, res_i };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// fnms
|
|
131
|
+
template <class A, class T>
|
|
132
|
+
XSIMD_INLINE batch<T, A> fnms(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<common>) noexcept
|
|
133
|
+
{
|
|
134
|
+
return -x * y - z;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
template <class A, class T>
|
|
138
|
+
XSIMD_INLINE batch<std::complex<T>, A> fnms(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<common>) noexcept
|
|
139
|
+
{
|
|
140
|
+
auto res_r = -fms(x.real(), y.real(), fms(x.imag(), y.imag(), z.real()));
|
|
141
|
+
auto res_i = -fma(x.real(), y.imag(), fma(x.imag(), y.real(), z.imag()));
|
|
142
|
+
return { res_r, res_i };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// fmas
|
|
146
|
+
template <class A, class T>
|
|
147
|
+
XSIMD_INLINE batch<T, A> fmas(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<common>) noexcept
|
|
148
|
+
{
|
|
149
|
+
struct even_lane
|
|
150
|
+
{
|
|
151
|
+
static constexpr bool get(unsigned const i, unsigned) noexcept { return (i & 1u) == 0; }
|
|
152
|
+
};
|
|
153
|
+
const auto mask = make_batch_bool_constant<T, even_lane, A>();
|
|
154
|
+
return fma(x, y, select(mask, neg(z), z));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// incr
|
|
158
|
+
template <class A, class T>
|
|
159
|
+
XSIMD_INLINE batch<T, A> incr(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
160
|
+
{
|
|
161
|
+
return self + T(1);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// incr_if
|
|
165
|
+
template <class A, class T, class Mask>
|
|
166
|
+
XSIMD_INLINE batch<T, A> incr_if(batch<T, A> const& self, Mask const& mask, requires_arch<common>) noexcept
|
|
167
|
+
{
|
|
168
|
+
return select(mask, incr(self), self);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// mul
|
|
172
|
+
template <class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
173
|
+
XSIMD_INLINE batch<T, A> mul(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
174
|
+
{
|
|
175
|
+
return detail::apply([](T x, T y) noexcept -> T
|
|
176
|
+
{ return x * y; },
|
|
177
|
+
self, other);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// rotl
|
|
181
|
+
template <class A, class T, class STy>
|
|
182
|
+
XSIMD_INLINE batch<T, A> rotl(batch<T, A> const& self, STy other, requires_arch<common>) noexcept
|
|
183
|
+
{
|
|
184
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
185
|
+
return (self << other) | (self >> (bits - other));
|
|
186
|
+
}
|
|
187
|
+
template <size_t count, class A, class T>
|
|
188
|
+
XSIMD_INLINE batch<T, A> rotl(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
189
|
+
{
|
|
190
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
191
|
+
static_assert(count < bits, "Count amount must be less than the number of bits in T");
|
|
192
|
+
return bitwise_lshift<count>(self) | bitwise_rshift<bits - count>(self);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// rotr
|
|
196
|
+
template <class A, class T, class STy>
|
|
197
|
+
XSIMD_INLINE batch<T, A> rotr(batch<T, A> const& self, STy other, requires_arch<common>) noexcept
|
|
198
|
+
{
|
|
199
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
200
|
+
return (self >> other) | (self << (bits - other));
|
|
201
|
+
}
|
|
202
|
+
template <size_t count, class A, class T>
|
|
203
|
+
XSIMD_INLINE batch<T, A> rotr(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
204
|
+
{
|
|
205
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
206
|
+
static_assert(count < bits, "Count must be less than the number of bits in T");
|
|
207
|
+
return bitwise_rshift<count>(self) | bitwise_lshift<bits - count>(self);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// sadd
|
|
211
|
+
template <class A>
|
|
212
|
+
XSIMD_INLINE batch<float, A> sadd(batch<float, A> const& self, batch<float, A> const& other, requires_arch<common>) noexcept
|
|
213
|
+
{
|
|
214
|
+
return add(self, other); // no saturated arithmetic on floating point numbers
|
|
215
|
+
}
|
|
216
|
+
template <class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
217
|
+
XSIMD_INLINE batch<T, A> sadd(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
218
|
+
{
|
|
219
|
+
if (std::is_signed<T>::value)
|
|
220
|
+
{
|
|
221
|
+
auto self_pos_branch = min(std::numeric_limits<T>::max() - other, self);
|
|
222
|
+
auto self_neg_branch = max(std::numeric_limits<T>::min() - other, self);
|
|
223
|
+
return other + select(other >= 0, self_pos_branch, self_neg_branch);
|
|
224
|
+
}
|
|
225
|
+
else
|
|
226
|
+
{
|
|
227
|
+
const auto diffmax = std::numeric_limits<T>::max() - self;
|
|
228
|
+
const auto mindiff = min(diffmax, other);
|
|
229
|
+
return self + mindiff;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
template <class A>
|
|
233
|
+
XSIMD_INLINE batch<double, A> sadd(batch<double, A> const& self, batch<double, A> const& other, requires_arch<common>) noexcept
|
|
234
|
+
{
|
|
235
|
+
return add(self, other); // no saturated arithmetic on floating point numbers
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ssub
|
|
239
|
+
template <class A>
|
|
240
|
+
XSIMD_INLINE batch<float, A> ssub(batch<float, A> const& self, batch<float, A> const& other, requires_arch<common>) noexcept
|
|
241
|
+
{
|
|
242
|
+
return sub(self, other); // no saturated arithmetic on floating point numbers
|
|
243
|
+
}
|
|
244
|
+
template <class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
245
|
+
XSIMD_INLINE batch<T, A> ssub(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
246
|
+
{
|
|
247
|
+
if (std::is_signed<T>::value)
|
|
248
|
+
{
|
|
249
|
+
return sadd(self, -other);
|
|
250
|
+
}
|
|
251
|
+
else
|
|
252
|
+
{
|
|
253
|
+
const auto diff = min(self, other);
|
|
254
|
+
return self - diff;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
template <class A>
|
|
258
|
+
XSIMD_INLINE batch<double, A> ssub(batch<double, A> const& self, batch<double, A> const& other, requires_arch<common>) noexcept
|
|
259
|
+
{
|
|
260
|
+
return sub(self, other); // no saturated arithmetic on floating point numbers
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
#endif
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/****************************************************************
|
|
2
|
+
* Partial backport of `__cpp_lib_bitops == 201907L` from C++20 *
|
|
3
|
+
****************************************************************/
|
|
4
|
+
|
|
5
|
+
#ifndef XSIMD_BIT_HPP
|
|
6
|
+
#define XSIMD_BIT_HPP
|
|
7
|
+
|
|
8
|
+
#if __cplusplus > 202002L
|
|
9
|
+
|
|
10
|
+
#include <version>
|
|
11
|
+
|
|
12
|
+
#if __cpp_lib_bitops >= 201907L
|
|
13
|
+
|
|
14
|
+
#include <bit>
|
|
15
|
+
|
|
16
|
+
namespace xsimd
|
|
17
|
+
{
|
|
18
|
+
namespace detail
|
|
19
|
+
{
|
|
20
|
+
using std::countl_one;
|
|
21
|
+
using std::countl_zero;
|
|
22
|
+
using std::countr_one;
|
|
23
|
+
using std::countr_zero;
|
|
24
|
+
using std::popcount;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#else
|
|
31
|
+
|
|
32
|
+
#include <climits>
|
|
33
|
+
#include <type_traits>
|
|
34
|
+
|
|
35
|
+
#ifdef __has_builtin
|
|
36
|
+
#define XSIMD_HAS_BUILTIN(x) __has_builtin(x)
|
|
37
|
+
#else
|
|
38
|
+
#define XSIMD_HAS_BUILTIN(x) 0
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
#ifdef _MSC_VER
|
|
42
|
+
#include <intrin.h>
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
namespace xsimd
|
|
46
|
+
{
|
|
47
|
+
namespace detail
|
|
48
|
+
{
|
|
49
|
+
// FIXME: We could do better by dispatching to the appropriate popcount instruction
|
|
50
|
+
// depending on the arch.
|
|
51
|
+
|
|
52
|
+
template <class T, class = std::enable_if_t<std::is_unsigned<T>::value>>
|
|
53
|
+
XSIMD_INLINE int popcount(T x) noexcept
|
|
54
|
+
{
|
|
55
|
+
#if XSIMD_HAS_BUILTIN(__builtin_popcountg)
|
|
56
|
+
return __builtin_popcountg(x);
|
|
57
|
+
#else
|
|
58
|
+
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
|
|
59
|
+
{
|
|
60
|
+
#if XSIMD_HAS_BUILTIN(__builtin_popcount)
|
|
61
|
+
return __builtin_popcount(x);
|
|
62
|
+
#elif defined(_MSC_VER)
|
|
63
|
+
return __popcnt(x);
|
|
64
|
+
#else
|
|
65
|
+
// https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSet64
|
|
66
|
+
return ((uint64_t)x * 0x200040008001ULL & 0x111111111111111ULL) % 0xf;
|
|
67
|
+
#endif
|
|
68
|
+
}
|
|
69
|
+
else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
|
|
70
|
+
{
|
|
71
|
+
#if XSIMD_HAS_BUILTIN(__builtin_popcount)
|
|
72
|
+
return __builtin_popcount(x);
|
|
73
|
+
#elif defined(_MSC_VER)
|
|
74
|
+
return __popcnt16(x);
|
|
75
|
+
#else
|
|
76
|
+
// https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSet64
|
|
77
|
+
constexpr unsigned long long msb12 = 0x1001001001001ULL;
|
|
78
|
+
constexpr unsigned long long mask5 = 0x84210842108421ULL;
|
|
79
|
+
|
|
80
|
+
unsigned int v = (unsigned int)x;
|
|
81
|
+
|
|
82
|
+
return ((v & 0xfff) * msb12 & mask5) % 0x1f
|
|
83
|
+
+ (((v & 0xfff000) >> 12) * msb12 & mask5) % 0x1f;
|
|
84
|
+
#endif
|
|
85
|
+
}
|
|
86
|
+
else XSIMD_IF_CONSTEXPR(sizeof(T) == 4)
|
|
87
|
+
{
|
|
88
|
+
#if XSIMD_HAS_BUILTIN(__builtin_popcount)
|
|
89
|
+
return __builtin_popcount(x);
|
|
90
|
+
#elif defined(_MSC_VER)
|
|
91
|
+
return __popcnt(x);
|
|
92
|
+
#else
|
|
93
|
+
// https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
|
|
94
|
+
x = x - ((x >> 1) & (T) ~(T)0 / 3);
|
|
95
|
+
x = (x & (T) ~(T)0 / 15 * 3) + ((x >> 2) & (T) ~(T)0 / 15 * 3);
|
|
96
|
+
x = (x + (x >> 4)) & (T) ~(T)0 / 255 * 15;
|
|
97
|
+
return (x * ((T) ~(T)0 / 255)) >> (sizeof(T) - 1) * CHAR_BIT;
|
|
98
|
+
#endif
|
|
99
|
+
}
|
|
100
|
+
else
|
|
101
|
+
{
|
|
102
|
+
// sizeof(T) == 8
|
|
103
|
+
#if XSIMD_HAS_BUILTIN(__builtin_popcountll)
|
|
104
|
+
return __builtin_popcountll(x);
|
|
105
|
+
#elif XSIMD_HAS_BUILTIN(__builtin_popcount)
|
|
106
|
+
return __builtin_popcount((unsigned int)x) + __builtin_popcount((unsigned int)(x >> 32));
|
|
107
|
+
#elif defined(_MSC_VER)
|
|
108
|
+
#ifdef _M_X64
|
|
109
|
+
return (int)__popcnt64(x);
|
|
110
|
+
#else
|
|
111
|
+
return (int)(__popcnt((unsigned int)x) + __popcnt((unsigned int)(x >> 32)));
|
|
112
|
+
#endif
|
|
113
|
+
#else
|
|
114
|
+
// https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
|
|
115
|
+
x = x - ((x >> 1) & (T) ~(T)0 / 3);
|
|
116
|
+
x = (x & (T) ~(T)0 / 15 * 3) + ((x >> 2) & (T) ~(T)0 / 15 * 3);
|
|
117
|
+
x = (x + (x >> 4)) & (T) ~(T)0 / 255 * 15;
|
|
118
|
+
return (x * ((T) ~(T)0 / 255)) >> (sizeof(T) - 1) * CHAR_BIT;
|
|
119
|
+
#endif
|
|
120
|
+
}
|
|
121
|
+
#endif
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
template <class T, class = std::enable_if_t<std::is_unsigned<T>::value>>
|
|
125
|
+
XSIMD_INLINE int countl_zero(T x) noexcept
|
|
126
|
+
{
|
|
127
|
+
#if XSIMD_HAS_BUILTIN(__builtin_clzg)
|
|
128
|
+
return __builtin_clzg(x, (int)(sizeof(T) * CHAR_BIT));
|
|
129
|
+
#else
|
|
130
|
+
if (x == 0)
|
|
131
|
+
return sizeof(T) * CHAR_BIT;
|
|
132
|
+
|
|
133
|
+
XSIMD_IF_CONSTEXPR(sizeof(T) <= 4)
|
|
134
|
+
{
|
|
135
|
+
#if XSIMD_HAS_BUILTIN(__builtin_clz)
|
|
136
|
+
return __builtin_clz((unsigned int)x) - (4 - sizeof(T)) * CHAR_BIT;
|
|
137
|
+
#elif defined(_MSC_VER)
|
|
138
|
+
unsigned long index;
|
|
139
|
+
_BitScanReverse(&index, (unsigned long)x);
|
|
140
|
+
return sizeof(T) * CHAR_BIT - index - 1;
|
|
141
|
+
#else
|
|
142
|
+
x |= x >> 1;
|
|
143
|
+
x |= x >> 2;
|
|
144
|
+
x |= x >> 4;
|
|
145
|
+
XSIMD_IF_CONSTEXPR(sizeof(T) >= 2)
|
|
146
|
+
{
|
|
147
|
+
x |= x >> 8;
|
|
148
|
+
}
|
|
149
|
+
XSIMD_IF_CONSTEXPR(sizeof(T) >= 4)
|
|
150
|
+
{
|
|
151
|
+
x |= x >> 16;
|
|
152
|
+
}
|
|
153
|
+
return sizeof(T) * CHAR_BIT - popcount(x);
|
|
154
|
+
#endif
|
|
155
|
+
}
|
|
156
|
+
else
|
|
157
|
+
{
|
|
158
|
+
// sizeof(T) == 8
|
|
159
|
+
#if XSIMD_HAS_BUILTIN(__builtin_clzll)
|
|
160
|
+
return __builtin_clzll((unsigned long long)x);
|
|
161
|
+
#elif defined(_MSC_VER) && defined(_M_X64)
|
|
162
|
+
unsigned long index;
|
|
163
|
+
_BitScanReverse64(&index, (unsigned long long)x);
|
|
164
|
+
return sizeof(T) * CHAR_BIT - index - 1;
|
|
165
|
+
#else
|
|
166
|
+
x |= x >> 1;
|
|
167
|
+
x |= x >> 2;
|
|
168
|
+
x |= x >> 4;
|
|
169
|
+
x |= x >> 8;
|
|
170
|
+
x |= x >> 16;
|
|
171
|
+
x |= x >> 32;
|
|
172
|
+
return sizeof(T) * CHAR_BIT - popcount(x);
|
|
173
|
+
#endif
|
|
174
|
+
}
|
|
175
|
+
#endif
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
template <class T, class = std::enable_if_t<std::is_unsigned<T>::value>>
|
|
179
|
+
XSIMD_INLINE int countl_one(T x) noexcept
|
|
180
|
+
{
|
|
181
|
+
return countl_zero(T(~x));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
template <class T, class = std::enable_if_t<std::is_unsigned<T>::value>>
|
|
185
|
+
XSIMD_INLINE int countr_zero(T x) noexcept
|
|
186
|
+
{
|
|
187
|
+
#if XSIMD_HAS_BUILTIN(__builtin_ctzg)
|
|
188
|
+
return __builtin_ctzg(x, (int)(sizeof(T) * CHAR_BIT));
|
|
189
|
+
#else
|
|
190
|
+
if (x == 0)
|
|
191
|
+
return sizeof(T) * CHAR_BIT;
|
|
192
|
+
|
|
193
|
+
XSIMD_IF_CONSTEXPR(sizeof(T) <= 4)
|
|
194
|
+
{
|
|
195
|
+
#if XSIMD_HAS_BUILTIN(__builtin_ctz)
|
|
196
|
+
return __builtin_ctz((unsigned int)x);
|
|
197
|
+
#elif defined(_MSC_VER)
|
|
198
|
+
unsigned long index;
|
|
199
|
+
_BitScanForward(&index, (unsigned long)x);
|
|
200
|
+
return index;
|
|
201
|
+
#endif
|
|
202
|
+
}
|
|
203
|
+
else
|
|
204
|
+
{
|
|
205
|
+
// sizeof(T) == 8
|
|
206
|
+
#if XSIMD_HAS_BUILTIN(__builtin_ctzll)
|
|
207
|
+
return __builtin_ctzll((unsigned long long)x);
|
|
208
|
+
#elif defined(_MSC_VER) && defined(_M_X64)
|
|
209
|
+
unsigned long index;
|
|
210
|
+
_BitScanForward64(&index, (unsigned long long)x);
|
|
211
|
+
return index;
|
|
212
|
+
#endif
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup
|
|
216
|
+
return popcount((T)((x & -x) - 1));
|
|
217
|
+
#endif
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
template <class T, class = std::enable_if_t<std::is_unsigned<T>::value>>
|
|
221
|
+
XSIMD_INLINE int countr_one(T x) noexcept
|
|
222
|
+
{
|
|
223
|
+
return countr_zero(T(~x));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
#endif
|
|
230
|
+
#endif
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/***************************************************************************
|
|
2
|
+
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
|
|
3
|
+
* Martin Renou *
|
|
4
|
+
* Copyright (c) QuantStack *
|
|
5
|
+
* Copyright (c) Serge Guelton *
|
|
6
|
+
* *
|
|
7
|
+
* Distributed under the terms of the BSD 3-Clause License. *
|
|
8
|
+
* *
|
|
9
|
+
* The full license is in the file LICENSE, distributed with this software. *
|
|
10
|
+
****************************************************************************/
|
|
11
|
+
|
|
12
|
+
#ifndef XSIMD_COMMON_CAST_HPP
|
|
13
|
+
#define XSIMD_COMMON_CAST_HPP
|
|
14
|
+
|
|
15
|
+
#include <array>
|
|
16
|
+
|
|
17
|
+
#include "../../config/xsimd_macros.hpp"
|
|
18
|
+
#include "../../utils/xsimd_type_traits.hpp"
|
|
19
|
+
|
|
20
|
+
namespace xsimd
|
|
21
|
+
{
|
|
22
|
+
namespace kernel
|
|
23
|
+
{
|
|
24
|
+
template <class A, class T>
|
|
25
|
+
XSIMD_INLINE std::array<batch<widen_t<T>, A>, 2> widen(batch<T, A> const& x, requires_arch<common>) noexcept
|
|
26
|
+
{
|
|
27
|
+
alignas(A::alignment()) T buffer[batch<T, A>::size];
|
|
28
|
+
x.store_aligned(&buffer[0]);
|
|
29
|
+
|
|
30
|
+
using T_out = widen_t<T>;
|
|
31
|
+
alignas(A::alignment()) T_out out_buffer[batch<T, A>::size];
|
|
32
|
+
for (size_t i = 0; i < batch<T, A>::size; ++i)
|
|
33
|
+
out_buffer[i] = static_cast<T_out>(buffer[i]);
|
|
34
|
+
|
|
35
|
+
return { batch<T_out, A>::load_aligned(&out_buffer[0]),
|
|
36
|
+
batch<T_out, A>::load_aligned(&out_buffer[batch<T_out, A>::size]) };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#endif
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/***************************************************************************
|
|
2
|
+
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
|
|
3
|
+
* Martin Renou *
|
|
4
|
+
* Copyright (c) QuantStack *
|
|
5
|
+
* Copyright (c) Serge Guelton *
|
|
6
|
+
* *
|
|
7
|
+
* Distributed under the terms of the BSD 3-Clause License. *
|
|
8
|
+
* *
|
|
9
|
+
* The full license is in the file LICENSE, distributed with this software. *
|
|
10
|
+
****************************************************************************/
|
|
11
|
+
|
|
12
|
+
#ifndef XSIMD_COMMON_COMPLEX_HPP
|
|
13
|
+
#define XSIMD_COMMON_COMPLEX_HPP
|
|
14
|
+
|
|
15
|
+
#include <complex>
|
|
16
|
+
|
|
17
|
+
#include "./xsimd_common_details.hpp"
|
|
18
|
+
|
|
19
|
+
namespace xsimd
|
|
20
|
+
{
|
|
21
|
+
|
|
22
|
+
namespace kernel
|
|
23
|
+
{
|
|
24
|
+
|
|
25
|
+
using namespace types;
|
|
26
|
+
|
|
27
|
+
// real
|
|
28
|
+
template <class A, class T>
|
|
29
|
+
XSIMD_INLINE batch<T, A> real(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
30
|
+
{
|
|
31
|
+
return self;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
template <class A, class T>
|
|
35
|
+
XSIMD_INLINE batch<T, A> real(batch<std::complex<T>, A> const& self, requires_arch<common>) noexcept
|
|
36
|
+
{
|
|
37
|
+
return self.real();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// imag
|
|
41
|
+
template <class A, class T>
|
|
42
|
+
XSIMD_INLINE batch<T, A> imag(batch<T, A> const& /*self*/, requires_arch<common>) noexcept
|
|
43
|
+
{
|
|
44
|
+
return batch<T, A>(T(0));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
template <class A, class T>
|
|
48
|
+
XSIMD_INLINE batch<T, A> imag(batch<std::complex<T>, A> const& self, requires_arch<common>) noexcept
|
|
49
|
+
{
|
|
50
|
+
return self.imag();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// arg
|
|
54
|
+
template <class A, class T>
|
|
55
|
+
XSIMD_INLINE real_batch_type_t<batch<T, A>> arg(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
56
|
+
{
|
|
57
|
+
return atan2(imag(self), real(self));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// conj
|
|
61
|
+
template <class A, class T>
|
|
62
|
+
XSIMD_INLINE complex_batch_type_t<batch<T, A>> conj(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
63
|
+
{
|
|
64
|
+
return { real(self), -imag(self) };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// norm
|
|
68
|
+
template <class A, class T>
|
|
69
|
+
XSIMD_INLINE real_batch_type_t<batch<T, A>> norm(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
70
|
+
{
|
|
71
|
+
return { fma(real(self), real(self), imag(self) * imag(self)) };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// proj
|
|
75
|
+
template <class A, class T>
|
|
76
|
+
XSIMD_INLINE complex_batch_type_t<batch<T, A>> proj(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
77
|
+
{
|
|
78
|
+
using batch_type = complex_batch_type_t<batch<T, A>>;
|
|
79
|
+
using real_batch = typename batch_type::real_batch;
|
|
80
|
+
using real_value_type = typename real_batch::value_type;
|
|
81
|
+
#ifdef __FAST_MATH__
|
|
82
|
+
return { self };
|
|
83
|
+
#else
|
|
84
|
+
auto cond = xsimd::isinf(real(self)) || xsimd::isinf(imag(self));
|
|
85
|
+
return select(cond,
|
|
86
|
+
batch_type(constants::infinity<real_batch>(),
|
|
87
|
+
copysign(real_batch(real_value_type(0)), imag(self))),
|
|
88
|
+
batch_type(self));
|
|
89
|
+
#endif
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
template <class A, class T>
|
|
93
|
+
XSIMD_INLINE batch_bool<T, A> isnan(batch<std::complex<T>, A> const& self, requires_arch<common>) noexcept
|
|
94
|
+
{
|
|
95
|
+
return batch_bool<T, A>(isnan(self.real()) || isnan(self.imag()));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
template <class A, class T>
|
|
99
|
+
XSIMD_INLINE batch_bool<T, A> isinf(batch<std::complex<T>, A> const& self, requires_arch<common>) noexcept
|
|
100
|
+
{
|
|
101
|
+
return batch_bool<T, A>(isinf(self.real()) || isinf(self.imag()));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
template <class A, class T>
|
|
105
|
+
XSIMD_INLINE batch_bool<T, A> isfinite(batch<std::complex<T>, A> const& self, requires_arch<common>) noexcept
|
|
106
|
+
{
|
|
107
|
+
return batch_bool<T, A>(isfinite(self.real()) && isfinite(self.imag()));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#endif
|