ycpp 0.1.0__cp315-cp315t-win_arm64.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.
Files changed (142) hide show
  1. ycpp/__init__.py +110 -0
  2. ycpp/_array.py +318 -0
  3. ycpp/_awareness.py +268 -0
  4. ycpp/_doc.py +718 -0
  5. ycpp/_event.py +188 -0
  6. ycpp/_id_map.py +620 -0
  7. ycpp/_map.py +267 -0
  8. ycpp/_provider.py +180 -0
  9. ycpp/_snapshot.py +28 -0
  10. ycpp/_sticky_index.py +59 -0
  11. ycpp/_stream.py +91 -0
  12. ycpp/_sync.py +192 -0
  13. ycpp/_text.py +239 -0
  14. ycpp/_transaction.py +287 -0
  15. ycpp/_typed.py +122 -0
  16. ycpp/_undo.py +201 -0
  17. ycpp/_update.py +18 -0
  18. ycpp/_xml.py +452 -0
  19. ycpp/_ycpp.cp315t-win_arm64.lib +0 -0
  20. ycpp/_ycpp.cp315t-win_arm64.pyd +0 -0
  21. ycpp-0.1.0.data/headers/fast_float/ascii_number.h +766 -0
  22. ycpp-0.1.0.data/headers/fast_float/bigint.h +638 -0
  23. ycpp-0.1.0.data/headers/fast_float/constexpr_feature_detect.h +53 -0
  24. ycpp-0.1.0.data/headers/fast_float/decimal_to_binary.h +212 -0
  25. ycpp-0.1.0.data/headers/fast_float/digit_comparison.h +455 -0
  26. ycpp-0.1.0.data/headers/fast_float/fast_float.h +91 -0
  27. ycpp-0.1.0.data/headers/fast_float/fast_table.h +708 -0
  28. ycpp-0.1.0.data/headers/fast_float/float_common.h +1432 -0
  29. ycpp-0.1.0.data/headers/fast_float/parse_number.h +488 -0
  30. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_arithmetic.hpp +267 -0
  31. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_bit.hpp +230 -0
  32. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_cast.hpp +43 -0
  33. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_complex.hpp +112 -0
  34. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_details.hpp +386 -0
  35. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_logical.hpp +240 -0
  36. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_math.hpp +2601 -0
  37. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_memory.hpp +1006 -0
  38. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_rounding.hpp +72 -0
  39. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_swizzle.hpp +260 -0
  40. ycpp-0.1.0.data/headers/xsimd/arch/common/xsimd_common_trigo.hpp +996 -0
  41. ycpp-0.1.0.data/headers/xsimd/arch/utils/shifts.hpp +82 -0
  42. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx.hpp +2111 -0
  43. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx2.hpp +1591 -0
  44. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512bw.hpp +724 -0
  45. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512cd.hpp +28 -0
  46. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512dq.hpp +270 -0
  47. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512er.hpp +17 -0
  48. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512f.hpp +2919 -0
  49. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512ifma.hpp +17 -0
  50. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512pf.hpp +17 -0
  51. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vbmi.hpp +76 -0
  52. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vbmi2.hpp +130 -0
  53. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp +17 -0
  54. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avx512vnni_avx512vbmi2.hpp +17 -0
  55. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_avxvnni.hpp +17 -0
  56. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_common.hpp +26 -0
  57. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_common_fwd.hpp +127 -0
  58. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_constants.hpp +393 -0
  59. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_emulated.hpp +787 -0
  60. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_avx.hpp +93 -0
  61. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_avx2.hpp +46 -0
  62. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma3_sse.hpp +97 -0
  63. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_fma4.hpp +92 -0
  64. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_i8mm_neon64.hpp +17 -0
  65. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_isa.hpp +146 -0
  66. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_neon.hpp +3580 -0
  67. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_neon64.hpp +1614 -0
  68. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_rvv.hpp +1515 -0
  69. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_scalar.hpp +1210 -0
  70. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse2.hpp +2333 -0
  71. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse3.hpp +66 -0
  72. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse4_1.hpp +510 -0
  73. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sse4_2.hpp +44 -0
  74. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_ssse3.hpp +186 -0
  75. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_sve.hpp +1186 -0
  76. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_vsx.hpp +916 -0
  77. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_vxe.hpp +787 -0
  78. ycpp-0.1.0.data/headers/xsimd/arch/xsimd_wasm.hpp +1819 -0
  79. ycpp-0.1.0.data/headers/xsimd/config/xsimd_arch.hpp +242 -0
  80. ycpp-0.1.0.data/headers/xsimd/config/xsimd_config.hpp +620 -0
  81. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features.hpp +50 -0
  82. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_arm.hpp +132 -0
  83. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_ppc.hpp +54 -0
  84. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_riscv.hpp +95 -0
  85. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_s390x.hpp +56 -0
  86. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpu_features_x86.hpp +1044 -0
  87. ycpp-0.1.0.data/headers/xsimd/config/xsimd_cpuid.hpp +144 -0
  88. ycpp-0.1.0.data/headers/xsimd/config/xsimd_getauxval.hpp +159 -0
  89. ycpp-0.1.0.data/headers/xsimd/config/xsimd_macros.hpp +76 -0
  90. ycpp-0.1.0.data/headers/xsimd/math/xsimd_rem_pio2.hpp +707 -0
  91. ycpp-0.1.0.data/headers/xsimd/memory/xsimd_aligned_allocator.hpp +349 -0
  92. ycpp-0.1.0.data/headers/xsimd/memory/xsimd_alignment.hpp +102 -0
  93. ycpp-0.1.0.data/headers/xsimd/types/xsimd_all_registers.hpp +57 -0
  94. ycpp-0.1.0.data/headers/xsimd/types/xsimd_api.hpp +3106 -0
  95. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx2_register.hpp +44 -0
  96. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512bw_register.hpp +51 -0
  97. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512cd_register.hpp +51 -0
  98. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512dq_register.hpp +51 -0
  99. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512er_register.hpp +51 -0
  100. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512f_register.hpp +77 -0
  101. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512ifma_register.hpp +51 -0
  102. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512pf_register.hpp +51 -0
  103. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vbmi2_register.hpp +51 -0
  104. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vbmi_register.hpp +51 -0
  105. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp +54 -0
  106. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx512vnni_avx512vbmi2_register.hpp +53 -0
  107. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avx_register.hpp +64 -0
  108. ycpp-0.1.0.data/headers/xsimd/types/xsimd_avxvnni_register.hpp +44 -0
  109. ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch.hpp +1665 -0
  110. ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch_constant.hpp +571 -0
  111. ycpp-0.1.0.data/headers/xsimd/types/xsimd_batch_fwd.hpp +41 -0
  112. ycpp-0.1.0.data/headers/xsimd/types/xsimd_common_arch.hpp +49 -0
  113. ycpp-0.1.0.data/headers/xsimd/types/xsimd_emulated_register.hpp +80 -0
  114. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_avx2_register.hpp +50 -0
  115. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_avx_register.hpp +50 -0
  116. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma3_sse_register.hpp +50 -0
  117. ycpp-0.1.0.data/headers/xsimd/types/xsimd_fma4_register.hpp +50 -0
  118. ycpp-0.1.0.data/headers/xsimd/types/xsimd_i8mm_neon64_register.hpp +55 -0
  119. ycpp-0.1.0.data/headers/xsimd/types/xsimd_neon64_register.hpp +55 -0
  120. ycpp-0.1.0.data/headers/xsimd/types/xsimd_neon_register.hpp +130 -0
  121. ycpp-0.1.0.data/headers/xsimd/types/xsimd_register.hpp +96 -0
  122. ycpp-0.1.0.data/headers/xsimd/types/xsimd_rvv_register.hpp +491 -0
  123. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse2_register.hpp +59 -0
  124. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse3_register.hpp +49 -0
  125. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse4_1_register.hpp +48 -0
  126. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sse4_2_register.hpp +48 -0
  127. ycpp-0.1.0.data/headers/xsimd/types/xsimd_ssse3_register.hpp +48 -0
  128. ycpp-0.1.0.data/headers/xsimd/types/xsimd_sve_register.hpp +216 -0
  129. ycpp-0.1.0.data/headers/xsimd/types/xsimd_traits.hpp +408 -0
  130. ycpp-0.1.0.data/headers/xsimd/types/xsimd_utils.hpp +462 -0
  131. ycpp-0.1.0.data/headers/xsimd/types/xsimd_vsx_register.hpp +77 -0
  132. ycpp-0.1.0.data/headers/xsimd/types/xsimd_vxe_register.hpp +86 -0
  133. ycpp-0.1.0.data/headers/xsimd/types/xsimd_wasm_register.hpp +59 -0
  134. ycpp-0.1.0.data/headers/xsimd/utils/bits.hpp +122 -0
  135. ycpp-0.1.0.data/headers/xsimd/utils/xsimd_type_traits.hpp +145 -0
  136. ycpp-0.1.0.data/headers/xsimd/xsimd.hpp +43 -0
  137. ycpp-0.1.0.dist-info/DELVEWHEEL +2 -0
  138. ycpp-0.1.0.dist-info/METADATA +15 -0
  139. ycpp-0.1.0.dist-info/RECORD +142 -0
  140. ycpp-0.1.0.dist-info/WHEEL +4 -0
  141. ycpp.libs/msvcp140-9cb625fcbc2fbbd6fca1aee8b24b0ebe.dll +0 -0
  142. ycpp.libs/msvcp140_1-84ac1bc84e09d193dd6ad98c84c0fd94.dll +0 -0
