ycpp 0.1.3__cp312-abi3-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.
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.lib +0 -0
  20. ycpp/_ycpp.pyd +0 -0
  21. ycpp-0.1.3.data/headers/fast_float/ascii_number.h +766 -0
  22. ycpp-0.1.3.data/headers/fast_float/bigint.h +638 -0
  23. ycpp-0.1.3.data/headers/fast_float/constexpr_feature_detect.h +53 -0
  24. ycpp-0.1.3.data/headers/fast_float/decimal_to_binary.h +212 -0
  25. ycpp-0.1.3.data/headers/fast_float/digit_comparison.h +455 -0
  26. ycpp-0.1.3.data/headers/fast_float/fast_float.h +91 -0
  27. ycpp-0.1.3.data/headers/fast_float/fast_table.h +708 -0
  28. ycpp-0.1.3.data/headers/fast_float/float_common.h +1432 -0
  29. ycpp-0.1.3.data/headers/fast_float/parse_number.h +488 -0
  30. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_arithmetic.hpp +267 -0
  31. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_bit.hpp +230 -0
  32. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_cast.hpp +43 -0
  33. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_complex.hpp +112 -0
  34. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_details.hpp +386 -0
  35. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_logical.hpp +240 -0
  36. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_math.hpp +2601 -0
  37. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_memory.hpp +1006 -0
  38. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_rounding.hpp +72 -0
  39. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_swizzle.hpp +260 -0
  40. ycpp-0.1.3.data/headers/xsimd/arch/common/xsimd_common_trigo.hpp +996 -0
  41. ycpp-0.1.3.data/headers/xsimd/arch/utils/shifts.hpp +82 -0
  42. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx.hpp +2111 -0
  43. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx2.hpp +1591 -0
  44. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512bw.hpp +724 -0
  45. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512cd.hpp +28 -0
  46. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512dq.hpp +270 -0
  47. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512er.hpp +17 -0
  48. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512f.hpp +2919 -0
  49. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512ifma.hpp +17 -0
  50. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512pf.hpp +17 -0
  51. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512vbmi.hpp +76 -0
  52. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512vbmi2.hpp +130 -0
  53. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp +17 -0
  54. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avx512vnni_avx512vbmi2.hpp +17 -0
  55. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_avxvnni.hpp +17 -0
  56. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_common.hpp +26 -0
  57. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_common_fwd.hpp +127 -0
  58. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_constants.hpp +393 -0
  59. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_emulated.hpp +787 -0
  60. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_fma3_avx.hpp +93 -0
  61. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_fma3_avx2.hpp +46 -0
  62. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_fma3_sse.hpp +97 -0
  63. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_fma4.hpp +92 -0
  64. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_i8mm_neon64.hpp +17 -0
  65. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_isa.hpp +146 -0
  66. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_neon.hpp +3580 -0
  67. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_neon64.hpp +1614 -0
  68. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_rvv.hpp +1515 -0
  69. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_scalar.hpp +1210 -0
  70. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_sse2.hpp +2333 -0
  71. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_sse3.hpp +66 -0
  72. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_sse4_1.hpp +510 -0
  73. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_sse4_2.hpp +44 -0
  74. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_ssse3.hpp +186 -0
  75. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_sve.hpp +1186 -0
  76. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_vsx.hpp +916 -0
  77. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_vxe.hpp +787 -0
  78. ycpp-0.1.3.data/headers/xsimd/arch/xsimd_wasm.hpp +1819 -0
  79. ycpp-0.1.3.data/headers/xsimd/config/xsimd_arch.hpp +242 -0
  80. ycpp-0.1.3.data/headers/xsimd/config/xsimd_config.hpp +620 -0
  81. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features.hpp +50 -0
  82. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features_arm.hpp +132 -0
  83. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features_ppc.hpp +54 -0
  84. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features_riscv.hpp +95 -0
  85. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features_s390x.hpp +56 -0
  86. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpu_features_x86.hpp +1044 -0
  87. ycpp-0.1.3.data/headers/xsimd/config/xsimd_cpuid.hpp +144 -0
  88. ycpp-0.1.3.data/headers/xsimd/config/xsimd_getauxval.hpp +159 -0
  89. ycpp-0.1.3.data/headers/xsimd/config/xsimd_macros.hpp +76 -0
  90. ycpp-0.1.3.data/headers/xsimd/math/xsimd_rem_pio2.hpp +707 -0
  91. ycpp-0.1.3.data/headers/xsimd/memory/xsimd_aligned_allocator.hpp +349 -0
  92. ycpp-0.1.3.data/headers/xsimd/memory/xsimd_alignment.hpp +102 -0
  93. ycpp-0.1.3.data/headers/xsimd/types/xsimd_all_registers.hpp +57 -0
  94. ycpp-0.1.3.data/headers/xsimd/types/xsimd_api.hpp +3106 -0
  95. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx2_register.hpp +44 -0
  96. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512bw_register.hpp +51 -0
  97. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512cd_register.hpp +51 -0
  98. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512dq_register.hpp +51 -0
  99. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512er_register.hpp +51 -0
  100. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512f_register.hpp +77 -0
  101. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512ifma_register.hpp +51 -0
  102. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512pf_register.hpp +51 -0
  103. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512vbmi2_register.hpp +51 -0
  104. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512vbmi_register.hpp +51 -0
  105. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp +54 -0
  106. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx512vnni_avx512vbmi2_register.hpp +53 -0
  107. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avx_register.hpp +64 -0
  108. ycpp-0.1.3.data/headers/xsimd/types/xsimd_avxvnni_register.hpp +44 -0
  109. ycpp-0.1.3.data/headers/xsimd/types/xsimd_batch.hpp +1665 -0
  110. ycpp-0.1.3.data/headers/xsimd/types/xsimd_batch_constant.hpp +571 -0
  111. ycpp-0.1.3.data/headers/xsimd/types/xsimd_batch_fwd.hpp +41 -0
  112. ycpp-0.1.3.data/headers/xsimd/types/xsimd_common_arch.hpp +49 -0
  113. ycpp-0.1.3.data/headers/xsimd/types/xsimd_emulated_register.hpp +80 -0
  114. ycpp-0.1.3.data/headers/xsimd/types/xsimd_fma3_avx2_register.hpp +50 -0
  115. ycpp-0.1.3.data/headers/xsimd/types/xsimd_fma3_avx_register.hpp +50 -0
  116. ycpp-0.1.3.data/headers/xsimd/types/xsimd_fma3_sse_register.hpp +50 -0
  117. ycpp-0.1.3.data/headers/xsimd/types/xsimd_fma4_register.hpp +50 -0
  118. ycpp-0.1.3.data/headers/xsimd/types/xsimd_i8mm_neon64_register.hpp +55 -0
  119. ycpp-0.1.3.data/headers/xsimd/types/xsimd_neon64_register.hpp +55 -0
  120. ycpp-0.1.3.data/headers/xsimd/types/xsimd_neon_register.hpp +130 -0
  121. ycpp-0.1.3.data/headers/xsimd/types/xsimd_register.hpp +96 -0
  122. ycpp-0.1.3.data/headers/xsimd/types/xsimd_rvv_register.hpp +491 -0
  123. ycpp-0.1.3.data/headers/xsimd/types/xsimd_sse2_register.hpp +59 -0
  124. ycpp-0.1.3.data/headers/xsimd/types/xsimd_sse3_register.hpp +49 -0
  125. ycpp-0.1.3.data/headers/xsimd/types/xsimd_sse4_1_register.hpp +48 -0
  126. ycpp-0.1.3.data/headers/xsimd/types/xsimd_sse4_2_register.hpp +48 -0
  127. ycpp-0.1.3.data/headers/xsimd/types/xsimd_ssse3_register.hpp +48 -0
  128. ycpp-0.1.3.data/headers/xsimd/types/xsimd_sve_register.hpp +216 -0
  129. ycpp-0.1.3.data/headers/xsimd/types/xsimd_traits.hpp +408 -0
  130. ycpp-0.1.3.data/headers/xsimd/types/xsimd_utils.hpp +462 -0
  131. ycpp-0.1.3.data/headers/xsimd/types/xsimd_vsx_register.hpp +77 -0
  132. ycpp-0.1.3.data/headers/xsimd/types/xsimd_vxe_register.hpp +86 -0
  133. ycpp-0.1.3.data/headers/xsimd/types/xsimd_wasm_register.hpp +59 -0
  134. ycpp-0.1.3.data/headers/xsimd/utils/bits.hpp +122 -0
  135. ycpp-0.1.3.data/headers/xsimd/utils/xsimd_type_traits.hpp +145 -0
  136. ycpp-0.1.3.data/headers/xsimd/xsimd.hpp +43 -0
  137. ycpp-0.1.3.dist-info/DELVEWHEEL +2 -0
  138. ycpp-0.1.3.dist-info/METADATA +15 -0
  139. ycpp-0.1.3.dist-info/RECORD +142 -0
  140. ycpp-0.1.3.dist-info/WHEEL +4 -0
  141. ycpp.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
  142. ycpp.libs/msvcp140_1-226498d4bfcb4f07974757b596ebec45.dll +0 -0