@@ -0,0 +1,1665 @@
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_BATCH_HPP
13
+ #define XSIMD_BATCH_HPP
14
+
15
+ #include <cassert>
16
+ #include <complex>
17
+
18
+ #include "../config/xsimd_arch.hpp"
19
+ #include "../config/xsimd_macros.hpp"
20
+ #include "../memory/xsimd_alignment.hpp"
21
+ #include "./xsimd_batch_fwd.hpp"
22
+ #include "./xsimd_utils.hpp"
23
+
24
+ namespace xsimd
25
+ {
26
+ namespace types
27
+ {
28
+ template <class T, class A>
29
+ struct integral_only_operators
30
+ {
31
+ XSIMD_INLINE batch<T, A>& operator%=(batch<T, A> const& other) noexcept;
32
+ XSIMD_INLINE batch<T, A>& operator>>=(int32_t other) noexcept;
33
+ XSIMD_INLINE batch<T, A>& operator>>=(batch<T, A> const& other) noexcept;
34
+ XSIMD_INLINE batch<T, A>& operator<<=(int32_t other) noexcept;
35
+ XSIMD_INLINE batch<T, A>& operator<<=(batch<T, A> const& other) noexcept;
36
+
37
+ /** Shorthand for xsimd::mod() */
38
+ friend XSIMD_INLINE batch<T, A> operator%(batch<T, A> const& self, batch<T, A> const& other) noexcept
39
+ {
40
+ return batch<T, A>(self) %= other;
41
+ }
42
+
43
+ /** Shorthand for xsimd::bitwise_rshift() */
44
+ friend XSIMD_INLINE batch<T, A> operator>>(batch<T, A> const& self, batch<T, A> const& other) noexcept
45
+ {
46
+ return batch<T, A>(self) >>= other;
47
+ }
48
+
49
+ /** Shorthand for xsimd::bitwise_lshift() */
50
+ friend XSIMD_INLINE batch<T, A> operator<<(batch<T, A> const& self, batch<T, A> const& other) noexcept
51
+ {
52
+ return batch<T, A>(self) <<= other;
53
+ }
54
+
55
+ /** Shorthand for xsimd::bitwise_rshift() */
56
+ friend XSIMD_INLINE batch<T, A> operator>>(batch<T, A> const& self, int32_t other) noexcept
57
+ {
58
+ return batch<T, A>(self) >>= other;
59
+ }
60
+
61
+ /** Shorthand for xsimd::bitwise_lshift() */
62
+ friend XSIMD_INLINE batch<T, A> operator<<(batch<T, A> const& self, int32_t other) noexcept
63
+ {
64
+ return batch<T, A>(self) <<= other;
65
+ }
66
+ };
67
+ template <class A>
68
+ struct integral_only_operators<float, A>
69
+ {
70
+ };
71
+ template <class A>
72
+ struct integral_only_operators<double, A>
73
+ {
74
+ };
75
+
76
+ }
77
+
78
+ namespace details
79
+ {
80
+ // These functions are forwarded declared here so that they can be used by friend functions
81
+ // with batch<T, A>. Their implementation must appear only once the
82
+ // kernel implementations have been included.
83
+ template <class T, class A>
84
+ XSIMD_INLINE batch_bool<T, A> eq(batch<T, A> const& self, batch<T, A> const& other) noexcept;
85
+
86
+ template <class T, class A>
87
+ XSIMD_INLINE batch_bool<T, A> neq(batch<T, A> const& self, batch<T, A> const& other) noexcept;
88
+
89
+ template <class T, class A>
90
+ XSIMD_INLINE batch_bool<T, A> ge(batch<T, A> const& self, batch<T, A> const& other) noexcept;
91
+
92
+ template <class T, class A>
93
+ XSIMD_INLINE batch_bool<T, A> le(batch<T, A> const& self, batch<T, A> const& other) noexcept;
94
+
95
+ template <class T, class A>
96
+ XSIMD_INLINE batch_bool<T, A> gt(batch<T, A> const& self, batch<T, A> const& other) noexcept;
97
+
98
+ template <class T, class A>
99
+ XSIMD_INLINE batch_bool<T, A> lt(batch<T, A> const& self, batch<T, A> const& other) noexcept;
100
+ }
101
+
102
+ /**
103
+ * @brief batch of integer or floating point values.
104
+ *
105
+ * Abstract representation of an SIMD register for floating point or integral
106
+ * value.
107
+ *
108
+ * @tparam T the type of the underlying values.
109
+ * @tparam A the architecture this batch is tied too.
110
+ **/
111
+ template <class T, class A>
112
+ class batch : public types::simd_register<T, A>, public types::integral_only_operators<T, A>
113
+ {
114
+ static_assert(!std::is_same<T, bool>::value, "use xsimd::batch_bool<T, A> instead of xsimd::batch<bool, A>");
115
+
116
+ public:
117
+ static constexpr std::size_t size = sizeof(types::simd_register<T, A>) / sizeof(T); ///< Number of scalar elements in this batch.
118
+
119
+ using value_type = T; ///< Type of the scalar elements within this batch.
120
+ using arch_type = A; ///< SIMD Architecture abstracted by this batch.
121
+ using register_type = typename types::simd_register<T, A>::register_type; ///< SIMD register type abstracted by this batch.
122
+ using batch_bool_type = batch_bool<T, A>; ///< Associated batch type used to represented logical operations on this batch.
123
+
124
+ // constructors
125
+ XSIMD_INLINE batch() = default; ///< Create a batch initialized with undefined values.
126
+ XSIMD_INLINE batch(T val) noexcept;
127
+ template <class... Ts>
128
+ XSIMD_INLINE batch(T val0, T val1, Ts... vals) noexcept;
129
+ XSIMD_INLINE explicit batch(batch_bool_type const& b) noexcept;
130
+ XSIMD_INLINE batch(register_type reg) noexcept;
131
+
132
+ template <class U>
133
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch broadcast(U val) noexcept;
134
+
135
+ // memory operators
136
+ template <class U>
137
+ XSIMD_INLINE void store_aligned(U* mem) const noexcept;
138
+ template <class U>
139
+ XSIMD_INLINE void store_unaligned(U* mem) const noexcept;
140
+ template <class U>
141
+ XSIMD_INLINE void store(U* mem, aligned_mode) const noexcept;
142
+ template <class U>
143
+ XSIMD_INLINE void store(U* mem, unaligned_mode) const noexcept;
144
+ template <class U>
145
+ XSIMD_INLINE void store(U* mem, stream_mode) const noexcept;
146
+
147
+ // Compile-time mask overloads
148
+ template <class U, bool... Values, class Mode = aligned_mode>
149
+ XSIMD_INLINE void store(U* mem, batch_bool_constant<T, A, Values...> mask, Mode) const noexcept;
150
+
151
+ template <class U>
152
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load_aligned(U const* mem) noexcept;
153
+ template <class U>
154
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load_unaligned(U const* mem) noexcept;
155
+ template <class U>
156
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load(U const* mem, aligned_mode) noexcept;
157
+ template <class U>
158
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load(U const* mem, unaligned_mode) noexcept;
159
+ // Compile-time mask overloads
160
+ template <class U, bool... Values, class Mode = aligned_mode>
161
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load(U const* mem, batch_bool_constant<T, A, Values...> mask, Mode = {}) noexcept;
162
+ template <class U>
163
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load(U const* mem, stream_mode) noexcept;
164
+
165
+ template <class U, class V>
166
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch gather(U const* src, batch<V, arch_type> const& index) noexcept;
167
+ template <class U, class V>
168
+ XSIMD_INLINE void scatter(U* dst, batch<V, arch_type> const& index) const noexcept;
169
+
170
+ XSIMD_INLINE T get(std::size_t i) const noexcept;
171
+
172
+ XSIMD_INLINE T first() const noexcept;
173
+
174
+ // comparison operators. Defined as friend to enable automatic
175
+ // conversion of parameters from scalar to batch, at the cost of using a
176
+ // proxy implementation from details::.
177
+ friend XSIMD_INLINE batch_bool<T, A> operator==(batch const& self, batch const& other) noexcept
178
+ {
179
+ return details::eq<T, A>(self, other);
180
+ }
181
+ friend XSIMD_INLINE batch_bool<T, A> operator!=(batch const& self, batch const& other) noexcept
182
+ {
183
+ return details::neq<T, A>(self, other);
184
+ }
185
+ friend XSIMD_INLINE batch_bool<T, A> operator>=(batch const& self, batch const& other) noexcept
186
+ {
187
+ return details::ge<T, A>(self, other);
188
+ }
189
+ friend XSIMD_INLINE batch_bool<T, A> operator<=(batch const& self, batch const& other) noexcept
190
+ {
191
+ return details::le<T, A>(self, other);
192
+ }
193
+ friend XSIMD_INLINE batch_bool<T, A> operator>(batch const& self, batch const& other) noexcept
194
+ {
195
+ return details::gt<T, A>(self, other);
196
+ }
197
+ friend XSIMD_INLINE batch_bool<T, A> operator<(batch const& self, batch const& other) noexcept
198
+ {
199
+ return details::lt<T, A>(self, other);
200
+ }
201
+
202
+ // Update operators
203
+ XSIMD_INLINE batch& operator+=(batch const& other) noexcept;
204
+ XSIMD_INLINE batch& operator-=(batch const& other) noexcept;
205
+ XSIMD_INLINE batch& operator*=(batch const& other) noexcept;
206
+ XSIMD_INLINE batch& operator/=(batch const& other) noexcept;
207
+ XSIMD_INLINE batch& operator&=(batch const& other) noexcept;
208
+ XSIMD_INLINE batch& operator|=(batch const& other) noexcept;
209
+ XSIMD_INLINE batch& operator^=(batch const& other) noexcept;
210
+
211
+ // incr/decr operators
212
+ XSIMD_INLINE batch& operator++() noexcept;
213
+ XSIMD_INLINE batch& operator--() noexcept;
214
+ XSIMD_INLINE batch operator++(int) noexcept;
215
+ XSIMD_INLINE batch operator--(int) noexcept;
216
+
217
+ // unary operators
218
+ XSIMD_INLINE batch_bool_type operator!() const noexcept;
219
+ XSIMD_INLINE batch operator~() const noexcept;
220
+ XSIMD_INLINE batch operator-() const noexcept;
221
+ XSIMD_INLINE batch operator+() const noexcept;
222
+
223
+ // arithmetic operators. They are defined as friend to enable automatic
224
+ // conversion of parameters from scalar to batch. Inline implementation
225
+ // is required to avoid warnings.
226
+
227
+ /** Shorthand for xsimd::add() */
228
+ friend XSIMD_INLINE batch operator+(batch const& self, batch const& other) noexcept
229
+ {
230
+ return batch(self) += other;
231
+ }
232
+
233
+ /** Shorthand for xsimd::sub() */
234
+ friend XSIMD_INLINE batch operator-(batch const& self, batch const& other) noexcept
235
+ {
236
+ return batch(self) -= other;
237
+ }
238
+
239
+ /** Shorthand for xsimd::mul() */
240
+ friend XSIMD_INLINE batch operator*(batch const& self, batch const& other) noexcept
241
+ {
242
+ return batch(self) *= other;
243
+ }
244
+
245
+ /** Shorthand for xsimd::div() */
246
+ friend XSIMD_INLINE batch operator/(batch const& self, batch const& other) noexcept
247
+ {
248
+ return batch(self) /= other;
249
+ }
250
+
251
+ /** Shorthand for xsimd::bitwise_and() */
252
+ friend XSIMD_INLINE batch operator&(batch const& self, batch const& other) noexcept
253
+ {
254
+ return batch(self) &= other;
255
+ }
256
+
257
+ /** Shorthand for xsimd::bitwise_or() */
258
+ friend XSIMD_INLINE batch operator|(batch const& self, batch const& other) noexcept
259
+ {
260
+ return batch(self) |= other;
261
+ }
262
+
263
+ /** Shorthand for xsimd::bitwise_xor() */
264
+ friend XSIMD_INLINE batch operator^(batch const& self, batch const& other) noexcept
265
+ {
266
+ return batch(self) ^= other;
267
+ }
268
+
269
+ /** Shorthand for xsimd::logical_and() */
270
+ friend XSIMD_INLINE batch operator&&(batch const& self, batch const& other) noexcept
271
+ {
272
+ return batch(self).logical_and(other);
273
+ }
274
+
275
+ /** Shorthand for xsimd::logical_or() */
276
+ friend XSIMD_INLINE batch operator||(batch const& self, batch const& other) noexcept
277
+ {
278
+ return batch(self).logical_or(other);
279
+ }
280
+
281
+ private:
282
+ XSIMD_INLINE batch logical_and(batch const& other) const noexcept;
283
+ XSIMD_INLINE batch logical_or(batch const& other) const noexcept;
284
+ };
285
+
286
+ #if __cplusplus < 201703L
287
+ template <class T, class A>
288
+ constexpr std::size_t batch<T, A>::size;
289
+ #endif
290
+
291
+ /**
292
+ * @brief batch of predicate over scalar or complex values.
293
+ *
294
+ * Abstract representation of a predicate over SIMD register for scalar or
295
+ * complex values.
296
+ *
297
+ * @tparam T the type of the predicated values.
298
+ * @tparam A the architecture this batch is tied too.
299
+ **/
300
+ template <class T, class A>
301
+ class batch_bool : public types::get_bool_simd_register_t<T, A>
302
+ {
303
+ using base_type = types::get_bool_simd_register_t<T, A>;
304
+
305
+ public:
306
+ static constexpr std::size_t size = sizeof(types::simd_register<T, A>) / sizeof(T); ///< Number of scalar elements in this batch.
307
+
308
+ using value_type = bool; ///< Type of the scalar elements within this batch.
309
+ using operand_type = T;
310
+ using arch_type = A; ///< SIMD Architecture abstracted by this batch.
311
+ using register_type = typename base_type::register_type; ///< SIMD register type abstracted by this batch.
312
+ using batch_type = batch<T, A>; ///< Associated batch type this batch represents logical operations for.
313
+
314
+ // constructors
315
+ XSIMD_INLINE batch_bool() = default; ///< Create a batch initialized with undefined values.
316
+ XSIMD_INLINE batch_bool(bool val) noexcept;
317
+ XSIMD_INLINE batch_bool(register_type reg) noexcept;
318
+ template <class... Ts>
319
+ XSIMD_INLINE batch_bool(bool val0, bool val1, Ts... vals) noexcept;
320
+
321
+ template <class Tp>
322
+ XSIMD_INLINE batch_bool(Tp const*) = delete;
323
+
324
+ // memory operators
325
+ XSIMD_INLINE void store_aligned(bool* mem) const noexcept;
326
+ XSIMD_INLINE void store_unaligned(bool* mem) const noexcept;
327
+ XSIMD_INLINE void store_stream(bool* mem) const noexcept;
328
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch_bool load_aligned(bool const* mem) noexcept;
329
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch_bool load_unaligned(bool const* mem) noexcept;
330
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch_bool load_stream(bool const* mem) noexcept;
331
+
332
+ XSIMD_INLINE bool get(std::size_t i) const noexcept;
333
+
334
+ XSIMD_INLINE bool first() const noexcept;
335
+
336
+ // mask operations
337
+ XSIMD_INLINE uint64_t mask() const noexcept;
338
+ XSIMD_INLINE static batch_bool from_mask(uint64_t mask) noexcept;
339
+
340
+ // comparison operators
341
+ XSIMD_INLINE batch_bool operator==(batch_bool const& other) const noexcept;
342
+ XSIMD_INLINE batch_bool operator!=(batch_bool const& other) const noexcept;
343
+
344
+ // logical operators
345
+ XSIMD_INLINE batch_bool operator~() const noexcept;
346
+ XSIMD_INLINE batch_bool operator!() const noexcept;
347
+ XSIMD_INLINE batch_bool operator&(batch_bool const& other) const noexcept;
348
+ XSIMD_INLINE batch_bool operator|(batch_bool const& other) const noexcept;
349
+ XSIMD_INLINE batch_bool operator^(batch_bool const& other) const noexcept;
350
+ XSIMD_INLINE batch_bool operator&&(batch_bool const& other) const noexcept;
351
+ XSIMD_INLINE batch_bool operator||(batch_bool const& other) const noexcept;
352
+
353
+ // update operators
354
+ XSIMD_INLINE batch_bool& operator&=(batch_bool const& other) noexcept { return (*this) = (*this) & other; }
355
+ XSIMD_INLINE batch_bool& operator|=(batch_bool const& other) noexcept { return (*this) = (*this) | other; }
356
+ XSIMD_INLINE batch_bool& operator^=(batch_bool const& other) noexcept { return (*this) = (*this) ^ other; }
357
+
358
+ private:
359
+ template <class U, class... V, size_t I, size_t... Is>
360
+ static XSIMD_INLINE register_type make_register(std::index_sequence<I, Is...>, U u, V... v) noexcept;
361
+
362
+ template <class... V>
363
+ static XSIMD_INLINE register_type make_register(std::index_sequence<>, V... v) noexcept;
364
+ };
365
+
366
+ #if __cplusplus < 201703L
367
+ template <class T, class A>
368
+ constexpr std::size_t batch_bool<T, A>::size;
369
+ #endif
370
+
371
+ /**
372
+ * @brief batch of complex values.
373
+ *
374
+ * Abstract representation of an SIMD register for complex values.
375
+ *
376
+ * @tparam T the type of the underlying values.
377
+ * @tparam A the architecture this batch is tied too.
378
+ **/
379
+ template <class T, class A>
380
+ class batch<std::complex<T>, A>
381
+ {
382
+ public:
383
+ using value_type = std::complex<T>; ///< Type of the complex elements within this batch.
384
+ using real_batch = batch<T, A>; ///< Type of the scalar elements within this batch.
385
+ using arch_type = A; ///< SIMD Architecture abstracted by this batch.
386
+ using batch_bool_type = batch_bool<T, A>; ///< Associated batch type used to represented logical operations on this batch.
387
+
388
+ static constexpr std::size_t size = real_batch::size; ///< Number of complex elements in this batch.
389
+
390
+ // constructors
391
+ XSIMD_INLINE batch() = default; ///< Create a batch initialized with undefined values.
392
+ XSIMD_INLINE batch(value_type const& val) noexcept;
393
+ XSIMD_INLINE batch(real_batch const& real, real_batch const& imag) noexcept;
394
+
395
+ XSIMD_INLINE batch(real_batch const& real) noexcept;
396
+ XSIMD_INLINE batch(T val) noexcept;
397
+ template <class... Ts>
398
+ XSIMD_INLINE batch(value_type val0, value_type val1, Ts... vals) noexcept;
399
+ XSIMD_INLINE explicit batch(batch_bool_type const& b) noexcept;
400
+
401
+ template <class U>
402
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch broadcast(U val) noexcept;
403
+
404
+ // memory operators
405
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load_aligned(const T* real_src, const T* imag_src = nullptr) noexcept;
406
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load_unaligned(const T* real_src, const T* imag_src = nullptr) noexcept;
407
+ XSIMD_INLINE void store_aligned(T* real_dst, T* imag_dst) const noexcept;
408
+ XSIMD_INLINE void store_unaligned(T* real_dst, T* imag_dst) const noexcept;
409
+
410
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load_aligned(const value_type* src) noexcept;
411
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load_unaligned(const value_type* src) noexcept;
412
+ XSIMD_INLINE void store_aligned(value_type* dst) const noexcept;
413
+ XSIMD_INLINE void store_unaligned(value_type* dst) const noexcept;
414
+
415
+ template <class U>
416
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load(U const* mem, aligned_mode) noexcept;
417
+ template <class U>
418
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load(U const* mem, unaligned_mode) noexcept;
419
+ // Compile-time mask overloads
420
+ template <class U, bool... Values, class Mode = aligned_mode>
421
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load(U const* mem, batch_bool_constant<value_type, A, Values...> mask, Mode = {}) noexcept;
422
+ template <class U>
423
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load(U const* mem, stream_mode) noexcept;
424
+ template <class U>
425
+ XSIMD_INLINE void store(U* mem, aligned_mode) const noexcept;
426
+ template <class U>
427
+ XSIMD_INLINE void store(U* mem, unaligned_mode) const noexcept;
428
+ // Compile-time mask overloads
429
+ template <class U, bool... Values, class Mode = aligned_mode>
430
+ XSIMD_INLINE void store(U* mem, batch_bool_constant<value_type, A, Values...> mask, Mode = {}) const noexcept;
431
+ template <class U>
432
+ XSIMD_INLINE void store(U* mem, stream_mode) const noexcept;
433
+
434
+ XSIMD_INLINE real_batch real() const noexcept;
435
+ XSIMD_INLINE real_batch imag() const noexcept;
436
+
437
+ XSIMD_INLINE value_type get(std::size_t i) const noexcept;
438
+
439
+ XSIMD_INLINE value_type first() const noexcept;
440
+
441
+ #ifdef XSIMD_ENABLE_XTL_COMPLEX
442
+ // xtl-related methods
443
+ template <bool i3ec>
444
+ XSIMD_INLINE batch(xtl::xcomplex<T, T, i3ec> const& val) noexcept;
445
+ template <bool i3ec, class... Ts>
446
+ XSIMD_INLINE batch(xtl::xcomplex<T, T, i3ec> val0, xtl::xcomplex<T, T, i3ec> val1, Ts... vals) noexcept;
447
+
448
+ template <bool i3ec>
449
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load_aligned(const xtl::xcomplex<T, T, i3ec>* src) noexcept;
450
+ template <bool i3ec>
451
+ XSIMD_NO_DISCARD static XSIMD_INLINE batch load_unaligned(const xtl::xcomplex<T, T, i3ec>* src) noexcept;
452
+ template <bool i3ec>
453
+ XSIMD_INLINE void store_aligned(xtl::xcomplex<T, T, i3ec>* dst) const noexcept;
454
+ template <bool i3ec>
455
+ XSIMD_INLINE void store_unaligned(xtl::xcomplex<T, T, i3ec>* dst) const noexcept;
456
+ #endif
457
+
458
+ // comparison operators
459
+ XSIMD_INLINE batch_bool<T, A> operator==(batch const& other) const noexcept;
460
+ XSIMD_INLINE batch_bool<T, A> operator!=(batch const& other) const noexcept;
461
+
462
+ // Update operators
463
+ XSIMD_INLINE batch& operator+=(batch const& other) noexcept;
464
+ XSIMD_INLINE batch& operator-=(batch const& other) noexcept;
465
+ XSIMD_INLINE batch& operator*=(batch const& other) noexcept;
466
+ XSIMD_INLINE batch& operator/=(batch const& other) noexcept;
467
+
468
+ // incr/decr operators
469
+ XSIMD_INLINE batch& operator++() noexcept;
470
+ XSIMD_INLINE batch& operator--() noexcept;
471
+ XSIMD_INLINE batch operator++(int) noexcept;
472
+ XSIMD_INLINE batch operator--(int) noexcept;
473
+
474
+ // unary operators
475
+ XSIMD_INLINE batch_bool_type operator!() const noexcept;
476
+ XSIMD_INLINE batch operator~() const noexcept;
477
+ XSIMD_INLINE batch operator-() const noexcept;
478
+ XSIMD_INLINE batch operator+() const noexcept;
479
+
480
+ // arithmetic operators. They are defined as friend to enable automatic
481
+ // conversion of parameters from scalar to batch
482
+
483
+ /** Shorthand for xsimd::add() */
484
+ friend XSIMD_INLINE batch operator+(batch const& self, batch const& other) noexcept
485
+ {
486
+ return batch(self) += other;
487
+ }
488
+
489
+ /** Shorthand for xsimd::sub() */
490
+ friend XSIMD_INLINE batch operator-(batch const& self, batch const& other) noexcept
491
+ {
492
+ return batch(self) -= other;
493
+ }
494
+
495
+ /** Shorthand for xsimd::mul() */
496
+ friend XSIMD_INLINE batch operator*(batch const& self, batch const& other) noexcept
497
+ {
498
+ return batch(self) *= other;
499
+ }
500
+
501
+ /** Shorthand for xsimd::div() */
502
+ friend XSIMD_INLINE batch operator/(batch const& self, batch const& other) noexcept
503
+ {
504
+ return batch(self) /= other;
505
+ }
506
+
507
+ private:
508
+ real_batch m_real;
509
+ real_batch m_imag;
510
+ };
511
+
512
+ #if __cplusplus < 201703L
513
+ template <class T, class A>
514
+ constexpr std::size_t batch<std::complex<T>, A>::size;
515
+ #endif
516
+
517
+ #ifdef XSIMD_ENABLE_XTL_COMPLEX
518
+ template <typename T, bool i3ec, typename A>
519
+ struct batch<xtl::xcomplex<T, T, i3ec>, A>
520
+ {
521
+ static_assert(std::is_same<T, void>::value,
522
+ "Please use batch<std::complex<T>, A> initialized from xtl::xcomplex instead");
523
+ };
524
+ #endif
525
+ }
526
+
527
+ #include "../arch/xsimd_isa.hpp"
528
+ #include "./xsimd_batch_constant.hpp"
529
+ #include "./xsimd_traits.hpp"
530
+
531
+ namespace xsimd
532
+ {
533
+
534
+ /**
535
+ * Create a batch with all element initialized to \c val.
536
+ */
537
+ template <class T, class A>
538
+ XSIMD_INLINE batch<T, A>::batch(T val) noexcept
539
+ : types::simd_register<T, A>(kernel::broadcast<A>(val, A {}))
540
+ {
541
+ detail::static_check_supported_config<T, A>();
542
+ }
543
+
544
+ /**
545
+ * Create a batch with elements initialized from \c val0, \c val1, \c vals...
546
+ * There must be exactly \c size elements in total.
547
+ */
548
+ template <class T, class A>
549
+ template <class... Ts>
550
+ XSIMD_INLINE batch<T, A>::batch(T val0, T val1, Ts... vals) noexcept
551
+ : batch(kernel::set<A>(batch {}, A {}, val0, val1, static_cast<T>(vals)...))
552
+ {
553
+ detail::static_check_supported_config<T, A>();
554
+ static_assert(sizeof...(Ts) + 2 == size, "The constructor requires as many arguments as batch elements.");
555
+ }
556
+
557
+ /**
558
+ * Converts a \c bool_batch to a \c batch where each element is
559
+ * set to 1 (resp. 0) if the corresponding element is `true`
560
+ * (resp. `false`).
561
+ */
562
+ template <class T, class A>
563
+ XSIMD_INLINE batch<T, A>::batch(batch_bool<T, A> const& b) noexcept
564
+ : batch(kernel::from_bool(b, A {}))
565
+ {
566
+ }
567
+
568
+ /**
569
+ * Wraps a compatible native simd register as a \c batch. This is generally not needed but
570
+ * becomes handy when doing architecture-specific operations.
571
+ */
572
+ template <class T, class A>
573
+ XSIMD_INLINE batch<T, A>::batch(register_type reg) noexcept
574
+ : types::simd_register<T, A>({ reg })
575
+ {
576
+ detail::static_check_supported_config<T, A>();
577
+ }
578
+
579
+ /**
580
+ * Equivalent to batch::batch(T val).
581
+ */
582
+ template <class T, class A>
583
+ template <class U>
584
+ XSIMD_NO_DISCARD XSIMD_INLINE batch<T, A> batch<T, A>::broadcast(U val) noexcept
585
+ {
586
+ detail::static_check_supported_config<T, A>();
587
+ return batch(static_cast<T>(val));
588
+ }
589
+
590
+ /**************************
591
+ * batch memory operators *
592
+ **************************/
593
+
594
+ /**
595
+ * Copy content of this batch to the buffer \c mem. The
596
+ * memory needs to be aligned.
597
+ */
598
+ template <class T, class A>
599
+ template <class U>
600
+ XSIMD_INLINE void batch<T, A>::store_aligned(U* mem) const noexcept
601
+ {
602
+ detail::static_check_supported_config<T, A>();
603
+ assert(((reinterpret_cast<uintptr_t>(mem) % A::alignment()) == 0)
604
+ && "store location is not properly aligned");
605
+ kernel::store_aligned<A>(mem, *this, A {});
606
+ }
607
+
608
+ /**
609
+ * Copy content of this batch to the buffer \c mem. The
610
+ * memory does not need to be aligned.
611
+ */
612
+ template <class T, class A>
613
+ template <class U>
614
+ XSIMD_INLINE void batch<T, A>::store_unaligned(U* mem) const noexcept
615
+ {
616
+ detail::static_check_supported_config<T, A>();
617
+ kernel::store_unaligned<A>(mem, *this, A {});
618
+ }
619
+
620
+ /**
621
+ * Equivalent to batch::store_aligned()
622
+ */
623
+ template <class T, class A>
624
+ template <class U>
625
+ XSIMD_INLINE void batch<T, A>::store(U* mem, aligned_mode) const noexcept
626
+ {
627
+ detail::static_check_supported_config<T, A>();
628
+ return store_aligned(mem);
629
+ }
630
+
631
+ /**
632
+ * Equivalent to batch::store_unaligned()
633
+ */
634
+ template <class T, class A>
635
+ template <class U>
636
+ XSIMD_INLINE void batch<T, A>::store(U* mem, unaligned_mode) const noexcept
637
+ {
638
+ detail::static_check_supported_config<T, A>();
639
+ return store_unaligned(mem);
640
+ }
641
+
642
+ // masked store free functions are provided in xsimd_api.hpp
643
+
644
+ template <class T, class A>
645
+ template <class U>
646
+ XSIMD_INLINE void batch<T, A>::store(U* mem, stream_mode) const noexcept
647
+ {
648
+ detail::static_check_supported_config<T, A>();
649
+ assert(((reinterpret_cast<uintptr_t>(mem) % A::alignment()) == 0)
650
+ && "store location is not properly aligned");
651
+ kernel::store_stream<A>(mem, *this, A {});
652
+ }
653
+
654
+ /**
655
+ * Loading from aligned memory. May involve a conversion if \c U is different
656
+ * from \c T.
657
+ */
658
+ template <class T, class A>
659
+ template <class U>
660
+ XSIMD_INLINE batch<T, A> batch<T, A>::load_aligned(U const* mem) noexcept
661
+ {
662
+ assert(((reinterpret_cast<uintptr_t>(mem) % A::alignment()) == 0)
663
+ && "loaded pointer is not properly aligned");
664
+ detail::static_check_supported_config<T, A>();
665
+ return kernel::load_aligned<A>(mem, kernel::convert<T> {}, A {});
666
+ }
667
+
668
+ /**
669
+ * Loading from unaligned memory. May involve a conversion if \c U is different
670
+ * from \c T.
671
+ */
672
+ template <class T, class A>
673
+ template <class U>
674
+ XSIMD_INLINE batch<T, A> batch<T, A>::load_unaligned(U const* mem) noexcept
675
+ {
676
+ detail::static_check_supported_config<T, A>();
677
+ return kernel::load_unaligned<A>(mem, kernel::convert<T> {}, A {});
678
+ }
679
+
680
+ /**
681
+ * Equivalent to batch::load_aligned()
682
+ */
683
+ template <class T, class A>
684
+ template <class U>
685
+ XSIMD_INLINE batch<T, A> batch<T, A>::load(U const* mem, aligned_mode) noexcept
686
+ {
687
+ detail::static_check_supported_config<T, A>();
688
+ return load_aligned(mem);
689
+ }
690
+
691
+ /**
692
+ * Equivalent to batch::load_unaligned()
693
+ */
694
+ template <class T, class A>
695
+ template <class U>
696
+ XSIMD_INLINE batch<T, A> batch<T, A>::load(U const* mem, unaligned_mode) noexcept
697
+ {
698
+ detail::static_check_supported_config<T, A>();
699
+ return load_unaligned(mem);
700
+ }
701
+
702
+ template <class T, class A>
703
+ template <class U, bool... Values, class Mode>
704
+ XSIMD_INLINE batch<T, A> batch<T, A>::load(U const* mem,
705
+ batch_bool_constant<T, A, Values...> mask,
706
+ Mode mode) noexcept
707
+ {
708
+ detail::static_check_supported_config<T, A>();
709
+ static_assert(std::is_same<Mode, aligned_mode>::value || std::is_same<Mode, unaligned_mode>::value,
710
+ "supported load mode");
711
+ XSIMD_IF_CONSTEXPR(mask.all())
712
+ {
713
+ return load(mem, mode);
714
+ }
715
+ else XSIMD_IF_CONSTEXPR(mask.none())
716
+ {
717
+ return broadcast<T>(0);
718
+ }
719
+ else
720
+ {
721
+ return kernel::load_masked<A>(mem, mask, kernel::convert<T> {}, mode, A {});
722
+ }
723
+ }
724
+
725
+ template <class T, class A>
726
+ template <class U, bool... Values, class Mode>
727
+ XSIMD_INLINE void batch<T, A>::store(U* mem,
728
+ batch_bool_constant<T, A, Values...> mask,
729
+ Mode mode) const noexcept
730
+ {
731
+ detail::static_check_supported_config<T, A>();
732
+ static_assert(std::is_same<Mode, aligned_mode>::value || std::is_same<Mode, unaligned_mode>::value,
733
+ "supported store mode");
734
+ XSIMD_IF_CONSTEXPR(mask.none())
735
+ {
736
+ return;
737
+ }
738
+ else XSIMD_IF_CONSTEXPR(mask.all())
739
+ {
740
+ store(mem, mode);
741
+ }
742
+ else
743
+ {
744
+ kernel::store_masked<A, T, U, Values...>(mem, *this, mask, mode, A {});
745
+ }
746
+ }
747
+
748
+ template <class T, class A>
749
+ template <class U>
750
+ XSIMD_INLINE batch<T, A> batch<T, A>::load(U const* mem, stream_mode) noexcept
751
+ {
752
+ detail::static_check_supported_config<T, A>();
753
+ assert(((reinterpret_cast<uintptr_t>(mem) % A::alignment()) == 0)
754
+ && "loaded pointer is not properly aligned");
755
+ return kernel::load_stream<A>(mem, kernel::convert<T> {}, A {});
756
+ }
757
+
758
+ /**
759
+ * Create a new batch gathering elements starting at address \c src and
760
+ * offset by each element in \c index.
761
+ * If \c T is not of the same size as \c U, a \c static_cast is performed
762
+ * at element gather time.
763
+ */
764
+ template <class T, class A>
765
+ template <typename U, typename V>
766
+ XSIMD_INLINE batch<T, A> batch<T, A>::gather(U const* src, batch<V, A> const& index) noexcept
767
+ {
768
+ detail::static_check_supported_config<T, A>();
769
+ static_assert(std::is_convertible<T, U>::value, "Can't convert from src to this batch's type!");
770
+ return kernel::gather(batch {}, src, index, A {});
771
+ }
772
+
773
+ /**
774
+ * Scatter elements from this batch into addresses starting at \c dst
775
+ * and offset by each element in \c index.
776
+ * If \c T is not of the same size as \c U, a \c static_cast is performed
777
+ * at element scatter time.
778
+ */
779
+ template <class T, class A>
780
+ template <class U, class V>
781
+ XSIMD_INLINE void batch<T, A>::scatter(U* dst, batch<V, A> const& index) const noexcept
782
+ {
783
+ detail::static_check_supported_config<T, A>();
784
+ static_assert(std::is_convertible<T, U>::value, "Can't convert from this batch's type to dst!");
785
+ kernel::scatter<A>(*this, dst, index, A {});
786
+ }
787
+
788
+ /**
789
+ * Retrieve the \c i th scalar element in this batch.
790
+ *
791
+ * \c warning This is very inefficient and should only be used for debugging purpose.
792
+ */
793
+ template <class T, class A>
794
+ XSIMD_INLINE T batch<T, A>::get(std::size_t i) const noexcept
795
+ {
796
+ return kernel::get(*this, i, A {});
797
+ }
798
+
799
+ /**
800
+ * Retrieve the first scalar element in this batch.
801
+ */
802
+ template <class T, class A>
803
+ XSIMD_INLINE T batch<T, A>::first() const noexcept
804
+ {
805
+ detail::static_check_supported_config<T, A>();
806
+ return kernel::first(*this, A {});
807
+ }
808
+
809
+ /******************************
810
+ * batch comparison operators *
811
+ ******************************/
812
+ namespace details
813
+ {
814
+ /**
815
+ * Shorthand for xsimd::eq()
816
+ */
817
+ template <class T, class A>
818
+ XSIMD_INLINE batch_bool<T, A> eq(batch<T, A> const& self, batch<T, A> const& other) noexcept
819
+ {
820
+ detail::static_check_supported_config<T, A>();
821
+ return kernel::eq<A>(self, other, A {});
822
+ }
823
+
824
+ /**
825
+ * Shorthand for xsimd::neq()
826
+ */
827
+ template <class T, class A>
828
+ XSIMD_INLINE batch_bool<T, A> neq(batch<T, A> const& self, batch<T, A> const& other) noexcept
829
+ {
830
+ detail::static_check_supported_config<T, A>();
831
+ return kernel::neq<A>(self, other, A {});
832
+ }
833
+
834
+ /**
835
+ * Shorthand for xsimd::ge()
836
+ */
837
+ template <class T, class A>
838
+ XSIMD_INLINE batch_bool<T, A> ge(batch<T, A> const& self, batch<T, A> const& other) noexcept
839
+ {
840
+ detail::static_check_supported_config<T, A>();
841
+ return kernel::ge<A>(self, other, A {});
842
+ }
843
+
844
+ /**
845
+ * Shorthand for xsimd::le()
846
+ */
847
+ template <class T, class A>
848
+ XSIMD_INLINE batch_bool<T, A> le(batch<T, A> const& self, batch<T, A> const& other) noexcept
849
+ {
850
+ detail::static_check_supported_config<T, A>();
851
+ return kernel::le<A>(self, other, A {});
852
+ }
853
+
854
+ /**
855
+ * Shorthand for xsimd::gt()
856
+ */
857
+ template <class T, class A>
858
+ XSIMD_INLINE batch_bool<T, A> gt(batch<T, A> const& self, batch<T, A> const& other) noexcept
859
+ {
860
+ detail::static_check_supported_config<T, A>();
861
+ return kernel::gt<A>(self, other, A {});
862
+ }
863
+
864
+ /**
865
+ * Shorthand for xsimd::lt()
866
+ */
867
+ template <class T, class A>
868
+ XSIMD_INLINE batch_bool<T, A> lt(batch<T, A> const& self, batch<T, A> const& other) noexcept
869
+ {
870
+ detail::static_check_supported_config<T, A>();
871
+ return kernel::lt<A>(self, other, A {});
872
+ }
873
+ }
874
+
875
+ /**************************
876
+ * batch update operators *
877
+ **************************/
878
+
879
+ template <class T, class A>
880
+ XSIMD_INLINE batch<T, A>& batch<T, A>::operator+=(batch<T, A> const& other) noexcept
881
+ {
882
+ detail::static_check_supported_config<T, A>();
883
+ return *this = kernel::add<A>(*this, other, A {});
884
+ }
885
+
886
+ template <class T, class A>
887
+ XSIMD_INLINE batch<T, A>& batch<T, A>::operator-=(batch<T, A> const& other) noexcept
888
+ {
889
+ detail::static_check_supported_config<T, A>();
890
+ return *this = kernel::sub<A>(*this, other, A {});
891
+ }
892
+
893
+ template <class T, class A>
894
+ XSIMD_INLINE batch<T, A>& batch<T, A>::operator*=(batch<T, A> const& other) noexcept
895
+ {
896
+ detail::static_check_supported_config<T, A>();
897
+ return *this = kernel::mul<A>(*this, other, A {});
898
+ }
899
+
900
+ template <class T, class A>
901
+ XSIMD_INLINE batch<T, A>& batch<T, A>::operator/=(batch<T, A> const& other) noexcept
902
+ {
903
+ detail::static_check_supported_config<T, A>();
904
+ return *this = kernel::div<A>(*this, other, A {});
905
+ }
906
+
907
+ template <class T, class A>
908
+ XSIMD_INLINE batch<T, A>& types::integral_only_operators<T, A>::operator%=(batch<T, A> const& other) noexcept
909
+ {
910
+ ::xsimd::detail::static_check_supported_config<T, A>();
911
+ return *static_cast<batch<T, A>*>(this) = kernel::mod<A>(*static_cast<batch<T, A>*>(this), other, A {});
912
+ }
913
+
914
+ template <class T, class A>
915
+ XSIMD_INLINE batch<T, A>& batch<T, A>::operator&=(batch<T, A> const& other) noexcept
916
+ {
917
+ detail::static_check_supported_config<T, A>();
918
+ return *this = kernel::bitwise_and<A>(*this, other, A {});
919
+ }
920
+
921
+ template <class T, class A>
922
+ XSIMD_INLINE batch<T, A>& batch<T, A>::operator|=(batch<T, A> const& other) noexcept
923
+ {
924
+ detail::static_check_supported_config<T, A>();
925
+ return *this = kernel::bitwise_or<A>(*this, other, A {});
926
+ }
927
+
928
+ template <class T, class A>
929
+ XSIMD_INLINE batch<T, A>& batch<T, A>::operator^=(batch<T, A> const& other) noexcept
930
+ {
931
+ detail::static_check_supported_config<T, A>();
932
+ return *this = kernel::bitwise_xor<A>(*this, other, A {});
933
+ }
934
+
935
+ template <class T, class A>
936
+ XSIMD_INLINE batch<T, A>& kernel::integral_only_operators<T, A>::operator>>=(batch<T, A> const& other) noexcept
937
+ {
938
+ ::xsimd::detail::static_check_supported_config<T, A>();
939
+ return *static_cast<batch<T, A>*>(this) = kernel::bitwise_rshift<A>(*static_cast<batch<T, A>*>(this), other, A {});
940
+ }
941
+
942
+ template <class T, class A>
943
+ XSIMD_INLINE batch<T, A>& kernel::integral_only_operators<T, A>::operator<<=(batch<T, A> const& other) noexcept
944
+ {
945
+ ::xsimd::detail::static_check_supported_config<T, A>();
946
+ return *static_cast<batch<T, A>*>(this) = kernel::bitwise_lshift<A>(*static_cast<batch<T, A>*>(this), other, A {});
947
+ }
948
+
949
+ template <class T, class A>
950
+ XSIMD_INLINE batch<T, A>& kernel::integral_only_operators<T, A>::operator>>=(int32_t other) noexcept
951
+ {
952
+ ::xsimd::detail::static_check_supported_config<T, A>();
953
+ return *static_cast<batch<T, A>*>(this) = kernel::bitwise_rshift<A>(*static_cast<batch<T, A>*>(this), other, A {});
954
+ }
955
+
956
+ template <class T, class A>
957
+ XSIMD_INLINE batch<T, A>& kernel::integral_only_operators<T, A>::operator<<=(int32_t other) noexcept
958
+ {
959
+ ::xsimd::detail::static_check_supported_config<T, A>();
960
+ return *static_cast<batch<T, A>*>(this) = kernel::bitwise_lshift<A>(*static_cast<batch<T, A>*>(this), other, A {});
961
+ }
962
+
963
+ /*****************************
964
+ * batch incr/decr operators *
965
+ *****************************/
966
+
967
+ template <class T, class A>
968
+ XSIMD_INLINE batch<T, A>& batch<T, A>::operator++() noexcept
969
+ {
970
+ detail::static_check_supported_config<T, A>();
971
+ return operator+=(1);
972
+ }
973
+
974
+ template <class T, class A>
975
+ XSIMD_INLINE batch<T, A>& batch<T, A>::operator--() noexcept
976
+ {
977
+ detail::static_check_supported_config<T, A>();
978
+ return operator-=(1);
979
+ }
980
+
981
+ template <class T, class A>
982
+ XSIMD_INLINE batch<T, A> batch<T, A>::operator++(int) noexcept
983
+ {
984
+ detail::static_check_supported_config<T, A>();
985
+ batch<T, A> copy(*this);
986
+ operator+=(1);
987
+ return copy;
988
+ }
989
+
990
+ template <class T, class A>
991
+ XSIMD_INLINE batch<T, A> batch<T, A>::operator--(int) noexcept
992
+ {
993
+ detail::static_check_supported_config<T, A>();
994
+ batch copy(*this);
995
+ operator-=(1);
996
+ return copy;
997
+ }
998
+
999
+ /*************************
1000
+ * batch unary operators *
1001
+ *************************/
1002
+
1003
+ template <class T, class A>
1004
+ XSIMD_INLINE batch_bool<T, A> batch<T, A>::operator!() const noexcept
1005
+ {
1006
+ detail::static_check_supported_config<T, A>();
1007
+ return kernel::eq<A>(*this, batch(0), A {});
1008
+ }
1009
+
1010
+ template <class T, class A>
1011
+ XSIMD_INLINE batch<T, A> batch<T, A>::operator~() const noexcept
1012
+ {
1013
+ detail::static_check_supported_config<T, A>();
1014
+ return kernel::bitwise_not<A>(*this, A {});
1015
+ }
1016
+
1017
+ template <class T, class A>
1018
+ XSIMD_INLINE batch<T, A> batch<T, A>::operator-() const noexcept
1019
+ {
1020
+ detail::static_check_supported_config<T, A>();
1021
+ return kernel::neg<A>(*this, A {});
1022
+ }
1023
+
1024
+ template <class T, class A>
1025
+ XSIMD_INLINE batch<T, A> batch<T, A>::operator+() const noexcept
1026
+ {
1027
+ detail::static_check_supported_config<T, A>();
1028
+ return *this;
1029
+ }
1030
+
1031
+ /************************
1032
+ * batch private method *
1033
+ ************************/
1034
+
1035
+ template <class T, class A>
1036
+ XSIMD_INLINE batch<T, A> batch<T, A>::logical_and(batch<T, A> const& other) const noexcept
1037
+ {
1038
+ return kernel::logical_and<A>(*this, other, A());
1039
+ }
1040
+
1041
+ template <class T, class A>
1042
+ XSIMD_INLINE batch<T, A> batch<T, A>::logical_or(batch<T, A> const& other) const noexcept
1043
+ {
1044
+ return kernel::logical_or<A>(*this, other, A());
1045
+ }
1046
+
1047
+ /***************************
1048
+ * batch_bool constructors *
1049
+ ***************************/
1050
+
1051
+ template <class T, class A>
1052
+ XSIMD_INLINE batch_bool<T, A>::batch_bool(register_type reg) noexcept
1053
+ : types::get_bool_simd_register_t<T, A>({ reg })
1054
+ {
1055
+ }
1056
+
1057
+ template <class T, class A>
1058
+ template <class... Ts>
1059
+ XSIMD_INLINE batch_bool<T, A>::batch_bool(bool val0, bool val1, Ts... vals) noexcept
1060
+ : batch_bool(kernel::set<A>(batch_bool {}, A {}, val0, val1, static_cast<bool>(vals)...))
1061
+ {
1062
+ static_assert(sizeof...(Ts) + 2 == size, "The constructor requires as many arguments as batch elements.");
1063
+ }
1064
+
1065
+ /*******************************
1066
+ * batch_bool memory operators *
1067
+ *******************************/
1068
+
1069
+ template <class T, class A>
1070
+ XSIMD_INLINE void batch_bool<T, A>::store_aligned(bool* mem) const noexcept
1071
+ {
1072
+ kernel::store(*this, mem, A {});
1073
+ }
1074
+
1075
+ template <class T, class A>
1076
+ XSIMD_INLINE void batch_bool<T, A>::store_unaligned(bool* mem) const noexcept
1077
+ {
1078
+ store_aligned(mem);
1079
+ }
1080
+
1081
+ template <class T, class A>
1082
+ XSIMD_INLINE void batch_bool<T, A>::store_stream(bool* mem) const noexcept
1083
+ {
1084
+ kernel::store_stream<A>(*this, mem, A {});
1085
+ }
1086
+
1087
+ template <class T, class A>
1088
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::load_aligned(bool const* mem) noexcept
1089
+ {
1090
+ return kernel::load_aligned<A>(mem, batch_bool<T, A>(), A {});
1091
+ }
1092
+
1093
+ template <class T, class A>
1094
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::load_unaligned(bool const* mem) noexcept
1095
+ {
1096
+ return kernel::load_unaligned<A>(mem, batch_bool<T, A>(), A {});
1097
+ }
1098
+
1099
+ template <class T, class A>
1100
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::load_stream(bool const* mem) noexcept
1101
+ {
1102
+ return kernel::load_stream<A>(mem, batch_bool<T, A>(), A {});
1103
+ }
1104
+
1105
+ /**
1106
+ * Extract a scalar mask representation from this @c batch_bool.
1107
+ *
1108
+ * @return bit mask
1109
+ */
1110
+ template <class T, class A>
1111
+ XSIMD_INLINE uint64_t batch_bool<T, A>::mask() const noexcept
1112
+ {
1113
+ return kernel::mask(*this, A {});
1114
+ }
1115
+
1116
+ /**
1117
+ * Extract a scalar mask representation from this @c batch_bool.
1118
+ *
1119
+ * @return bit mask
1120
+ */
1121
+ template <class T, class A>
1122
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::from_mask(uint64_t mask) noexcept
1123
+ {
1124
+ return kernel::from_mask(batch_bool<T, A>(), mask, A {});
1125
+ }
1126
+
1127
+ template <class T, class A>
1128
+ XSIMD_INLINE bool batch_bool<T, A>::get(std::size_t i) const noexcept
1129
+ {
1130
+ return kernel::get(*this, i, A {});
1131
+ }
1132
+
1133
+ template <class T, class A>
1134
+ XSIMD_INLINE bool batch_bool<T, A>::first() const noexcept
1135
+ {
1136
+ detail::static_check_supported_config<T, A>();
1137
+ return kernel::first(*this, A {});
1138
+ }
1139
+
1140
+ /***********************************
1141
+ * batch_bool comparison operators *
1142
+ ***********************************/
1143
+
1144
+ template <class T, class A>
1145
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::operator==(batch_bool<T, A> const& other) const noexcept
1146
+ {
1147
+ return kernel::eq<A>(*this, other, A {}).data;
1148
+ }
1149
+
1150
+ template <class T, class A>
1151
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::operator!=(batch_bool<T, A> const& other) const noexcept
1152
+ {
1153
+ return kernel::neq<A>(*this, other, A {}).data;
1154
+ }
1155
+
1156
+ /********************************
1157
+ * batch_bool logical operators *
1158
+ ********************************/
1159
+
1160
+ template <class T, class A>
1161
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::operator~() const noexcept
1162
+ {
1163
+ return kernel::bitwise_not<A>(*this, A {}).data;
1164
+ }
1165
+
1166
+ template <class T, class A>
1167
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::operator!() const noexcept
1168
+ {
1169
+ return operator==(batch_bool(false));
1170
+ }
1171
+
1172
+ template <class T, class A>
1173
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::operator&(batch_bool<T, A> const& other) const noexcept
1174
+ {
1175
+ return kernel::bitwise_and<A>(*this, other, A {}).data;
1176
+ }
1177
+
1178
+ template <class T, class A>
1179
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::operator|(batch_bool<T, A> const& other) const noexcept
1180
+ {
1181
+ return kernel::bitwise_or<A>(*this, other, A {}).data;
1182
+ }
1183
+
1184
+ template <class T, class A>
1185
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::operator^(batch_bool<T, A> const& other) const noexcept
1186
+ {
1187
+ return kernel::bitwise_xor<A>(*this, other, A {}).data;
1188
+ }
1189
+
1190
+ template <class T, class A>
1191
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::operator&&(batch_bool const& other) const noexcept
1192
+ {
1193
+ return operator&(other);
1194
+ }
1195
+
1196
+ template <class T, class A>
1197
+ XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::operator||(batch_bool const& other) const noexcept
1198
+ {
1199
+ return operator|(other);
1200
+ }
1201
+
1202
+ /******************************
1203
+ * batch_bool private methods *
1204
+ ******************************/
1205
+
1206
+ template <class T, class A>
1207
+ XSIMD_INLINE batch_bool<T, A>::batch_bool(bool val) noexcept
1208
+ : base_type { make_register(std::make_index_sequence<size - 1>(), val) }
1209
+ {
1210
+ }
1211
+
1212
+ template <class T, class A>
1213
+ template <class U, class... V, size_t I, size_t... Is>
1214
+ XSIMD_INLINE auto batch_bool<T, A>::make_register(std::index_sequence<I, Is...>, U u, V... v) noexcept -> register_type
1215
+ {
1216
+ return make_register(std::index_sequence<Is...>(), u, u, v...);
1217
+ }
1218
+
1219
+ template <class T, class A>
1220
+ template <class... V>
1221
+ XSIMD_INLINE auto batch_bool<T, A>::make_register(std::index_sequence<>, V... v) noexcept -> register_type
1222
+ {
1223
+ return kernel::set<A>(batch_bool<T, A>(), A {}, v...).data;
1224
+ }
1225
+
1226
+ /*******************************
1227
+ * batch<complex> constructors *
1228
+ *******************************/
1229
+
1230
+ template <class T, class A>
1231
+ XSIMD_INLINE batch<std::complex<T>, A>::batch(value_type const& val) noexcept
1232
+ : m_real(val.real())
1233
+ , m_imag(val.imag())
1234
+ {
1235
+ }
1236
+
1237
+ template <class T, class A>
1238
+ XSIMD_INLINE batch<std::complex<T>, A>::batch(real_batch const& real, real_batch const& imag) noexcept
1239
+ : m_real(real)
1240
+ , m_imag(imag)
1241
+ {
1242
+ }
1243
+
1244
+ template <class T, class A>
1245
+ XSIMD_INLINE batch<std::complex<T>, A>::batch(real_batch const& real) noexcept
1246
+ : m_real(real)
1247
+ , m_imag(0)
1248
+ {
1249
+ }
1250
+
1251
+ template <class T, class A>
1252
+ XSIMD_INLINE batch<std::complex<T>, A>::batch(T val) noexcept
1253
+ : m_real(val)
1254
+ , m_imag(0)
1255
+ {
1256
+ }
1257
+
1258
+ template <class T, class A>
1259
+ template <class... Ts>
1260
+ XSIMD_INLINE batch<std::complex<T>, A>::batch(value_type val0, value_type val1, Ts... vals) noexcept
1261
+ : batch(kernel::set<A>(batch {}, A {}, val0, val1, static_cast<value_type>(vals)...))
1262
+ {
1263
+ static_assert(sizeof...(Ts) + 2 == size, "as many arguments as batch elements");
1264
+ }
1265
+
1266
+ template <class T, class A>
1267
+ XSIMD_INLINE batch<std::complex<T>, A>::batch(batch_bool_type const& b) noexcept
1268
+ : m_real(b)
1269
+ , m_imag(0)
1270
+ {
1271
+ }
1272
+
1273
+ template <class T, class A>
1274
+ template <class U>
1275
+ XSIMD_NO_DISCARD XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::broadcast(U val) noexcept
1276
+ {
1277
+ return batch(static_cast<std::complex<T>>(val));
1278
+ }
1279
+
1280
+ /***********************************
1281
+ * batch<complex> memory operators *
1282
+ ***********************************/
1283
+
1284
+ template <class T, class A>
1285
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::load_aligned(const T* real_src, const T* imag_src) noexcept
1286
+ {
1287
+ return { batch<T, A>::load_aligned(real_src), imag_src ? batch<T, A>::load_aligned(imag_src) : batch<T, A>(0) };
1288
+ }
1289
+ template <class T, class A>
1290
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::load_unaligned(const T* real_src, const T* imag_src) noexcept
1291
+ {
1292
+ return { batch<T, A>::load_unaligned(real_src), imag_src ? batch<T, A>::load_unaligned(imag_src) : batch<T, A>(0) };
1293
+ }
1294
+
1295
+ template <class T, class A>
1296
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::load_aligned(const value_type* src) noexcept
1297
+ {
1298
+ assert(((reinterpret_cast<uintptr_t>(src) % A::alignment()) == 0)
1299
+ && "loaded pointer is not properly aligned");
1300
+ return kernel::load_complex_aligned<A>(src, kernel::convert<value_type> {}, A {});
1301
+ }
1302
+
1303
+ template <class T, class A>
1304
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::load_unaligned(const value_type* src) noexcept
1305
+ {
1306
+ return kernel::load_complex_unaligned<A>(src, kernel::convert<value_type> {}, A {});
1307
+ }
1308
+
1309
+ template <class T, class A>
1310
+ XSIMD_INLINE void batch<std::complex<T>, A>::store_aligned(value_type* dst) const noexcept
1311
+ {
1312
+ assert(((reinterpret_cast<uintptr_t>(dst) % A::alignment()) == 0)
1313
+ && "store location is not properly aligned");
1314
+ return kernel::store_complex_aligned(dst, *this, A {});
1315
+ }
1316
+
1317
+ template <class T, class A>
1318
+ XSIMD_INLINE void batch<std::complex<T>, A>::store_unaligned(value_type* dst) const noexcept
1319
+ {
1320
+ return kernel::store_complex_unaligned(dst, *this, A {});
1321
+ }
1322
+
1323
+ // Compile-time mask overloads for complex store
1324
+ template <class T, class A>
1325
+ template <class U, bool... Values, class Mode>
1326
+ XSIMD_INLINE void batch<std::complex<T>, A>::store(U* mem, batch_bool_constant<value_type, A, Values...> mask, Mode mode) const noexcept
1327
+ {
1328
+ kernel::store_masked<A>(mem, *this, mask, mode, A {});
1329
+ }
1330
+
1331
+ template <class T, class A>
1332
+ XSIMD_INLINE void batch<std::complex<T>, A>::store_aligned(T* real_dst, T* imag_dst) const noexcept
1333
+ {
1334
+ m_real.store_aligned(real_dst);
1335
+ m_imag.store_aligned(imag_dst);
1336
+ }
1337
+
1338
+ template <class T, class A>
1339
+ XSIMD_INLINE void batch<std::complex<T>, A>::store_unaligned(T* real_dst, T* imag_dst) const noexcept
1340
+ {
1341
+ m_real.store_unaligned(real_dst);
1342
+ m_imag.store_unaligned(imag_dst);
1343
+ }
1344
+
1345
+ template <class T, class A>
1346
+ template <class U>
1347
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::load(U const* mem, aligned_mode) noexcept
1348
+ {
1349
+ return load_aligned(mem);
1350
+ }
1351
+
1352
+ template <class T, class A>
1353
+ template <class U>
1354
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::load(U const* mem, unaligned_mode) noexcept
1355
+ {
1356
+ return load_unaligned(mem);
1357
+ }
1358
+
1359
+ // Compile-time mask overloads for complex load
1360
+ template <class T, class A>
1361
+ template <class U, bool... Values, class Mode>
1362
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::load(U const* mem,
1363
+ batch_bool_constant<value_type, A, Values...> mask,
1364
+ Mode mode) noexcept
1365
+ {
1366
+ return kernel::load_masked<A>(mem, mask, kernel::convert<value_type> {}, mode, A {});
1367
+ }
1368
+
1369
+ template <class T, class A>
1370
+ template <class U>
1371
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::load(U const* mem, stream_mode) noexcept
1372
+ {
1373
+ assert(((reinterpret_cast<uintptr_t>(mem) % A::alignment()) == 0)
1374
+ && "loaded pointer is not properly aligned");
1375
+ auto* ptr = reinterpret_cast<value_type const*>(mem);
1376
+ return kernel::load_complex_stream<A>(ptr, kernel::convert<value_type> {}, A {});
1377
+ }
1378
+
1379
+ template <class T, class A>
1380
+ template <class U>
1381
+ XSIMD_INLINE void batch<std::complex<T>, A>::store(U* mem, aligned_mode) const noexcept
1382
+ {
1383
+ return store_aligned(mem);
1384
+ }
1385
+
1386
+ template <class T, class A>
1387
+ template <class U>
1388
+ XSIMD_INLINE void batch<std::complex<T>, A>::store(U* mem, unaligned_mode) const noexcept
1389
+ {
1390
+ return store_unaligned(mem);
1391
+ }
1392
+
1393
+ template <class T, class A>
1394
+ template <class U>
1395
+ XSIMD_INLINE void batch<std::complex<T>, A>::store(U* mem, stream_mode) const noexcept
1396
+ {
1397
+ assert(((reinterpret_cast<uintptr_t>(mem) % A::alignment()) == 0)
1398
+ && "store location is not properly aligned");
1399
+ auto* ptr = reinterpret_cast<value_type*>(mem);
1400
+ return kernel::store_complex_stream(ptr, *this, A {});
1401
+ }
1402
+
1403
+ template <class T, class A>
1404
+ XSIMD_INLINE auto batch<std::complex<T>, A>::real() const noexcept -> real_batch
1405
+ {
1406
+ return m_real;
1407
+ }
1408
+
1409
+ template <class T, class A>
1410
+ XSIMD_INLINE auto batch<std::complex<T>, A>::imag() const noexcept -> real_batch
1411
+ {
1412
+ return m_imag;
1413
+ }
1414
+
1415
+ template <class T, class A>
1416
+ XSIMD_INLINE auto batch<std::complex<T>, A>::get(std::size_t i) const noexcept -> value_type
1417
+ {
1418
+ return kernel::get(*this, i, A {});
1419
+ }
1420
+
1421
+ template <class T, class A>
1422
+ XSIMD_INLINE auto batch<std::complex<T>, A>::first() const noexcept -> value_type
1423
+ {
1424
+ detail::static_check_supported_config<std::complex<T>, A>();
1425
+ return kernel::first(*this, A {});
1426
+ }
1427
+
1428
+ /**************************************
1429
+ * batch<complex> xtl-related methods *
1430
+ **************************************/
1431
+
1432
+ #ifdef XSIMD_ENABLE_XTL_COMPLEX
1433
+
1434
+ template <class T, class A>
1435
+ template <bool i3ec>
1436
+ XSIMD_INLINE batch<std::complex<T>, A>::batch(xtl::xcomplex<T, T, i3ec> const& val) noexcept
1437
+ : m_real(val.real())
1438
+ , m_imag(val.imag())
1439
+ {
1440
+ }
1441
+
1442
+ template <class T, class A>
1443
+ template <bool i3ec, class... Ts>
1444
+ XSIMD_INLINE batch<std::complex<T>, A>::batch(xtl::xcomplex<T, T, i3ec> val0, xtl::xcomplex<T, T, i3ec> val1, Ts... vals) noexcept
1445
+ : batch(kernel::set<A>(batch {}, A {}, val0, val1, static_cast<xtl::xcomplex<T, T, i3ec>>(vals)...))
1446
+ {
1447
+ static_assert(sizeof...(Ts) + 2 == size, "as many arguments as batch elements");
1448
+ }
1449
+
1450
+ // Memory layout of an xcomplex and std::complex are the same when xcomplex
1451
+ // stores values and not reference. Unfortunately, this breaks strict
1452
+ // aliasing...
1453
+
1454
+ template <class T, class A>
1455
+ template <bool i3ec>
1456
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::load_aligned(const xtl::xcomplex<T, T, i3ec>* src) noexcept
1457
+ {
1458
+ return load_aligned(reinterpret_cast<std::complex<T> const*>(src));
1459
+ }
1460
+
1461
+ template <class T, class A>
1462
+ template <bool i3ec>
1463
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::load_unaligned(const xtl::xcomplex<T, T, i3ec>* src) noexcept
1464
+ {
1465
+ return load_unaligned(reinterpret_cast<std::complex<T> const*>(src));
1466
+ }
1467
+
1468
+ template <class T, class A>
1469
+ template <bool i3ec>
1470
+ XSIMD_INLINE void batch<std::complex<T>, A>::store_aligned(xtl::xcomplex<T, T, i3ec>* dst) const noexcept
1471
+ {
1472
+ store_aligned(reinterpret_cast<std::complex<T>*>(dst));
1473
+ }
1474
+
1475
+ template <class T, class A>
1476
+ template <bool i3ec>
1477
+ XSIMD_INLINE void batch<std::complex<T>, A>::store_unaligned(xtl::xcomplex<T, T, i3ec>* dst) const noexcept
1478
+ {
1479
+ store_unaligned(reinterpret_cast<std::complex<T>*>(dst));
1480
+ }
1481
+
1482
+ #endif
1483
+
1484
+ /***************************************
1485
+ * batch<complex> comparison operators *
1486
+ ***************************************/
1487
+
1488
+ template <class T, class A>
1489
+ XSIMD_INLINE batch_bool<T, A> batch<std::complex<T>, A>::operator==(batch const& other) const noexcept
1490
+ {
1491
+ return m_real == other.m_real && m_imag == other.m_imag;
1492
+ }
1493
+
1494
+ template <class T, class A>
1495
+ XSIMD_INLINE batch_bool<T, A> batch<std::complex<T>, A>::operator!=(batch const& other) const noexcept
1496
+ {
1497
+ return m_real != other.m_real || m_imag != other.m_imag;
1498
+ }
1499
+
1500
+ /***********************************
1501
+ * batch<complex> update operators *
1502
+ ***********************************/
1503
+
1504
+ template <class T, class A>
1505
+ XSIMD_INLINE batch<std::complex<T>, A>& batch<std::complex<T>, A>::operator+=(batch const& other) noexcept
1506
+ {
1507
+ m_real += other.m_real;
1508
+ m_imag += other.m_imag;
1509
+ return *this;
1510
+ }
1511
+
1512
+ template <class T, class A>
1513
+ XSIMD_INLINE batch<std::complex<T>, A>& batch<std::complex<T>, A>::operator-=(batch const& other) noexcept
1514
+ {
1515
+ m_real -= other.m_real;
1516
+ m_imag -= other.m_imag;
1517
+ return *this;
1518
+ }
1519
+
1520
+ template <class T, class A>
1521
+ XSIMD_INLINE batch<std::complex<T>, A>& batch<std::complex<T>, A>::operator*=(batch const& other) noexcept
1522
+ {
1523
+ real_batch new_real = fms(real(), other.real(), imag() * other.imag());
1524
+ real_batch new_imag = fma(real(), other.imag(), imag() * other.real());
1525
+ m_real = new_real;
1526
+ m_imag = new_imag;
1527
+ return *this;
1528
+ }
1529
+
1530
+ template <class T, class A>
1531
+ XSIMD_INLINE batch<std::complex<T>, A>& batch<std::complex<T>, A>::operator/=(batch const& other) noexcept
1532
+ {
1533
+ real_batch a = real();
1534
+ real_batch b = imag();
1535
+ real_batch c = other.real();
1536
+ real_batch d = other.imag();
1537
+ real_batch e = c * c + d * d;
1538
+ m_real = (c * a + d * b) / e;
1539
+ m_imag = (c * b - d * a) / e;
1540
+ return *this;
1541
+ }
1542
+
1543
+ /**************************************
1544
+ * batch<complex> incr/decr operators *
1545
+ **************************************/
1546
+
1547
+ template <class T, class A>
1548
+ XSIMD_INLINE batch<std::complex<T>, A>& batch<std::complex<T>, A>::operator++() noexcept
1549
+ {
1550
+ return operator+=(1);
1551
+ }
1552
+
1553
+ template <class T, class A>
1554
+ XSIMD_INLINE batch<std::complex<T>, A>& batch<std::complex<T>, A>::operator--() noexcept
1555
+ {
1556
+ return operator-=(1);
1557
+ }
1558
+
1559
+ template <class T, class A>
1560
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::operator++(int) noexcept
1561
+ {
1562
+ batch copy(*this);
1563
+ operator+=(1);
1564
+ return copy;
1565
+ }
1566
+
1567
+ template <class T, class A>
1568
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::operator--(int) noexcept
1569
+ {
1570
+ batch copy(*this);
1571
+ operator-=(1);
1572
+ return copy;
1573
+ }
1574
+
1575
+ /**********************************
1576
+ * batch<complex> unary operators *
1577
+ **********************************/
1578
+
1579
+ template <class T, class A>
1580
+ XSIMD_INLINE batch_bool<T, A> batch<std::complex<T>, A>::operator!() const noexcept
1581
+ {
1582
+ return operator==(batch(0));
1583
+ }
1584
+
1585
+ template <class T, class A>
1586
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::operator~() const noexcept
1587
+ {
1588
+ return { ~m_real, ~m_imag };
1589
+ }
1590
+
1591
+ template <class T, class A>
1592
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::operator-() const noexcept
1593
+ {
1594
+ return { -m_real, -m_imag };
1595
+ }
1596
+
1597
+ template <class T, class A>
1598
+ XSIMD_INLINE batch<std::complex<T>, A> batch<std::complex<T>, A>::operator+() const noexcept
1599
+ {
1600
+ return { +m_real, +m_imag };
1601
+ }
1602
+
1603
+ /**********************************
1604
+ * size type aliases
1605
+ **********************************/
1606
+
1607
+ namespace details
1608
+ {
1609
+ template <typename T, std::size_t N, class ArchList>
1610
+ struct sized_batch;
1611
+
1612
+ template <typename T, std::size_t N>
1613
+ struct sized_batch<T, N, xsimd::arch_list<>>
1614
+ {
1615
+ using type = void;
1616
+ };
1617
+
1618
+ template <typename T, class Arch, bool BatchExists = xsimd::has_simd_register<T, Arch>::value>
1619
+ struct batch_trait;
1620
+
1621
+ template <typename T, class Arch>
1622
+ struct batch_trait<T, Arch, true>
1623
+ {
1624
+ using type = xsimd::batch<T, Arch>;
1625
+ static constexpr std::size_t size = xsimd::batch<T, Arch>::size;
1626
+ };
1627
+
1628
+ template <typename T, class Arch>
1629
+ struct batch_trait<T, Arch, false>
1630
+ {
1631
+ using type = void;
1632
+ static constexpr std::size_t size = 0;
1633
+ };
1634
+
1635
+ template <typename T, std::size_t N, class Arch, class... Archs>
1636
+ struct sized_batch<T, N, xsimd::arch_list<Arch, Archs...>>
1637
+ {
1638
+ using type = std::conditional_t<
1639
+ batch_trait<T, Arch>::size == N,
1640
+ typename batch_trait<T, Arch>::type,
1641
+ typename sized_batch<T, N, xsimd::arch_list<Archs...>>::type>;
1642
+ };
1643
+ }
1644
+
1645
+ /**
1646
+ * @brief type utility to select a batch of given type and size
1647
+ *
1648
+ * If one of the available architectures has a native vector type of the
1649
+ * given type and size, sets the @p type member to the appropriate batch
1650
+ * type. Otherwise set its to @p void.
1651
+ *
1652
+ * @tparam T the type of the underlying values.
1653
+ * @tparam N the number of elements of that type in the batch.
1654
+ **/
1655
+ template <typename T, std::size_t N>
1656
+ struct make_sized_batch
1657
+ {
1658
+ using type = typename details::sized_batch<T, N, supported_architectures>::type;
1659
+ };
1660
+
1661
+ template <typename T, std::size_t N>
1662
+ using make_sized_batch_t = typename make_sized_batch<T, N>::type;
1663
+ }
1664
+
1665
+ #endif