@@ -0,0 +1,571 @@
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_CONSTANT_HPP
13
+ #define XSIMD_BATCH_CONSTANT_HPP
14
+
15
+ #include <cstddef>
16
+ #include <functional>
17
+ #include <utility>
18
+
19
+ #include "./xsimd_batch.hpp"
20
+ #include "./xsimd_utils.hpp"
21
+
22
+ namespace xsimd
23
+ {
24
+ /**
25
+ * @brief batch of boolean constant
26
+ *
27
+ * Abstract representation of a batch of boolean constants.
28
+ *
29
+ * @tparam batch_type the type of the associated batch values.
30
+ * @tparam Values boolean constant represented by this batch
31
+ **/
32
+ template <typename T, class A, bool... Values>
33
+ struct batch_bool_constant
34
+ {
35
+ using batch_type = batch_bool<T, A>;
36
+ static constexpr std::size_t size = sizeof...(Values);
37
+ using value_type = bool;
38
+ using operand_type = T;
39
+ static_assert(sizeof...(Values) == batch_type::size, "consistent batch size");
40
+
41
+ public:
42
+ /**
43
+ * @brief Generate a batch of @p batch_type from this @p batch_bool_constant
44
+ */
45
+ constexpr batch_type as_batch_bool() const noexcept { return { Values... }; }
46
+
47
+ /**
48
+ * @brief Generate a batch of @p integers from this @p batch_bool_constant
49
+ */
50
+ constexpr batch<as_integer_t<T>, A> as_batch() const noexcept { return { -as_integer_t<T>(Values)... }; } // the minus is important!
51
+ /**
52
+ * @brief Generate a batch of @p batch_type from this @p batch_bool_constant
53
+ */
54
+ constexpr operator batch_type() const noexcept { return as_batch_bool(); }
55
+
56
+ constexpr bool get(std::size_t i) const noexcept
57
+ {
58
+ return std::array<value_type, size> { { Values... } }[i];
59
+ }
60
+
61
+ static constexpr int mask() noexcept
62
+ {
63
+ return mask_helper(0, static_cast<int>(Values)...);
64
+ }
65
+
66
+ static constexpr bool none() noexcept
67
+ {
68
+ return truncated_mask() == 0u;
69
+ }
70
+
71
+ static constexpr bool any() noexcept
72
+ {
73
+ return !none();
74
+ }
75
+
76
+ static constexpr bool all() noexcept
77
+ {
78
+ return truncated_mask() == low_mask(size);
79
+ }
80
+
81
+ static constexpr std::size_t countr_zero() noexcept
82
+ {
83
+ return countr_zero_impl(truncated_mask(), size);
84
+ }
85
+
86
+ static constexpr std::size_t countl_zero() noexcept
87
+ {
88
+ return countl_zero_impl(truncated_mask(), size);
89
+ }
90
+
91
+ static constexpr std::size_t countr_one() noexcept
92
+ {
93
+ return countr_one_impl(truncated_mask(), size);
94
+ }
95
+
96
+ static constexpr std::size_t countl_one() noexcept
97
+ {
98
+ return countl_one_impl(truncated_mask(), size);
99
+ }
100
+
101
+ private:
102
+ static constexpr int mask_helper(int acc) noexcept { return acc; }
103
+
104
+ template <class... Tys>
105
+ static constexpr int mask_helper(int acc, int mask, Tys... masks) noexcept
106
+ {
107
+ return mask_helper(acc | mask, (masks << 1)...);
108
+ }
109
+
110
+ struct logical_or
111
+ {
112
+ constexpr bool operator()(bool x, bool y) const { return x || y; }
113
+ };
114
+ struct logical_and
115
+ {
116
+ constexpr bool operator()(bool x, bool y) const { return x && y; }
117
+ };
118
+ struct logical_xor
119
+ {
120
+ constexpr bool operator()(bool x, bool y) const { return x ^ y; }
121
+ };
122
+
123
+ template <class F, class SelfPack, class OtherPack, std::size_t... Indices>
124
+ static constexpr batch_bool_constant<T, A, F()(std::tuple_element<Indices, SelfPack>::type::value, std::tuple_element<Indices, OtherPack>::type::value)...>
125
+ apply(std::index_sequence<Indices...>)
126
+ {
127
+ return {};
128
+ }
129
+
130
+ template <class F, bool... OtherValues>
131
+ static constexpr auto apply(batch_bool_constant<T, A, Values...>, batch_bool_constant<T, A, OtherValues...>)
132
+ {
133
+ static_assert(sizeof...(Values) == sizeof...(OtherValues), "compatible constant batches");
134
+ return apply<F, std::tuple<std::integral_constant<bool, Values>...>, std::tuple<std::integral_constant<bool, OtherValues>...>>(std::make_index_sequence<sizeof...(Values)>());
135
+ }
136
+
137
+ public:
138
+ #define MAKE_BINARY_OP(OP, NAME) \
139
+ template <bool... OtherValues> \
140
+ constexpr auto operator OP(batch_bool_constant<T, A, OtherValues...> other) const \
141
+ { \
142
+ return apply<NAME>(*this, other); \
143
+ }
144
+
145
+ MAKE_BINARY_OP(|, logical_or)
146
+ MAKE_BINARY_OP(||, logical_or)
147
+ MAKE_BINARY_OP(&, logical_and)
148
+ MAKE_BINARY_OP(&&, logical_and)
149
+ MAKE_BINARY_OP(^, logical_xor)
150
+
151
+ #undef MAKE_BINARY_OP
152
+
153
+ constexpr batch_bool_constant<T, A, !Values...> operator!() const
154
+ {
155
+ return {};
156
+ }
157
+
158
+ constexpr batch_bool_constant<T, A, !Values...> operator~() const
159
+ {
160
+ return {};
161
+ }
162
+
163
+ private:
164
+ // Build a 64-bit mask from Values... (LSB = index 0)
165
+ template <std::size_t I, bool... Remaining>
166
+ struct build_bits_helper;
167
+
168
+ template <std::size_t I>
169
+ struct build_bits_helper<I>
170
+ {
171
+ static constexpr uint64_t value = 0u;
172
+ };
173
+
174
+ template <std::size_t I, bool Current, bool... Remaining>
175
+ struct build_bits_helper<I, Current, Remaining...>
176
+ {
177
+ static constexpr uint64_t value = (Current ? (uint64_t(1) << I) : 0u)
178
+ | build_bits_helper<I + 1, Remaining...>::value;
179
+ };
180
+
181
+ static constexpr uint64_t bits() noexcept
182
+ {
183
+ return build_bits_helper<0, Values...>::value;
184
+ }
185
+ static constexpr uint64_t low_mask(std::size_t k) noexcept
186
+ {
187
+ return (k >= 64u) ? ~uint64_t(0) : ((uint64_t(1) << k) - 1u);
188
+ }
189
+ static constexpr uint64_t truncated_mask() noexcept
190
+ {
191
+ return bits() & low_mask(size);
192
+ }
193
+ static constexpr std::size_t countr_zero_impl(uint64_t v, std::size_t n) noexcept
194
+ {
195
+ return (n == 0 || (v & 1u) != 0u) ? 0u : (1u + countr_zero_impl(v >> 1, n - 1));
196
+ }
197
+ static constexpr std::size_t countr_one_impl(uint64_t v, std::size_t n) noexcept
198
+ {
199
+ return (n == 0 || (v & 1u) == 0u) ? 0u : (1u + countr_one_impl(v >> 1, n - 1));
200
+ }
201
+ static constexpr std::size_t countl_zero_impl(uint64_t v, std::size_t n) noexcept
202
+ {
203
+ return (n == 0) ? 0u : ((((v >> (n - 1)) & 1u) != 0u) ? 0u : (1u + countl_zero_impl(v, n - 1)));
204
+ }
205
+ static constexpr std::size_t countl_one_impl(uint64_t v, std::size_t n) noexcept
206
+ {
207
+ return (n == 0) ? 0u : ((((v >> (n - 1)) & 1u) == 0u) ? 0u : (1u + countl_one_impl(v, n - 1)));
208
+ }
209
+ };
210
+
211
+ namespace detail
212
+ {
213
+ template <class A2, std::size_t BeginIdx, typename T, class A, bool... Values, std::size_t... Is>
214
+ XSIMD_INLINE constexpr batch_bool_constant<
215
+ T, A2,
216
+ std::tuple_element<BeginIdx + Is,
217
+ std::tuple<std::integral_constant<bool, Values>...>>::type::value...>
218
+ splice_impl(std::index_sequence<Is...>) noexcept
219
+ {
220
+ return {};
221
+ }
222
+
223
+ template <class A2, std::size_t Begin, std::size_t End,
224
+ typename T, class A, bool... Values,
225
+ std::size_t N = (End >= Begin ? (End - Begin) : 0)>
226
+ XSIMD_INLINE constexpr auto splice(batch_bool_constant<T, A, Values...>) noexcept
227
+ {
228
+ static_assert(Begin <= End, "splice: Begin must be <= End");
229
+ static_assert(End <= sizeof...(Values), "splice: End must be <= size");
230
+ static_assert(N == batch_bool<T, A2>::size, "splice: target arch size must match submask length");
231
+ return splice_impl<A2, Begin, T, A, Values...>(std::make_index_sequence<N>());
232
+ }
233
+
234
+ template <class A2, typename T, class A, bool... Values>
235
+ XSIMD_INLINE constexpr auto lower_half(batch_bool_constant<T, A, Values...>) noexcept
236
+ {
237
+ static_assert(sizeof...(Values) % 2 == 0, "lower_half requires even size");
238
+ static_assert(batch_bool<T, A2>::size == sizeof...(Values) / 2,
239
+ "lower_half: target arch size must match submask length");
240
+ return splice_impl<A2, 0, T, A, Values...>(std::make_index_sequence<sizeof...(Values) / 2>());
241
+ }
242
+
243
+ template <class A2, typename T, class A, bool... Values>
244
+ XSIMD_INLINE constexpr auto upper_half(batch_bool_constant<T, A, Values...>) noexcept
245
+ {
246
+ static_assert(sizeof...(Values) % 2 == 0, "upper_half requires even size");
247
+ static_assert(batch_bool<T, A2>::size == sizeof...(Values) / 2,
248
+ "upper_half: target arch size must match submask length");
249
+ return splice_impl<A2, sizeof...(Values) / 2, T, A, Values...>(std::make_index_sequence<sizeof...(Values) / 2>());
250
+ }
251
+ } // namespace detail
252
+
253
+ /**
254
+ * @brief batch of integral constants
255
+ *
256
+ * Abstract representation of a batch of integral constants.
257
+ *
258
+ * @tparam batch_type the type of the associated batch values.
259
+ * @tparam Values constants represented by this batch
260
+ **/
261
+ template <typename T, class A, T... Values>
262
+ struct batch_constant
263
+ {
264
+ static constexpr std::size_t size = sizeof...(Values);
265
+ using batch_type = batch<T, A>;
266
+ using value_type = typename batch_type::value_type;
267
+ static_assert(sizeof...(Values) == batch_type::size, "consistent batch size");
268
+
269
+ /**
270
+ * @brief Generate a batch of @p batch_type from this @p batch_constant
271
+ */
272
+ XSIMD_INLINE batch_type as_batch() const noexcept { return { Values... }; }
273
+
274
+ /**
275
+ * @brief Generate a batch of @p batch_type from this @p batch_constant
276
+ */
277
+ XSIMD_INLINE operator batch_type() const noexcept { return as_batch(); }
278
+
279
+ /**
280
+ * @brief Get the @p i th element of this @p batch_constant
281
+ */
282
+ constexpr T get(std::size_t i) const noexcept
283
+ {
284
+ return get(i, std::array<T, size> { Values... });
285
+ }
286
+
287
+ private:
288
+ constexpr T get(std::size_t i, std::array<T, size> const& values) const noexcept
289
+ {
290
+ return values[i];
291
+ }
292
+
293
+ template <typename = void>
294
+ struct binary_rshift
295
+ {
296
+ constexpr T operator()(T x, T y) const { return x >> y; }
297
+ };
298
+ template <typename = void>
299
+ struct binary_lshift
300
+ {
301
+ constexpr T operator()(T x, T y) const { return x << y; }
302
+ };
303
+
304
+ template <class F, class SelfPack, class OtherPack, std::size_t... Indices>
305
+ static constexpr batch_constant<T, A, F()(std::tuple_element<Indices, SelfPack>::type::value, std::tuple_element<Indices, OtherPack>::type::value)...>
306
+ apply(std::index_sequence<Indices...>)
307
+ {
308
+ return {};
309
+ }
310
+
311
+ template <class F, T... OtherValues>
312
+ static constexpr auto apply(batch_constant<T, A, Values...>, batch_constant<T, A, OtherValues...>)
313
+ {
314
+ static_assert(sizeof...(Values) == sizeof...(OtherValues), "compatible constant batches");
315
+ return apply<F, std::tuple<std::integral_constant<T, Values>...>, std::tuple<std::integral_constant<T, OtherValues>...>>(std::make_index_sequence<sizeof...(Values)>());
316
+ }
317
+
318
+ public:
319
+ #define MAKE_BINARY_OP(OP, NAME) \
320
+ template <T... OtherValues> \
321
+ constexpr auto operator OP(batch_constant<T, A, OtherValues...> other) const \
322
+ { \
323
+ return apply<NAME<void>>(*this, other); \
324
+ } \
325
+ template <T OtherValue> \
326
+ constexpr batch_constant<T, A, (Values OP OtherValue)...> operator OP(std::integral_constant<T, OtherValue>) const \
327
+ { \
328
+ return {}; \
329
+ }
330
+
331
+ MAKE_BINARY_OP(+, std::plus)
332
+ MAKE_BINARY_OP(-, std::minus)
333
+ MAKE_BINARY_OP(*, std::multiplies)
334
+ MAKE_BINARY_OP(/, std::divides)
335
+ MAKE_BINARY_OP(%, std::modulus)
336
+ MAKE_BINARY_OP(&, std::bit_and)
337
+ MAKE_BINARY_OP(|, std::bit_or)
338
+ MAKE_BINARY_OP(^, std::bit_xor)
339
+ MAKE_BINARY_OP(<<, binary_lshift)
340
+ MAKE_BINARY_OP(>>, binary_rshift)
341
+
342
+ #undef MAKE_BINARY_OP
343
+
344
+ template <class F, class SelfPack, class OtherPack, std::size_t... Indices>
345
+ static constexpr batch_bool_constant<T, A, F()(std::tuple_element<Indices, SelfPack>::type::value, std::tuple_element<Indices, OtherPack>::type::value)...>
346
+ apply_bool(std::index_sequence<Indices...>)
347
+ {
348
+ return {};
349
+ }
350
+
351
+ template <class F, T... OtherValues>
352
+ static constexpr auto apply_bool(batch_constant<T, A, Values...>, batch_constant<T, A, OtherValues...>)
353
+ {
354
+ static_assert(sizeof...(Values) == sizeof...(OtherValues), "compatible constant batches");
355
+ return apply_bool<F, std::tuple<std::integral_constant<T, Values>...>, std::tuple<std::integral_constant<T, OtherValues>...>>(std::make_index_sequence<sizeof...(Values)>());
356
+ }
357
+
358
+ #define MAKE_BINARY_BOOL_OP(OP, NAME) \
359
+ template <T... OtherValues> \
360
+ constexpr auto operator OP(batch_constant<T, A, OtherValues...> other) const \
361
+ { \
362
+ return apply_bool<NAME<void>>(*this, other); \
363
+ } \
364
+ template <T OtherValue> \
365
+ constexpr batch_bool_constant<T, A, (Values OP OtherValue)...> operator OP(std::integral_constant<T, OtherValue>) const \
366
+ { \
367
+ return {}; \
368
+ }
369
+
370
+ MAKE_BINARY_BOOL_OP(==, std::equal_to)
371
+ MAKE_BINARY_BOOL_OP(!=, std::not_equal_to)
372
+ MAKE_BINARY_BOOL_OP(<, std::less)
373
+ MAKE_BINARY_BOOL_OP(<=, std::less_equal)
374
+ MAKE_BINARY_BOOL_OP(>, std::greater)
375
+ MAKE_BINARY_BOOL_OP(>=, std::greater_equal)
376
+
377
+ #undef MAKE_BINARY_BOOL_OP
378
+
379
+ constexpr batch_constant<T, A, (T)-Values...> operator-() const
380
+ {
381
+ return {};
382
+ }
383
+
384
+ constexpr batch_constant<T, A, (T) + Values...> operator+() const
385
+ {
386
+ return {};
387
+ }
388
+
389
+ constexpr batch_constant<T, A, (T)~Values...> operator~() const
390
+ {
391
+ return {};
392
+ }
393
+ };
394
+
395
+ namespace detail
396
+ {
397
+ template <typename T, class G, class A, std::size_t... Is>
398
+ XSIMD_INLINE constexpr batch_constant<T, A, (T)G::get(Is, sizeof...(Is))...>
399
+ make_batch_constant(std::index_sequence<Is...>) noexcept
400
+ {
401
+ return {};
402
+ }
403
+
404
+ template <typename T, T Val, class A, std::size_t... Is>
405
+ XSIMD_INLINE constexpr batch_constant<T, A, (static_cast<T>(0 * Is) + Val)...>
406
+ make_batch_constant(std::index_sequence<Is...>) noexcept
407
+ {
408
+ return {};
409
+ }
410
+
411
+ #if __cplusplus >= 202002L
412
+ template <std::array Arr, class A, std::size_t... Is>
413
+ XSIMD_INLINE constexpr batch_constant<typename decltype(Arr)::value_type, A, Arr[Is]...>
414
+ make_batch_constant(std::index_sequence<Is...>) noexcept
415
+ {
416
+ return {};
417
+ }
418
+ #endif
419
+
420
+ template <typename T, class G, class A, std::size_t... Is>
421
+ XSIMD_INLINE constexpr batch_bool_constant<T, A, G::get(Is, sizeof...(Is))...>
422
+ make_batch_bool_constant(std::index_sequence<Is...>) noexcept
423
+ {
424
+ return {};
425
+ }
426
+
427
+ template <typename T, bool Val, class A, std::size_t... Is>
428
+ XSIMD_INLINE constexpr batch_bool_constant<T, A, ((static_cast<bool>(Is) | true) & Val)...>
429
+ make_batch_bool_constant(std::index_sequence<Is...>) noexcept
430
+ {
431
+ return {};
432
+ }
433
+
434
+ #if __cplusplus >= 202002L
435
+ template <typename T, std::array Arr, class A, std::size_t... Is>
436
+ XSIMD_INLINE constexpr batch_bool_constant<T, A, Arr[Is]...>
437
+ make_batch_bool_constant(std::index_sequence<Is...>) noexcept
438
+ {
439
+ return {};
440
+ }
441
+ #endif
442
+
443
+ } // namespace detail
444
+
445
+ /**
446
+ * @brief Build a @c batch_constant out of a generator function
447
+ *
448
+ * @tparam batch_type type of the (non-constant) batch to build
449
+ * @tparam G type used to generate that batch. That type must have a static
450
+ * member @c get that's used to generate the batch constant. Conversely, the
451
+ * generated batch_constant has value `{G::get(0, batch_size), ... , G::get(batch_size - 1, batch_size)}`
452
+ *
453
+ * The following generator produces a batch of `(n - 1, 0, 1, ... n-2)`
454
+ *
455
+ * @code
456
+ * struct Rot
457
+ * {
458
+ * static constexpr unsigned get(unsigned i, unsigned n)
459
+ * {
460
+ * return (i + n - 1) % n;
461
+ * }
462
+ * };
463
+ * @endcode
464
+ */
465
+ template <typename T, class G, class A = default_arch>
466
+ XSIMD_INLINE constexpr decltype(detail::make_batch_constant<T, G, A>(std::make_index_sequence<batch<T, A>::size>()))
467
+ make_batch_constant() noexcept
468
+ {
469
+ return {};
470
+ }
471
+
472
+ /**
473
+ * @brief Build a @c batch_bool_constant out of a generator function
474
+ *
475
+ * Similar to @c make_batch_constant for @c batch_bool_constant
476
+ */
477
+ template <typename T, class G, class A = default_arch>
478
+ XSIMD_INLINE constexpr decltype(detail::make_batch_bool_constant<T, G, A>(std::make_index_sequence<batch<T, A>::size>()))
479
+ make_batch_bool_constant() noexcept
480
+ {
481
+ return {};
482
+ }
483
+
484
+ // FIXME: Skipping those for doxygen because of bad interaction with breathe.
485
+ #ifndef DOXYGEN_SHOULD_SKIP_THIS
486
+ /**
487
+ * @brief Build a @c batch_constant with a single repeated value.
488
+ *
489
+ * @tparam T type of the data held in the batch.
490
+ * @tparam Val The value to repeat.
491
+ * @tparam A Architecture that will be used when converting to a regular batch.
492
+ */
493
+ template <typename T, T Val, class A = default_arch>
494
+ XSIMD_INLINE constexpr decltype(detail::make_batch_constant<T, Val, A>(std::make_index_sequence<batch<T, A>::size>()))
495
+ make_batch_constant() noexcept
496
+ {
497
+ return {};
498
+ }
499
+
500
+ #if __cplusplus >= 202002L
501
+ /**
502
+ * @brief Build a @c batch_constant from a std::array (C++20)
503
+ *
504
+ * @tparam Arr The std::array containing the values (non type template argument).
505
+ * @tparam A Architecture that will be used when converting to a regular batch.
506
+ */
507
+ template <std::array Arr, class A = default_arch>
508
+ requires(Arr.size() == batch<typename decltype(Arr)::value_type, A>::size)
509
+ XSIMD_INLINE constexpr auto make_batch_constant() noexcept
510
+ {
511
+ return detail::make_batch_constant<Arr, A>(std::make_index_sequence<Arr.size()>());
512
+ }
513
+ #endif
514
+
515
+ /*
516
+ * @brief Build a @c batch_bool_constant with a single repeated value.
517
+ *
518
+ * Similar to @c make_batch_constant for @c batch_bool_constant
519
+ */
520
+ template <typename T, bool Val, class A = default_arch>
521
+ XSIMD_INLINE constexpr decltype(detail::make_batch_bool_constant<T, Val, A>(std::make_index_sequence<batch<T, A>::size>()))
522
+ make_batch_bool_constant() noexcept
523
+ {
524
+ return {};
525
+ }
526
+
527
+ #if __cplusplus >= 202002L
528
+ /**
529
+ * @brief Build a @c batch_constant from a std::array of boolean (C++20)
530
+ *
531
+ * @tparam Arr The std::array containing the boolean values (non type template argument).
532
+ * @tparam A Architecture that will be used when converting to a regular batch.
533
+ */
534
+ template <typename T, std::array Arr, class A = default_arch>
535
+ requires(
536
+ (Arr.size() == batch_bool<T, A>::size)
537
+ && std::is_same_v<typename decltype(Arr)::value_type, bool>)
538
+ XSIMD_INLINE constexpr auto make_batch_bool_constant() noexcept
539
+ {
540
+ return detail::make_batch_bool_constant<T, Arr, A>(std::make_index_sequence<Arr.size()>());
541
+ }
542
+ #endif
543
+
544
+ #endif
545
+
546
+ namespace generator
547
+ {
548
+ template <class T>
549
+ struct iota
550
+ {
551
+ static constexpr T get(size_t index, size_t)
552
+ {
553
+ return static_cast<T>(index);
554
+ }
555
+ };
556
+ }
557
+ /**
558
+ * @brief Build a @c batch_constant as an enumerated range
559
+ *
560
+ * @tparam T type of the data held in the batch.
561
+ * @tparam A Architecture that will be used when converting to a regular batch.
562
+ */
563
+ template <typename T, class A = default_arch>
564
+ XSIMD_INLINE constexpr auto make_iota_batch_constant() noexcept
565
+ {
566
+ return make_batch_constant<T, generator::iota<T>, A>();
567
+ }
568
+
569
+ } // namespace xsimd
570
+
571
+ #endif
@@ -0,0 +1,41 @@
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_FWD_HPP
13
+ #define XSIMD_BATCH_FWD_HPP
14
+
15
+ #include "../config/xsimd_config.hpp"
16
+
17
+ // TODO this is somehow redundant with XSIMD_DEFAULT_ARCH but is only supported
18
+ // when an architecture is defined.
19
+ #if defined(XSIMD_NO_SUPPORTED_ARCHITECTURE)
20
+ #define XSIMD_BATCH_DEFAULT_ARCH_IMPL void
21
+ #else
22
+ #include "../config/xsimd_arch.hpp"
23
+ #define XSIMD_BATCH_DEFAULT_ARCH_IMPL default_arch
24
+ #endif // XSIMD_NO_SUPPORTED_ARCHITECTURE
25
+
26
+ namespace xsimd
27
+ {
28
+ template <class T, class A = XSIMD_BATCH_DEFAULT_ARCH_IMPL>
29
+ class batch_bool;
30
+
31
+ template <typename T, class A, bool... Values>
32
+ struct batch_bool_constant;
33
+
34
+ template <class T, class A = XSIMD_BATCH_DEFAULT_ARCH_IMPL>
35
+ class batch;
36
+
37
+ template <typename T, class A, T... Values>
38
+ struct batch_constant;
39
+ }
40
+
41
+ #endif
@@ -0,0 +1,49 @@
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_ARCH_HPP
13
+ #define XSIMD_COMMON_ARCH_HPP
14
+
15
+ #include <cstddef>
16
+
17
+ #include "../config/xsimd_config.hpp"
18
+
19
+ /**
20
+ * @defgroup architectures Architecture description
21
+ * */
22
+ namespace xsimd
23
+ {
24
+ /**
25
+ * @ingroup architectures
26
+ *
27
+ * Base class for all architectures.
28
+ */
29
+ struct common
30
+ {
31
+ /// Whether this architecture is supported at compile-time.
32
+ static constexpr bool supported() noexcept { return true; }
33
+ /// Whether this architecture is available at run-time.
34
+ static constexpr bool available() noexcept { return true; }
35
+ /// If this architectures supports aligned memory accesses, the required
36
+ /// alignment.
37
+ static constexpr std::size_t alignment() noexcept { return 0; }
38
+ /// Whether this architecture requires aligned memory access.
39
+ static constexpr bool requires_alignment() noexcept { return false; }
40
+ /// Name of the architecture.
41
+ static constexpr char const* name() noexcept { return "common"; }
42
+ };
43
+
44
+ struct unsupported
45
+ {
46
+ };
47
+ }
48
+
49
+ #endif