react-native-executorch 0.10.6 → 0.10.7

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 (237) hide show
  1. package/lib/module/fetcher/telemetry.js +1 -1
  2. package/package.json +1 -1
  3. package/react-native-executorch.podspec +2 -0
  4. package/src/fetcher/telemetry.ts +1 -1
  5. package/third-party/common/phonemis/CMakeLists.txt +70 -14
  6. package/third-party/common/phonemis/README.md +183 -33
  7. package/third-party/common/phonemis/THIRD_PARTY_NOTICES.md +57 -0
  8. package/third-party/common/phonemis/knowledge/code_style.md +642 -0
  9. package/third-party/common/phonemis/licenses/Unicode-3.0.txt +39 -0
  10. package/third-party/common/phonemis/licenses/misaki-Apache-2.0.txt +201 -0
  11. package/third-party/common/phonemis/licenses/nlohmann-json-MIT.txt +21 -0
  12. package/third-party/common/phonemis/licenses/xsimd-BSD-3-Clause.txt +29 -0
  13. package/third-party/common/phonemis/src/phonemis/base/config.h +6 -0
  14. package/third-party/common/phonemis/src/phonemis/base/ipipeline.cpp +75 -0
  15. package/third-party/common/phonemis/src/phonemis/base/ipipeline.h +21 -0
  16. package/third-party/common/phonemis/src/phonemis/base/phonemizer/constants.h +2 -5
  17. package/third-party/common/phonemis/src/phonemis/base/phonemizer/lexicon_phonemizer.cpp +3 -4
  18. package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/neural_phonemizer.cpp +17 -8
  19. package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/neural_phonemizer.h +4 -0
  20. package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/tokenizer.cpp +21 -6
  21. package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/tokenizer.h +13 -4
  22. package/third-party/common/phonemis/src/phonemis/base/pipeline.cpp +8 -0
  23. package/third-party/common/phonemis/src/phonemis/base/pipeline.h +19 -0
  24. package/third-party/common/phonemis/src/phonemis/base/processor/common/conditions.cpp +37 -0
  25. package/third-party/common/phonemis/src/phonemis/base/processor/common/conditions.h +45 -0
  26. package/third-party/common/phonemis/src/phonemis/base/processor/common/constants.h +10 -0
  27. package/third-party/common/phonemis/src/phonemis/base/processor/common/context.cpp +105 -0
  28. package/third-party/common/phonemis/src/phonemis/base/processor/common/context.h +49 -0
  29. package/third-party/common/phonemis/src/phonemis/base/processor/common/document.cpp +173 -0
  30. package/third-party/common/phonemis/src/phonemis/base/processor/common/document.h +67 -0
  31. package/third-party/common/phonemis/src/phonemis/base/processor/common/text.cpp +75 -0
  32. package/third-party/common/phonemis/src/phonemis/base/processor/common/text.h +60 -0
  33. package/third-party/common/phonemis/src/phonemis/base/processor/common/types.h +18 -0
  34. package/third-party/common/phonemis/src/phonemis/base/processor/config.h +53 -0
  35. package/third-party/common/phonemis/src/phonemis/base/processor/layer.h +9 -7
  36. package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/constants.h +20 -0
  37. package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/layer.cpp +89 -0
  38. package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/layer.h +35 -0
  39. package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/types.h +16 -0
  40. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/kind.h +40 -0
  41. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/layer.h +382 -0
  42. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/notation.h +30 -0
  43. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/numerals.cpp +51 -0
  44. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/numerals.h +31 -0
  45. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern.h +30 -0
  46. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern_set.cpp +17 -0
  47. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern_set.h +31 -0
  48. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/patterns.cpp +811 -0
  49. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/patterns.h +285 -0
  50. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/primitives.cpp +64 -0
  51. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/primitives.h +23 -0
  52. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/types.h +94 -0
  53. package/third-party/common/phonemis/src/phonemis/base/processor/layers/sanitizer/layer.cpp +19 -0
  54. package/third-party/common/phonemis/src/phonemis/base/processor/{sanitizer_layer.h → layers/sanitizer/layer.h} +8 -8
  55. package/third-party/common/phonemis/src/phonemis/base/processor/layers/sym2word/layer.cpp +65 -0
  56. package/third-party/common/phonemis/src/phonemis/base/processor/layers/sym2word/layer.h +29 -0
  57. package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/layer.cpp +170 -0
  58. package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/layer.h +40 -0
  59. package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/types.h +25 -0
  60. package/third-party/common/phonemis/src/phonemis/base/processor/layers/trim/layer.cpp +47 -0
  61. package/third-party/common/phonemis/src/phonemis/base/processor/layers/trim/layer.h +19 -0
  62. package/third-party/common/phonemis/src/phonemis/base/processor/preprocessor.cpp +60 -0
  63. package/third-party/common/phonemis/src/phonemis/base/processor/preprocessor.h +45 -0
  64. package/third-party/common/phonemis/src/phonemis/base/processor/processor.cpp +6 -7
  65. package/third-party/common/phonemis/src/phonemis/base/processor/processor.h +14 -10
  66. package/third-party/common/phonemis/src/phonemis/base/tagger/hmm_tagger.cpp +89 -52
  67. package/third-party/common/phonemis/src/phonemis/base/tagger/hmm_tagger.h +16 -9
  68. package/third-party/common/phonemis/src/phonemis/base/tokenizer/tokenizer.cpp +13 -12
  69. package/third-party/common/phonemis/src/phonemis/lang/de/constants.h +183 -19
  70. package/third-party/common/phonemis/src/phonemis/lang/de/num2word.cpp +355 -309
  71. package/third-party/common/phonemis/src/phonemis/lang/de/num2word.h +42 -17
  72. package/third-party/common/phonemis/src/phonemis/lang/de/patterns.cpp +56 -0
  73. package/third-party/common/phonemis/src/phonemis/lang/de/patterns.h +15 -0
  74. package/third-party/common/phonemis/src/phonemis/lang/de/pipeline.h +3 -3
  75. package/third-party/common/phonemis/src/phonemis/lang/en/constants.h +181 -30
  76. package/third-party/common/phonemis/src/phonemis/lang/en/hmm_tagger.cpp +5 -7
  77. package/third-party/common/phonemis/src/phonemis/lang/en/num2word.cpp +232 -135
  78. package/third-party/common/phonemis/src/phonemis/lang/en/num2word.h +41 -16
  79. package/third-party/common/phonemis/src/phonemis/lang/en/pipeline.h +3 -10
  80. package/third-party/common/phonemis/src/phonemis/lang/es/constants.h +182 -60
  81. package/third-party/common/phonemis/src/phonemis/lang/es/num2word.cpp +247 -212
  82. package/third-party/common/phonemis/src/phonemis/lang/es/num2word.h +38 -18
  83. package/third-party/common/phonemis/src/phonemis/lang/es/patterns.cpp +50 -0
  84. package/third-party/common/phonemis/src/phonemis/lang/es/patterns.h +15 -0
  85. package/third-party/common/phonemis/src/phonemis/lang/es/pipeline.h +3 -3
  86. package/third-party/common/phonemis/src/phonemis/lang/fr/constants.h +152 -26
  87. package/third-party/common/phonemis/src/phonemis/lang/fr/num2word.cpp +252 -179
  88. package/third-party/common/phonemis/src/phonemis/lang/fr/num2word.h +38 -15
  89. package/third-party/common/phonemis/src/phonemis/lang/fr/patterns.cpp +83 -0
  90. package/third-party/common/phonemis/src/phonemis/lang/fr/patterns.h +15 -0
  91. package/third-party/common/phonemis/src/phonemis/lang/fr/pipeline.h +3 -3
  92. package/third-party/common/phonemis/src/phonemis/lang/hi/constants.h +62 -10
  93. package/third-party/common/phonemis/src/phonemis/lang/hi/num2word.cpp +74 -123
  94. package/third-party/common/phonemis/src/phonemis/lang/hi/num2word.h +27 -16
  95. package/third-party/common/phonemis/src/phonemis/lang/hi/pipeline.h +5 -3
  96. package/third-party/common/phonemis/src/phonemis/lang/it/constants.h +122 -42
  97. package/third-party/common/phonemis/src/phonemis/lang/it/num2word.cpp +200 -207
  98. package/third-party/common/phonemis/src/phonemis/lang/it/num2word.h +30 -18
  99. package/third-party/common/phonemis/src/phonemis/lang/it/patterns.cpp +25 -0
  100. package/third-party/common/phonemis/src/phonemis/lang/it/patterns.h +15 -0
  101. package/third-party/common/phonemis/src/phonemis/lang/it/pipeline.h +3 -3
  102. package/third-party/common/phonemis/src/phonemis/lang/pl/constants.h +346 -77
  103. package/third-party/common/phonemis/src/phonemis/lang/pl/num2word.cpp +631 -246
  104. package/third-party/common/phonemis/src/phonemis/lang/pl/num2word.h +47 -15
  105. package/third-party/common/phonemis/src/phonemis/lang/pl/pipeline.h +6 -6
  106. package/third-party/common/phonemis/src/phonemis/lang/pt/constants.h +201 -0
  107. package/third-party/common/phonemis/src/phonemis/lang/pt/num2word.cpp +365 -0
  108. package/third-party/common/phonemis/src/phonemis/lang/pt/num2word.h +53 -0
  109. package/third-party/common/phonemis/src/phonemis/lang/pt/pipeline.h +4 -2
  110. package/third-party/common/phonemis/src/phonemis/main.cpp +42 -11
  111. package/third-party/common/phonemis/src/phonemis/protophone/meta.h +24 -0
  112. package/third-party/common/phonemis/src/phonemis/protophone/numeric.h +26 -0
  113. package/third-party/common/phonemis/src/phonemis/protophone/protophone.cpp +525 -0
  114. package/third-party/common/phonemis/src/phonemis/protophone/protophone.h +80 -0
  115. package/third-party/common/phonemis/src/phonemis/protophone/tensor.h +76 -0
  116. package/third-party/common/phonemis/src/phonemis/protophone/tensor_utils.h +89 -0
  117. package/third-party/common/phonemis/src/phonemis/protophone/tensor_view.h +125 -0
  118. package/third-party/common/phonemis/src/phonemis/protophone/types.h +43 -0
  119. package/third-party/common/phonemis/src/phonemis/utils/strings.h +20 -14
  120. package/third-party/common/phonemis/src/phonemis/utils/unicode.h +15 -1
  121. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_arithmetic.hpp +267 -0
  122. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_bit.hpp +232 -0
  123. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_cast.hpp +43 -0
  124. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_complex.hpp +112 -0
  125. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_details.hpp +386 -0
  126. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_logical.hpp +240 -0
  127. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_math.hpp +2601 -0
  128. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_memory.hpp +1006 -0
  129. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_rounding.hpp +72 -0
  130. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_swizzle.hpp +260 -0
  131. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_trigo.hpp +996 -0
  132. package/third-party/common/phonemis/src/third-party/xsimd/arch/utils/shifts.hpp +82 -0
  133. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx.hpp +2111 -0
  134. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx2.hpp +1591 -0
  135. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx2_128.hpp +170 -0
  136. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512bw.hpp +724 -0
  137. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512cd.hpp +28 -0
  138. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512dq.hpp +270 -0
  139. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512er.hpp +17 -0
  140. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512f.hpp +2919 -0
  141. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512ifma.hpp +17 -0
  142. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512pf.hpp +17 -0
  143. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vbmi.hpp +76 -0
  144. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vbmi2.hpp +130 -0
  145. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp +17 -0
  146. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vnni_avx512vbmi2.hpp +17 -0
  147. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx_128.hpp +164 -0
  148. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avxvnni.hpp +17 -0
  149. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_common.hpp +26 -0
  150. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_common_fwd.hpp +127 -0
  151. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_constants.hpp +393 -0
  152. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_emulated.hpp +787 -0
  153. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_avx.hpp +93 -0
  154. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_avx2.hpp +46 -0
  155. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_sse.hpp +97 -0
  156. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma4.hpp +92 -0
  157. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_i8mm_neon64.hpp +17 -0
  158. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_isa.hpp +148 -0
  159. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_neon.hpp +3580 -0
  160. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_neon64.hpp +1614 -0
  161. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_rvv.hpp +1515 -0
  162. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_scalar.hpp +1210 -0
  163. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse2.hpp +2333 -0
  164. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse3.hpp +66 -0
  165. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse4_1.hpp +510 -0
  166. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse4_2.hpp +44 -0
  167. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_ssse3.hpp +186 -0
  168. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sve.hpp +1186 -0
  169. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_vsx.hpp +947 -0
  170. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_vxe.hpp +787 -0
  171. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_wasm.hpp +1819 -0
  172. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_arch.hpp +242 -0
  173. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_config.hpp +633 -0
  174. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features.hpp +50 -0
  175. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_arm.hpp +132 -0
  176. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_ppc.hpp +54 -0
  177. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_riscv.hpp +95 -0
  178. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_s390x.hpp +56 -0
  179. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_x86.hpp +1121 -0
  180. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpuid.hpp +144 -0
  181. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_getauxval.hpp +159 -0
  182. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_macros.hpp +78 -0
  183. package/third-party/common/phonemis/src/third-party/xsimd/math/xsimd_rem_pio2.hpp +707 -0
  184. package/third-party/common/phonemis/src/third-party/xsimd/memory/xsimd_aligned_allocator.hpp +349 -0
  185. package/third-party/common/phonemis/src/third-party/xsimd/memory/xsimd_alignment.hpp +102 -0
  186. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_all_registers.hpp +57 -0
  187. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_api.hpp +3106 -0
  188. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx2_register.hpp +57 -0
  189. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512bw_register.hpp +51 -0
  190. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512cd_register.hpp +51 -0
  191. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512dq_register.hpp +51 -0
  192. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512er_register.hpp +51 -0
  193. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512f_register.hpp +77 -0
  194. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512ifma_register.hpp +51 -0
  195. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512pf_register.hpp +51 -0
  196. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vbmi2_register.hpp +51 -0
  197. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vbmi_register.hpp +51 -0
  198. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp +54 -0
  199. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vnni_avx512vbmi2_register.hpp +53 -0
  200. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx_register.hpp +79 -0
  201. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avxvnni_register.hpp +44 -0
  202. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch.hpp +1666 -0
  203. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch_constant.hpp +572 -0
  204. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch_fwd.hpp +41 -0
  205. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_common_arch.hpp +49 -0
  206. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_emulated_register.hpp +80 -0
  207. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_avx2_register.hpp +50 -0
  208. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_avx_register.hpp +50 -0
  209. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_sse_register.hpp +50 -0
  210. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma4_register.hpp +50 -0
  211. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_i8mm_neon64_register.hpp +55 -0
  212. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_neon64_register.hpp +55 -0
  213. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_neon_register.hpp +130 -0
  214. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_register.hpp +96 -0
  215. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_rvv_register.hpp +491 -0
  216. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse2_register.hpp +59 -0
  217. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse3_register.hpp +49 -0
  218. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse4_1_register.hpp +48 -0
  219. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse4_2_register.hpp +48 -0
  220. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_ssse3_register.hpp +48 -0
  221. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sve_register.hpp +216 -0
  222. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_traits.hpp +409 -0
  223. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_utils.hpp +462 -0
  224. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_vsx_register.hpp +84 -0
  225. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_vxe_register.hpp +86 -0
  226. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_wasm_register.hpp +59 -0
  227. package/third-party/common/phonemis/src/third-party/xsimd/utils/bits.hpp +122 -0
  228. package/third-party/common/phonemis/src/third-party/xsimd/utils/xsimd_type_traits.hpp +145 -0
  229. package/third-party/common/phonemis/src/third-party/xsimd/xsimd.hpp +43 -0
  230. package/third-party/common/phonemis/src/phonemis/base/processor/constants.h +0 -11
  231. package/third-party/common/phonemis/src/phonemis/base/processor/num2word/config.h +0 -16
  232. package/third-party/common/phonemis/src/phonemis/base/processor/num2word/layer.cpp +0 -271
  233. package/third-party/common/phonemis/src/phonemis/base/processor/num2word/layer.h +0 -45
  234. package/third-party/common/phonemis/src/phonemis/base/processor/num2word/types.h +0 -29
  235. package/third-party/common/phonemis/src/phonemis/base/processor/sanitizer_layer.cpp +0 -22
  236. package/third-party/common/phonemis/src/phonemis/base/processor/trim_layer.cpp +0 -40
  237. package/third-party/common/phonemis/src/phonemis/base/processor/trim_layer.h +0 -22
@@ -0,0 +1,3106 @@
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_API_HPP
13
+ #define XSIMD_API_HPP
14
+
15
+ #include <complex>
16
+ #include <cstddef>
17
+ #include <limits>
18
+ #include <ostream>
19
+
20
+ #include "../arch/xsimd_isa.hpp"
21
+ #include "../types/xsimd_batch.hpp"
22
+ #include "../types/xsimd_traits.hpp"
23
+ #include "../utils/xsimd_type_traits.hpp"
24
+
25
+ namespace xsimd
26
+ {
27
+ /**
28
+ * high level free functions
29
+ *
30
+ * @defgroup batch_arithmetic Arithmetic operators
31
+ * @defgroup batch_constant Constant batches
32
+ * @defgroup batch_cond Conditional operators
33
+ * @defgroup batch_data_transfer Memory operators
34
+ * @defgroup batch_math Basic math operators
35
+ * @defgroup batch_math_extra Extra math operators
36
+ * @defgroup batch_fp Floating point manipulation
37
+ * @defgroup batch_rounding Rounding operators
38
+ * @defgroup batch_conversion Conversion operators
39
+ * @defgroup batch_complex Complex operators
40
+ * @defgroup batch_logical Logical operators
41
+ * @defgroup batch_bitwise Bitwise operators
42
+ * @defgroup batch_reducers Reducers
43
+ * @defgroup batch_miscellaneous Miscellaneous
44
+ * @defgroup batch_trigo Trigonometry
45
+ *
46
+ * @defgroup batch_bool_logical Boolean logical operators
47
+ * @defgroup batch_bool_reducers Boolean reducers
48
+ */
49
+
50
+ /**
51
+ * @ingroup batch_math
52
+ *
53
+ * Computes the absolute values of each scalar in the batch \c x.
54
+ * @param x batch of integer or floating point values.
55
+ * @return the absolute values of \c x.
56
+ */
57
+ template <class T, class A>
58
+ XSIMD_INLINE batch<T, A> abs(batch<T, A> const& x) noexcept
59
+ {
60
+ detail::static_check_supported_config<T, A>();
61
+ return kernel::abs<A>(x, A {});
62
+ }
63
+
64
+ /**
65
+ * @ingroup batch_complex
66
+ *
67
+ * Computes the absolute values of each complex in the batch \c z.
68
+ * @param z batch of complex values.
69
+ * @return the absolute values of \c z.
70
+ */
71
+ template <class T, class A>
72
+ XSIMD_INLINE batch<T, A> abs(batch<std::complex<T>, A> const& z) noexcept
73
+ {
74
+ detail::static_check_supported_config<T, A>();
75
+ return kernel::abs<A>(z, A {});
76
+ }
77
+
78
+ /**
79
+ * @ingroup batch_arithmetic
80
+ *
81
+ * Computes the sum of the batches \c x and \c y.
82
+ * @param x batch or scalar involved in the addition.
83
+ * @param y batch or scalar involved in the addition.
84
+ * @return the sum of \c x and \c y
85
+ */
86
+ template <class T, class A>
87
+ XSIMD_INLINE batch<T, A> add(batch<T, A> const& x, batch<T, A> const& y) noexcept
88
+ {
89
+ detail::static_check_supported_config<T, A>();
90
+ return x + y;
91
+ }
92
+
93
+ /**
94
+ * @ingroup batch_trigo
95
+ *
96
+ * Computes the arc cosine of the batch \c x.
97
+ * @param x batch of floating point values.
98
+ * @return the arc cosine of \c x.
99
+ */
100
+ template <class T, class A>
101
+ XSIMD_INLINE batch<T, A> acos(batch<T, A> const& x) noexcept
102
+ {
103
+ detail::static_check_supported_config<T, A>();
104
+ return kernel::acos<A>(x, A {});
105
+ }
106
+
107
+ /**
108
+ * @ingroup batch_trigo
109
+ *
110
+ * Computes the inverse hyperbolic cosine of the batch \c x.
111
+ * @param x batch of floating point values.
112
+ * @return the inverse hyperbolic cosine of \c x.
113
+ */
114
+ template <class T, class A>
115
+ XSIMD_INLINE batch<T, A> acosh(batch<T, A> const& x) noexcept
116
+ {
117
+ detail::static_check_supported_config<T, A>();
118
+ return kernel::acosh<A>(x, A {});
119
+ }
120
+
121
+ /**
122
+ * @ingroup batch_complex
123
+ *
124
+ * Computes the argument of the batch \c z.
125
+ * @param z batch of complex or real values.
126
+ * @return the argument of \c z.
127
+ */
128
+ template <class T, class A>
129
+ XSIMD_INLINE real_batch_type_t<batch<T, A>> arg(batch<T, A> const& z) noexcept
130
+ {
131
+ detail::static_check_supported_config<T, A>();
132
+ return kernel::arg<A>(z, A {});
133
+ }
134
+
135
+ /**
136
+ * @ingroup batch_trigo
137
+ *
138
+ * Computes the arc sine of the batch \c x.
139
+ * @param x batch of floating point values.
140
+ * @return the arc sine of \c x.
141
+ */
142
+ template <class T, class A>
143
+ XSIMD_INLINE batch<T, A> asin(batch<T, A> const& x) noexcept
144
+ {
145
+ detail::static_check_supported_config<T, A>();
146
+ return kernel::asin<A>(x, A {});
147
+ }
148
+
149
+ /**
150
+ * @ingroup batch_trigo
151
+ *
152
+ * Computes the inverse hyperbolic sine of the batch \c x.
153
+ * @param x batch of floating point values.
154
+ * @return the inverse hyperbolic sine of \c x.
155
+ */
156
+ template <class T, class A>
157
+ XSIMD_INLINE batch<T, A> asinh(batch<T, A> const& x) noexcept
158
+ {
159
+ detail::static_check_supported_config<T, A>();
160
+ return kernel::asinh<A>(x, A {});
161
+ }
162
+
163
+ /**
164
+ * @ingroup batch_trigo
165
+ *
166
+ * Computes the arc tangent of the batch \c x.
167
+ * @param x batch of floating point values.
168
+ * @return the arc tangent of \c x.
169
+ */
170
+ template <class T, class A>
171
+ XSIMD_INLINE batch<T, A> atan(batch<T, A> const& x) noexcept
172
+ {
173
+ detail::static_check_supported_config<T, A>();
174
+ return kernel::atan<A>(x, A {});
175
+ }
176
+
177
+ /**
178
+ * @ingroup batch_trigo
179
+ *
180
+ * Computes the arc tangent of the batch \c x/y, using the signs of the
181
+ * arguments to determine the correct quadrant.
182
+ * @param x batch of floating point values.
183
+ * @param y batch of floating point values.
184
+ * @return the arc tangent of \c x/y.
185
+ */
186
+ template <class T, class A>
187
+ XSIMD_INLINE batch<T, A> atan2(batch<T, A> const& x, batch<T, A> const& y) noexcept
188
+ {
189
+ detail::static_check_supported_config<T, A>();
190
+ return kernel::atan2<A>(x, y, A {});
191
+ }
192
+
193
+ /**
194
+ * @ingroup batch_trigo
195
+ *
196
+ * Computes the inverse hyperbolic tangent of the batch \c x.
197
+ * @param x batch of floating point values.
198
+ * @return the inverse hyperbolic tangent of \c x.
199
+ */
200
+ template <class T, class A>
201
+ XSIMD_INLINE batch<T, A> atanh(batch<T, A> const& x) noexcept
202
+ {
203
+ detail::static_check_supported_config<T, A>();
204
+ return kernel::atanh<A>(x, A {});
205
+ }
206
+
207
+ /**
208
+ * @ingroup batch_math
209
+ *
210
+ * Computes the average of batches \c x and \c y
211
+ * @param x batch of T
212
+ * @param y batch of T
213
+ * @return the average of elements between \c x and \c y.
214
+ */
215
+ template <class T, class A>
216
+ XSIMD_INLINE batch<T, A> avg(batch<T, A> const& x, batch<T, A> const& y) noexcept
217
+ {
218
+ detail::static_check_supported_config<T, A>();
219
+ return kernel::avg<A>(x, y, A {});
220
+ }
221
+
222
+ /**
223
+ * @ingroup batch_math
224
+ *
225
+ * Computes the rounded average of batches \c x and \c y
226
+ * @param x batch of T
227
+ * @param y batch of T
228
+ * @return the rounded average of elements between \c x and \c y.
229
+ */
230
+ template <class T, class A>
231
+ XSIMD_INLINE batch<T, A> avgr(batch<T, A> const& x, batch<T, A> const& y) noexcept
232
+ {
233
+ detail::static_check_supported_config<T, A>();
234
+ return kernel::avgr<A>(x, y, A {});
235
+ }
236
+
237
+ /**
238
+ * @ingroup batch_conversion
239
+ *
240
+ * Perform a static_cast from \c T_in to \c T_out on \c x.
241
+ * @param x batch_bool of \c T_in
242
+ * @return \c x cast to \c T_out
243
+ */
244
+ template <class T_out, class T_in, class A>
245
+ XSIMD_INLINE batch_bool<T_out, A> batch_bool_cast(batch_bool<T_in, A> const& x) noexcept
246
+ {
247
+ detail::static_check_supported_config<T_out, A>();
248
+ detail::static_check_supported_config<T_in, A>();
249
+ static_assert(batch_bool<T_out, A>::size == batch_bool<T_in, A>::size, "Casting between incompatibles batch_bool types.");
250
+ return kernel::batch_bool_cast<A>(x, batch_bool<T_out, A> {}, A {});
251
+ }
252
+
253
+ /**
254
+ * @ingroup batch_conversion
255
+ *
256
+ * Perform a static_cast from \c T_in to \c T_out on \c x.
257
+ * @param x batch of \c T_in
258
+ * @return \c x cast to \c T_out
259
+ */
260
+ template <class T_out, class T_in, class A>
261
+ XSIMD_INLINE batch<T_out, A> batch_cast(batch<T_in, A> const& x) noexcept
262
+ {
263
+ detail::static_check_supported_config<T_out, A>();
264
+ detail::static_check_supported_config<T_in, A>();
265
+ return kernel::batch_cast<A>(x, batch<T_out, A> {}, A {});
266
+ }
267
+
268
+ /**
269
+ * @ingroup batch_miscellaneous
270
+ *
271
+ * Computes the bit of sign of \c x
272
+ * @param x batch of scalar
273
+ * @return bit of sign of \c x
274
+ */
275
+ template <class T, class A>
276
+ XSIMD_INLINE batch<T, A> bitofsign(batch<T, A> const& x) noexcept
277
+ {
278
+ detail::static_check_supported_config<T, A>();
279
+ return kernel::bitofsign<A>(x, A {});
280
+ }
281
+
282
+ /**
283
+ * @ingroup batch_bitwise
284
+ *
285
+ * Computes the bitwise and of the batches \c x and \c y.
286
+ * @param x batch involved in the operation.
287
+ * @param y batch involved in the operation.
288
+ * @return the result of the bitwise and.
289
+ */
290
+ template <class T, class A>
291
+ XSIMD_INLINE batch<T, A> bitwise_and(batch<T, A> const& x, batch<T, A> const& y) noexcept
292
+ {
293
+ detail::static_check_supported_config<T, A>();
294
+ return x & y;
295
+ }
296
+
297
+ /**
298
+ * @ingroup batch_bitwise
299
+ *
300
+ * Computes the bitwise and of the batches \c x and \c y.
301
+ * @param x batch involved in the operation.
302
+ * @param y batch involved in the operation.
303
+ * @return the result of the bitwise and.
304
+ */
305
+ template <class T, class A>
306
+ XSIMD_INLINE batch_bool<T, A> bitwise_and(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
307
+ {
308
+ detail::static_check_supported_config<T, A>();
309
+ return x & y;
310
+ }
311
+
312
+ /**
313
+ * @ingroup batch_bitwise
314
+ *
315
+ * Computes the bitwise and not of batches \c x and \c y.
316
+ * @param x batch involved in the operation.
317
+ * @param y batch involved in the operation.
318
+ * @return the result of the bitwise and not.
319
+ */
320
+ template <class T, class A>
321
+ XSIMD_INLINE batch<T, A> bitwise_andnot(batch<T, A> const& x, batch<T, A> const& y) noexcept
322
+ {
323
+ detail::static_check_supported_config<T, A>();
324
+ return kernel::bitwise_andnot<A>(x, y, A {});
325
+ }
326
+
327
+ /**
328
+ * @ingroup batch_bool_logical
329
+ *
330
+ * Computes the bitwise and not of batches \c x and \c y.
331
+ * @param x batch involved in the operation.
332
+ * @param y batch involved in the operation.
333
+ * @return the result of the bitwise and not.
334
+ */
335
+ template <class T, class A>
336
+ XSIMD_INLINE batch_bool<T, A> bitwise_andnot(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
337
+ {
338
+ detail::static_check_supported_config<T, A>();
339
+ return kernel::bitwise_andnot<A>(x, y, A {});
340
+ }
341
+
342
+ /**
343
+ * @ingroup batch_conversion
344
+ *
345
+ * Perform a reinterpret_cast from \c T_in to \c T_out on \c x.
346
+ * @param x batch of \c T_in
347
+ * @return \c x reinterpreted as \c T_out
348
+ */
349
+ template <class T_out, class T_in, class A>
350
+ XSIMD_INLINE batch<T_out, A> bitwise_cast(batch<T_in, A> const& x) noexcept
351
+ {
352
+ detail::static_check_supported_config<T_in, A>();
353
+ detail::static_check_supported_config<T_out, A>();
354
+ return kernel::bitwise_cast<A>(x, batch<T_out, A> {}, A {});
355
+ }
356
+
357
+ namespace detail
358
+ {
359
+ // Detection for kernel overloads accepting ``batch_constant`` in ``bitwise_lshift``
360
+ // directly (or in a parent register function).
361
+ // The ``batch_constant`` overload is a rare but useful optimization.
362
+ // Running the detection here is less error prone than to add a fallback to all
363
+ // architectures.
364
+
365
+ template <class Arch, class Batch, class BatchConstant, class = void>
366
+ struct has_bitwise_lshift_batch_const : std::false_type
367
+ {
368
+ };
369
+
370
+ template <class Arch, class Batch, class BatchConstant>
371
+ struct has_bitwise_lshift_batch_const<
372
+ Arch, Batch, BatchConstant,
373
+ void_t<decltype(kernel::bitwise_lshift<Arch>(
374
+ std::declval<Batch>(), std::declval<BatchConstant>(), Arch {}))>>
375
+ : std::true_type
376
+ {
377
+ };
378
+
379
+ template <class Arch, class T, T... Values>
380
+ XSIMD_INLINE batch<T, Arch> bitwise_lshift_batch_const(batch<T, Arch> const& x, batch_constant<T, Arch, Values...> shift, std::true_type) noexcept
381
+ {
382
+ // Optimized ``batch_constant`` implementation
383
+ return kernel::bitwise_lshift<Arch>(x, shift, Arch {});
384
+ }
385
+
386
+ template <class Arch, class T, T... Values>
387
+ XSIMD_INLINE batch<T, Arch> bitwise_lshift_batch_const(batch<T, Arch> const& x, batch_constant<T, Arch, Values...> shift, std::false_type) noexcept
388
+ {
389
+ // Fallback to regular run-time implementation
390
+ return kernel::bitwise_lshift<Arch>(x, shift.as_batch(), Arch {});
391
+ }
392
+ }
393
+
394
+ /**
395
+ * @ingroup batch_bitwise
396
+ *
397
+ * Perform a bitwise shift to the left
398
+ * @param x batch of \c T_in
399
+ * @param shift scalar amount to shift
400
+ * @return shifted \c x.
401
+ */
402
+ template <class T, class A>
403
+ XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, int shift) noexcept
404
+ {
405
+ detail::static_check_supported_config<T, A>();
406
+ return kernel::bitwise_lshift<A>(x, shift, A {});
407
+ }
408
+ template <size_t shift, class T, class A>
409
+ XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x) noexcept
410
+ {
411
+ detail::static_check_supported_config<T, A>();
412
+ return kernel::bitwise_lshift<shift, A>(x, A {});
413
+ }
414
+ template <class T, class A>
415
+ XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, batch<T, A> const& shift) noexcept
416
+ {
417
+ detail::static_check_supported_config<T, A>();
418
+ return kernel::bitwise_lshift<A>(x, shift, A {});
419
+ }
420
+ template <class T, class A, T... Values>
421
+ XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, batch_constant<T, A, Values...> shift) noexcept
422
+ {
423
+ detail::static_check_supported_config<T, A>();
424
+ using has_batch_const_impl = detail::has_bitwise_lshift_batch_const<A, decltype(x), decltype(shift)>;
425
+ return detail::bitwise_lshift_batch_const<A>(x, shift, has_batch_const_impl {});
426
+ }
427
+
428
+ /**
429
+ * @ingroup batch_bitwise
430
+ *
431
+ * Computes the bitwise not of batch \c x.
432
+ * @param x batch involved in the operation.
433
+ * @return the result of the bitwise not.
434
+ */
435
+ template <class T, class A>
436
+ XSIMD_INLINE batch<T, A> bitwise_not(batch<T, A> const& x) noexcept
437
+ {
438
+ detail::static_check_supported_config<T, A>();
439
+ return kernel::bitwise_not<A>(x, A {});
440
+ }
441
+
442
+ /**
443
+ * @ingroup batch_bitwise
444
+ *
445
+ * Computes the bitwise not of batch \c x.
446
+ * @param x batch involved in the operation.
447
+ * @return the result of the bitwise not.
448
+ */
449
+ template <class T, class A>
450
+ XSIMD_INLINE batch_bool<T, A> bitwise_not(batch_bool<T, A> const& x) noexcept
451
+ {
452
+ detail::static_check_supported_config<T, A>();
453
+ return kernel::bitwise_not<A>(x, A {});
454
+ }
455
+
456
+ /**
457
+ * @ingroup batch_bitwise
458
+ *
459
+ * Computes the bitwise or of the batches \c x and \c y.
460
+ * @param x scalar or batch of scalars
461
+ * @param y scalar or batch of scalars
462
+ * @return the result of the bitwise or.
463
+ */
464
+ template <class T, class A>
465
+ XSIMD_INLINE batch<T, A> bitwise_or(batch<T, A> const& x, batch<T, A> const& y) noexcept
466
+ {
467
+ detail::static_check_supported_config<T, A>();
468
+ return x | y;
469
+ }
470
+
471
+ /**
472
+ * @ingroup batch_bitwise
473
+ *
474
+ * Computes the bitwise or of the batches \c x and \c y.
475
+ * @param x scalar or batch of scalars
476
+ * @param y scalar or batch of scalars
477
+ * @return the result of the bitwise or.
478
+ */
479
+ template <class T, class A>
480
+ XSIMD_INLINE batch_bool<T, A> bitwise_or(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
481
+ {
482
+ detail::static_check_supported_config<T, A>();
483
+ return x | y;
484
+ }
485
+
486
+ /**
487
+ * @ingroup batch_bitwise
488
+ *
489
+ * Perform a bitwise shift to the right
490
+ * @param x batch of \c T_in
491
+ * @param shift scalar amount to shift
492
+ * @return shifted \c x.
493
+ */
494
+ template <class T, class A>
495
+ XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x, int shift) noexcept
496
+ {
497
+ detail::static_check_supported_config<T, A>();
498
+ return kernel::bitwise_rshift<A>(x, shift, A {});
499
+ }
500
+ template <class T, class A>
501
+ XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x, batch<T, A> const& shift) noexcept
502
+ {
503
+ detail::static_check_supported_config<T, A>();
504
+ return kernel::bitwise_rshift<A>(x, shift, A {});
505
+ }
506
+ template <size_t shift, class T, class A>
507
+ XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x) noexcept
508
+ {
509
+ detail::static_check_supported_config<T, A>();
510
+ return kernel::bitwise_rshift<shift, A>(x, A {});
511
+ }
512
+
513
+ /**
514
+ * @ingroup batch_bitwise
515
+ *
516
+ * Computes the bitwise xor of the batches \c x and \c y.
517
+ * @param x scalar or batch of scalars
518
+ * @param y scalar or batch of scalars
519
+ * @return the result of the bitwise xor.
520
+ */
521
+ template <class T, class A>
522
+ XSIMD_INLINE batch<T, A> bitwise_xor(batch<T, A> const& x, batch<T, A> const& y) noexcept
523
+ {
524
+ detail::static_check_supported_config<T, A>();
525
+ return x ^ y;
526
+ }
527
+
528
+ /**
529
+ * @ingroup batch_bitwise
530
+ *
531
+ * Computes the bitwise xor of the batches \c x and \c y.
532
+ * @param x scalar or batch of scalars
533
+ * @param y scalar or batch of scalars
534
+ * @return the result of the bitwise xor.
535
+ */
536
+ template <class T, class A>
537
+ XSIMD_INLINE batch_bool<T, A> bitwise_xor(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
538
+ {
539
+ detail::static_check_supported_config<T, A>();
540
+ return x ^ y;
541
+ }
542
+
543
+ /**
544
+ * @ingroup batch_data_transfer
545
+ *
546
+ * Creates a batch from the single value \c v. If \c v is a boolean,
547
+ * this function returns a batch_bool<uint8_t>. If you need another type
548
+ * of batch_bool, please use \c broadcast_as instead.
549
+ * @param v the value used to initialize the batch
550
+ * @return a new batch instance
551
+ */
552
+ template <class T, class A = default_arch>
553
+ XSIMD_INLINE typename kernel::detail::broadcaster<T, A>::return_type broadcast(T v) noexcept
554
+ {
555
+ detail::static_check_supported_config<T, A>();
556
+ return kernel::detail::broadcaster<T, A>::run(v);
557
+ }
558
+
559
+ /**
560
+ * @ingroup batch_data_transfer
561
+ *
562
+ * Creates a batch from the single value \c v and
563
+ * the specified batch value type \c To.
564
+ * @param v the value used to initialize the batch
565
+ * @return a new batch instance
566
+ */
567
+ template <class To, class A = default_arch, class From>
568
+ XSIMD_INLINE simd_return_type<From, To, A> broadcast_as(From v) noexcept
569
+ {
570
+ detail::static_check_supported_config<From, A>();
571
+ using batch_value_type = typename simd_return_type<From, To, A>::value_type;
572
+ using value_type = std::conditional_t<std::is_same<From, bool>::value,
573
+ bool,
574
+ batch_value_type>;
575
+ return simd_return_type<From, To, A>(value_type(v));
576
+ }
577
+
578
+ /**
579
+ * @ingroup batch_math
580
+ *
581
+ * Computes the cubic root of the batch \c x.
582
+ * @param x batch of floating point values.
583
+ * @return the cubic root of \c x.
584
+ */
585
+ template <class T, class A>
586
+ XSIMD_INLINE batch<T, A> cbrt(batch<T, A> const& x) noexcept
587
+ {
588
+ detail::static_check_supported_config<T, A>();
589
+ return kernel::cbrt<A>(x, A {});
590
+ }
591
+
592
+ /**
593
+ * @ingroup batch_rounding
594
+ *
595
+ * Computes the batch of smallest integer values not less than
596
+ * scalars in \c x.
597
+ * @param x batch of floating point values.
598
+ * @return the batch of smallest integer values not less than \c x.
599
+ */
600
+ template <class T, class A>
601
+ XSIMD_INLINE batch<T, A> ceil(batch<T, A> const& x) noexcept
602
+ {
603
+ detail::static_check_supported_config<T, A>();
604
+ return kernel::ceil<A>(x, A {});
605
+ }
606
+
607
+ /**
608
+ * @ingroup batch_math
609
+ *
610
+ * Clips the values of the batch \c x between those of the batches \c lo and \c hi.
611
+ * @param x batch of scalar values.
612
+ * @param lo batch of scalar values.
613
+ * @param hi batch of scalar values.
614
+ * @return the result of the clipping.
615
+ */
616
+ template <class T, class A>
617
+ XSIMD_INLINE batch<T, A> clip(batch<T, A> const& x, batch<T, A> const& lo, batch<T, A> const& hi) noexcept
618
+ {
619
+ detail::static_check_supported_config<T, A>();
620
+ return kernel::clip(x, lo, hi, A {});
621
+ }
622
+
623
+ /**
624
+ * @ingroup batch_data_transfer
625
+ *
626
+ * Pick elements from \c x selected by \c mask, and append them to the
627
+ * resulting vector, zeroing the remaining slots
628
+ */
629
+ template <class T, class A>
630
+ XSIMD_INLINE batch<T, A> compress(batch<T, A> const& x, batch_bool<T, A> const& mask) noexcept
631
+ {
632
+ detail::static_check_supported_config<T, A>();
633
+ return kernel::compress<A>(x, mask, A {});
634
+ }
635
+
636
+ /**
637
+ * @ingroup batch_complex
638
+ *
639
+ * Computes the conjugate of the batch \c z.
640
+ * @param z batch of complex values.
641
+ * @return the argument of \c z.
642
+ */
643
+ template <class A, class T>
644
+ XSIMD_INLINE complex_batch_type_t<batch<T, A>> conj(batch<T, A> const& z) noexcept
645
+ {
646
+ return kernel::conj(z, A {});
647
+ }
648
+
649
+ /**
650
+ * @ingroup batch_miscellaneous
651
+ *
652
+ * Computes a value whose absolute value matches
653
+ * that of \c x, but whose sign bit matches that of \c y.
654
+ * @param x batch of scalars
655
+ * @param y batch of scalars
656
+ * @return batch whose absolute value matches that of \c x, but whose sign bit
657
+ * matches that of \c y.
658
+ */
659
+ template <class T, class A>
660
+ XSIMD_INLINE batch<T, A> copysign(batch<T, A> const& x, batch<T, A> const& y) noexcept
661
+ {
662
+ detail::static_check_supported_config<T, A>();
663
+ return kernel::copysign<A>(x, y, A {});
664
+ }
665
+
666
+ /**
667
+ * @ingroup batch_trigo
668
+ *
669
+ * Computes the cosine of the batch \c x.
670
+ * @param x batch of floating point values.
671
+ * @return the cosine of \c x.
672
+ */
673
+ template <class T, class A>
674
+ XSIMD_INLINE batch<T, A> cos(batch<T, A> const& x) noexcept
675
+ {
676
+ detail::static_check_supported_config<T, A>();
677
+ return kernel::cos<A>(x, A {});
678
+ }
679
+
680
+ /**
681
+ * @ingroup batch_trigo
682
+ *
683
+ * computes the hyperbolic cosine of the batch \c x.
684
+ * @param x batch of floating point values.
685
+ * @return the hyperbolic cosine of \c x.
686
+ */
687
+ template <class T, class A>
688
+ XSIMD_INLINE batch<T, A> cosh(batch<T, A> const& x) noexcept
689
+ {
690
+ detail::static_check_supported_config<T, A>();
691
+ return kernel::cosh<A>(x, A {});
692
+ }
693
+
694
+ /**
695
+ * @ingroup batch_bool_reducers
696
+ *
697
+ * Count the number of values set to true in the batch \c x
698
+ * @param x boolean or batch of boolean
699
+ * @return the result of the counting.
700
+ */
701
+ template <class T, class A>
702
+ XSIMD_INLINE size_t count(batch_bool<T, A> const& x) noexcept
703
+ {
704
+ detail::static_check_supported_config<T, A>();
705
+ return kernel::count<A>(x, A {});
706
+ }
707
+
708
+ /**
709
+ * @ingroup batch_arithmetic
710
+ *
711
+ * Subtract 1 to batch \c x.
712
+ * @param x batch involved in the decrement.
713
+ * @return the subtraction of \c x and 1.
714
+ */
715
+ template <class T, class A>
716
+ XSIMD_INLINE batch<T, A> decr(batch<T, A> const& x) noexcept
717
+ {
718
+ detail::static_check_supported_config<T, A>();
719
+ return kernel::decr<A>(x, A {});
720
+ }
721
+
722
+ /**
723
+ * @ingroup batch_arithmetic
724
+ *
725
+ * Subtract 1 to batch \c x for each element where \c mask is true.
726
+ * @param x batch involved in the increment.
727
+ * @param mask whether to perform the increment or not. Can be a \c
728
+ * batch_bool or a \c batch_bool_constant.
729
+ * @return the subtraction of \c x and 1 when \c mask is true.
730
+ */
731
+ template <class T, class A, class Mask>
732
+ XSIMD_INLINE batch<T, A> decr_if(batch<T, A> const& x, Mask const& mask) noexcept
733
+ {
734
+ detail::static_check_supported_config<T, A>();
735
+ return kernel::decr_if<A>(x, mask, A {});
736
+ }
737
+
738
+ /**
739
+ * @ingroup batch_arithmetic
740
+ *
741
+ * Computes the division of the batch \c x by the batch \c y.
742
+ * @param x scalar or batch of scalars
743
+ * @param y scalar or batch of scalars
744
+ * @return the result of the division.
745
+ */
746
+ template <class T, class A>
747
+ XSIMD_INLINE batch<T, A> div(batch<T, A> const& x, batch<T, A> const& y) noexcept
748
+ {
749
+ detail::static_check_supported_config<T, A>();
750
+ return x / y;
751
+ }
752
+
753
+ /**
754
+ * @ingroup batch_logical
755
+ *
756
+ * Element-wise equality comparison of batches \c x and \c y.
757
+ * @param x batch of scalars
758
+ * @param y batch of scalars
759
+ * @return a boolean batch.
760
+ */
761
+ template <class T, class A>
762
+ XSIMD_INLINE auto eq(batch<T, A> const& x, batch<T, A> const& y) noexcept
763
+ {
764
+ detail::static_check_supported_config<T, A>();
765
+ return x == y;
766
+ }
767
+
768
+ /**
769
+ * @ingroup batch_logical
770
+ *
771
+ * Element-wise equality comparison of batches of boolean values \c x and \c y.
772
+ * @param x batch of booleans involved in the comparison.
773
+ * @param y batch of booleans involved in the comparison.
774
+ * @return a boolean batch.
775
+ */
776
+ template <class T, class A>
777
+ XSIMD_INLINE batch_bool<T, A> eq(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
778
+ {
779
+ detail::static_check_supported_config<T, A>();
780
+ return x == y;
781
+ }
782
+
783
+ /**
784
+ * @ingroup batch_math
785
+ *
786
+ * Computes the natural exponential of the batch \c x.
787
+ * @param x batch of floating point values.
788
+ * @return the natural exponential of \c x.
789
+ */
790
+ template <class T, class A>
791
+ XSIMD_INLINE batch<T, A> exp(batch<T, A> const& x) noexcept
792
+ {
793
+ detail::static_check_supported_config<T, A>();
794
+ return kernel::exp<A>(x, A {});
795
+ }
796
+
797
+ /**
798
+ * @ingroup batch_math
799
+ *
800
+ * Computes the base 10 exponential of the batch \c x.
801
+ * @param x batch of floating point values.
802
+ * @return the base 10 exponential of \c x.
803
+ */
804
+ template <class T, class A>
805
+ XSIMD_INLINE batch<T, A> exp10(batch<T, A> const& x) noexcept
806
+ {
807
+ detail::static_check_supported_config<T, A>();
808
+ return kernel::exp10<A>(x, A {});
809
+ }
810
+
811
+ /**
812
+ * @ingroup batch_math
813
+ *
814
+ * Computes the base 2 exponential of the batch \c x.
815
+ * @param x batch of floating point values.
816
+ * @return the base 2 exponential of \c x.
817
+ */
818
+ template <class T, class A>
819
+ XSIMD_INLINE batch<T, A> exp2(batch<T, A> const& x) noexcept
820
+ {
821
+ detail::static_check_supported_config<T, A>();
822
+ return kernel::exp2<A>(x, A {});
823
+ }
824
+
825
+ /**
826
+ * @ingroup batch_data_transfer
827
+ *
828
+ * Load contiguous elements from \c x and place them in slots selected by \c
829
+ * mask, zeroing the other slots
830
+ */
831
+ template <class T, class A>
832
+ XSIMD_INLINE batch<T, A> expand(batch<T, A> const& x, batch_bool<T, A> const& mask) noexcept
833
+ {
834
+ detail::static_check_supported_config<T, A>();
835
+ return kernel::expand<A>(x, mask, A {});
836
+ }
837
+
838
+ /**
839
+ * @ingroup batch_math
840
+ *
841
+ * Computes the natural exponential of the batch \c x, minus one.
842
+ * @param x batch of floating point values.
843
+ * @return the natural exponential of \c x, minus one.
844
+ */
845
+ template <class T, class A>
846
+ XSIMD_INLINE batch<T, A> expm1(batch<T, A> const& x) noexcept
847
+ {
848
+ detail::static_check_supported_config<T, A>();
849
+ return kernel::expm1<A>(x, A {});
850
+ }
851
+
852
+ /**
853
+ * @ingroup batch_math_extra
854
+ *
855
+ * Computes the error function of the batch \c x.
856
+ * @param x batch of floating point values.
857
+ * @return the error function of \c x.
858
+ */
859
+ template <class T, class A>
860
+ XSIMD_INLINE batch<T, A> erf(batch<T, A> const& x) noexcept
861
+ {
862
+ detail::static_check_supported_config<T, A>();
863
+ return kernel::erf<A>(x, A {});
864
+ }
865
+
866
+ /**
867
+ * @ingroup batch_math_extra
868
+ *
869
+ * Computes the complementary error function of the batch \c x.
870
+ * @param x batch of floating point values.
871
+ * @return the error function of \c x.
872
+ */
873
+ template <class T, class A>
874
+ XSIMD_INLINE batch<T, A> erfc(batch<T, A> const& x) noexcept
875
+ {
876
+ detail::static_check_supported_config<T, A>();
877
+ return kernel::erfc<A>(x, A {});
878
+ }
879
+
880
+ /**
881
+ * Extract vector from pair of vectors
882
+ * extracts the lowest vector elements from the second source \c x
883
+ * and the highest vector elements from the first source \c y
884
+ * Concatenates the results into th Return value.
885
+ * @param x batch of integer or floating point values.
886
+ * @param y batch of integer or floating point values.
887
+ * @param i integer specifying the lowest vector element to extract from the first source register
888
+ * @return.
889
+ */
890
+ template <class T, class A>
891
+ XSIMD_INLINE batch<T, A> extract_pair(batch<T, A> const& x, batch<T, A> const& y, std::size_t i) noexcept
892
+ {
893
+ detail::static_check_supported_config<T, A>();
894
+ return kernel::extract_pair<A>(x, y, i, A {});
895
+ }
896
+
897
+ /**
898
+ * @ingroup batch_math
899
+ *
900
+ * Computes the absolute values of each scalar in the batch \c x.
901
+ * @param x batch floating point values.
902
+ * @return the absolute values of \c x.
903
+ */
904
+ template <class T, class A>
905
+ XSIMD_INLINE batch<T, A> fabs(batch<T, A> const& x) noexcept
906
+ {
907
+ detail::static_check_supported_config<T, A>();
908
+ return kernel::abs<A>(x, A {});
909
+ }
910
+
911
+ /**
912
+ * @ingroup batch_math
913
+ *
914
+ * Computes the positive difference between \c x and \c y, that is,
915
+ * <tt>max(0, x-y)</tt>.
916
+ * @param x batch of floating point values.
917
+ * @param y batch of floating point values.
918
+ * @return the positive difference.
919
+ */
920
+ template <class T, class A>
921
+ XSIMD_INLINE batch<T, A> fdim(batch<T, A> const& x, batch<T, A> const& y) noexcept
922
+ {
923
+ detail::static_check_supported_config<T, A>();
924
+ return kernel::fdim<A>(x, y, A {});
925
+ }
926
+
927
+ /**
928
+ * @ingroup batch_rounding
929
+ *
930
+ * Computes the batch of largest integer values not greater than
931
+ * scalars in \c x.
932
+ * @param x batch of floating point values.
933
+ * @return the batch of largest integer values not greater than \c x.
934
+ */
935
+ template <class T, class A>
936
+ XSIMD_INLINE batch<T, A> floor(batch<T, A> const& x) noexcept
937
+ {
938
+ detail::static_check_supported_config<T, A>();
939
+ return kernel::floor<A>(x, A {});
940
+ }
941
+
942
+ /**
943
+ * @ingroup batch_arithmetic
944
+ *
945
+ * Computes <tt>(x*y) + z</tt> in a single instruction when possible.
946
+ * @param x a batch of integer or floating point values.
947
+ * @param y a batch of integer or floating point values.
948
+ * @param z a batch of integer or floating point values.
949
+ * @return the result of the fused multiply-add operation.
950
+ */
951
+ template <class T, class A>
952
+ XSIMD_INLINE batch<T, A> fma(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z) noexcept
953
+ {
954
+ detail::static_check_supported_config<T, A>();
955
+ return kernel::fma<A>(x, y, z, A {});
956
+ }
957
+
958
+ /**
959
+ * @ingroup batch_math
960
+ *
961
+ * Computes the larger values of the batches \c x and \c y.
962
+ * @param x a batch of integer or floating point values.
963
+ * @param y a batch of integer or floating point values.
964
+ * @return a batch of the larger values.
965
+ */
966
+ template <class T, class A>
967
+ XSIMD_INLINE batch<T, A> fmax(batch<T, A> const& x, batch<T, A> const& y) noexcept
968
+ {
969
+ detail::static_check_supported_config<T, A>();
970
+ return kernel::max<A>(x, y, A {});
971
+ }
972
+
973
+ /**
974
+ * @ingroup batch_math
975
+ *
976
+ * Computes the smaller values of the batches \c x and \c y.
977
+ * @param x a batch of integer or floating point values.
978
+ * @param y a batch of integer or floating point values.
979
+ * @return a batch of the smaller values.
980
+ */
981
+ template <class T, class A>
982
+ XSIMD_INLINE batch<T, A> fmin(batch<T, A> const& x, batch<T, A> const& y) noexcept
983
+ {
984
+ detail::static_check_supported_config<T, A>();
985
+ return kernel::min<A>(x, y, A {});
986
+ }
987
+
988
+ /**
989
+ * @ingroup batch_math
990
+ *
991
+ * Computes the modulo of the batch \c x by the batch \c y.
992
+ * @param x batch involved in the modulo.
993
+ * @param y batch involved in the modulo.
994
+ * @return the result of the modulo.
995
+ */
996
+ template <class T, class A>
997
+ XSIMD_INLINE batch<T, A> fmod(batch<T, A> const& x, batch<T, A> const& y) noexcept
998
+ {
999
+ detail::static_check_supported_config<T, A>();
1000
+ return kernel::fmod<A>(x, y, A {});
1001
+ }
1002
+
1003
+ /**
1004
+ * @ingroup batch_arithmetic
1005
+ *
1006
+ * Computes <tt>(x*y) - z</tt> in a single instruction when possible.
1007
+ * @param x a batch of integer or floating point values.
1008
+ * @param y a batch of integer or floating point values.
1009
+ * @param z a batch of integer or floating point values.
1010
+ * @return the result of the fused multiply-sub operation.
1011
+ */
1012
+ template <class T, class A>
1013
+ XSIMD_INLINE batch<T, A> fms(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z) noexcept
1014
+ {
1015
+ detail::static_check_supported_config<T, A>();
1016
+ return kernel::fms<A>(x, y, z, A {});
1017
+ }
1018
+
1019
+ /**
1020
+ * @ingroup batch_arithmetic
1021
+ *
1022
+ * Computes <tt>-(x*y) + z</tt> in a single instruction when possible.
1023
+ * @param x a batch of integer or floating point values.
1024
+ * @param y a batch of integer or floating point values.
1025
+ * @param z a batch of integer or floating point values.
1026
+ * @return the result of the fused negated multiply-add operation.
1027
+ */
1028
+ template <class T, class A>
1029
+ XSIMD_INLINE batch<T, A> fnma(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z) noexcept
1030
+ {
1031
+ detail::static_check_supported_config<T, A>();
1032
+ return kernel::fnma<A>(x, y, z, A {});
1033
+ }
1034
+
1035
+ /**
1036
+ * @ingroup batch_arithmetic
1037
+ *
1038
+ * Computes <tt>-(x*y) - z</tt> in a single instruction when possible.
1039
+ * @param x a batch of integer or floating point values.
1040
+ * @param y a batch of integer or floating point values.
1041
+ * @param z a batch of integer or floating point values.
1042
+ * @return the result of the fused negated multiply-sub operation.
1043
+ */
1044
+ template <class T, class A>
1045
+ XSIMD_INLINE batch<T, A> fnms(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z) noexcept
1046
+ {
1047
+ detail::static_check_supported_config<T, A>();
1048
+ return kernel::fnms<A>(x, y, z, A {});
1049
+ }
1050
+
1051
+ /**
1052
+ * @ingroup batch_arithmetic
1053
+ *
1054
+ * Computes <tt>-(x*y) - z</tt> in a single instruction when possible.
1055
+ * @param x a batch of integer or floating point values.
1056
+ * @param y a batch of integer or floating point values.
1057
+ * @param z a batch of integer or floating point values.
1058
+ * @return a batch where each even-indexed element is computed as <tt>x * y - z</tt> and each odd-indexed element as <tt>x * y + z</tt>
1059
+ */
1060
+ template <class T, class A>
1061
+ XSIMD_INLINE batch<T, A> fmas(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z) noexcept
1062
+ {
1063
+ detail::static_check_supported_config<T, A>();
1064
+ return kernel::fmas<A>(x, y, z, A {});
1065
+ }
1066
+ /**
1067
+ * @ingroup batch_fp
1068
+ *
1069
+ * Split split the number x into a normalized fraction and an exponent which is stored in exp
1070
+ * @param x a batch of integer or floating point values.
1071
+ * @param y a batch of integer or floating point values.
1072
+ * @return the normalized fraction of x
1073
+ */
1074
+ template <class T, class A>
1075
+ XSIMD_INLINE batch<T, A> frexp(const batch<T, A>& x, batch<as_integer_t<T>, A>& y) noexcept
1076
+ {
1077
+ detail::static_check_supported_config<T, A>();
1078
+ return kernel::frexp<A>(x, y, A {});
1079
+ }
1080
+
1081
+ /**
1082
+ * @ingroup batch_logical
1083
+ *
1084
+ * Element-wise greater or equal comparison of batches \c x and \c y.
1085
+ * @tparam X the actual type of batch.
1086
+ * @param x batch involved in the comparison.
1087
+ * @param y batch involved in the comparison.
1088
+ * @return a boolean batch.
1089
+ */
1090
+ template <class T, class A>
1091
+ XSIMD_INLINE batch_bool<T, A> ge(batch<T, A> const& x, batch<T, A> const& y) noexcept
1092
+ {
1093
+ detail::static_check_supported_config<T, A>();
1094
+ return x >= y;
1095
+ }
1096
+
1097
+ /**
1098
+ * @ingroup batch_logical
1099
+ *
1100
+ * Element-wise greater than comparison of batches \c x and \c y.
1101
+ * @tparam X the actual type of batch.
1102
+ * @param x batch involved in the comparison.
1103
+ * @param y batch involved in the comparison.
1104
+ * @return a boolean batch.
1105
+ */
1106
+ template <class T, class A>
1107
+ XSIMD_INLINE batch_bool<T, A> gt(batch<T, A> const& x, batch<T, A> const& y) noexcept
1108
+ {
1109
+ detail::static_check_supported_config<T, A>();
1110
+ return x > y;
1111
+ }
1112
+
1113
+ /**
1114
+ * @ingroup batch_data_transfer
1115
+ *
1116
+ * Extract the scalar element at compile-time index \c I from batch \c b.
1117
+ * @param b the batch to extract from.
1118
+ * @return the scalar element at index \c I.
1119
+ */
1120
+ template <size_t I, class T, class A>
1121
+ XSIMD_INLINE T get(batch<T, A> const& b) noexcept
1122
+ {
1123
+ static_assert(I < batch<T, A>::size, "index out of bounds");
1124
+ detail::static_check_supported_config<T, A>();
1125
+ return kernel::get(b, index<I> {}, A {});
1126
+ }
1127
+
1128
+ template <size_t I, class T, class A>
1129
+ XSIMD_INLINE bool get(batch_bool<T, A> const& b) noexcept
1130
+ {
1131
+ static_assert(I < batch_bool<T, A>::size, "index out of bounds");
1132
+ detail::static_check_supported_config<T, A>();
1133
+ return kernel::get(b, index<I> {}, A {});
1134
+ }
1135
+
1136
+ template <size_t I, class T, class A>
1137
+ XSIMD_INLINE typename batch<std::complex<T>, A>::value_type get(batch<std::complex<T>, A> const& b) noexcept
1138
+ {
1139
+ static_assert(I < batch<std::complex<T>, A>::size, "index out of bounds");
1140
+ detail::static_check_supported_config<T, A>();
1141
+ return kernel::get(b, index<I> {}, A {});
1142
+ }
1143
+
1144
+ /**
1145
+ * @ingroup batch_reducers
1146
+ *
1147
+ * Parallel horizontal addition: adds the scalars of each batch
1148
+ * in the array pointed by \c row and store them in a returned
1149
+ * batch.
1150
+ * @param row an array of \c N batches
1151
+ * @return the result of the reduction.
1152
+ */
1153
+ template <class T, class A>
1154
+ XSIMD_INLINE batch<T, A> haddp(batch<T, A> const* row) noexcept
1155
+ {
1156
+ detail::static_check_supported_config<T, A>();
1157
+ return kernel::haddp<A>(row, A {});
1158
+ }
1159
+
1160
+ /**
1161
+ * @ingroup batch_math
1162
+ *
1163
+ * Computes the square root of the sum of the squares of the batches
1164
+ * \c x, and \c y.
1165
+ * @param x batch of floating point values.
1166
+ * @param y batch of floating point values.
1167
+ * @return the square root of the sum of the squares of \c x and \c y.
1168
+ */
1169
+ template <class T, class A>
1170
+ XSIMD_INLINE batch<T, A> hypot(batch<T, A> const& x, batch<T, A> const& y) noexcept
1171
+ {
1172
+ detail::static_check_supported_config<T, A>();
1173
+ return kernel::hypot<A>(x, y, A {});
1174
+ }
1175
+
1176
+ /**
1177
+ * @ingroup batch_complex
1178
+ *
1179
+ * Computes the imaginary part of the batch \c x.
1180
+ * @param x batch of complex or real values.
1181
+ * @return the argument of \c x.
1182
+ */
1183
+ template <class T, class A>
1184
+ XSIMD_INLINE real_batch_type_t<batch<T, A>> imag(batch<T, A> const& x) noexcept
1185
+ {
1186
+ detail::static_check_supported_config<T, A>();
1187
+ return kernel::imag<A>(x, A {});
1188
+ }
1189
+
1190
+ /**
1191
+ * @ingroup batch_arithmetic
1192
+ *
1193
+ * Add 1 to batch \c x.
1194
+ * @param x batch involved in the increment.
1195
+ * @return the sum of \c x and 1.
1196
+ */
1197
+ template <class T, class A>
1198
+ XSIMD_INLINE batch<T, A> incr(batch<T, A> const& x) noexcept
1199
+ {
1200
+ detail::static_check_supported_config<T, A>();
1201
+ return kernel::incr<A>(x, A {});
1202
+ }
1203
+
1204
+ /**
1205
+ * @ingroup batch_arithmetic
1206
+ *
1207
+ * Add 1 to batch \c x for each element where \c mask is true.
1208
+ * @param x batch involved in the increment.
1209
+ * @param mask whether to perform the increment or not. Can be a \c
1210
+ * batch_bool or a \c batch_bool_constant.
1211
+ * @return the sum of \c x and 1 when \c mask is true.
1212
+ */
1213
+ template <class T, class A, class Mask>
1214
+ XSIMD_INLINE batch<T, A> incr_if(batch<T, A> const& x, Mask const& mask) noexcept
1215
+ {
1216
+ detail::static_check_supported_config<T, A>();
1217
+ return kernel::incr_if<A>(x, mask, A {});
1218
+ }
1219
+
1220
+ #ifndef __FAST_MATH__
1221
+ /**
1222
+ * @ingroup batch_constant
1223
+ *
1224
+ * Return a batch of scalars representing positive infinity
1225
+ * @return a batch of positive infinity
1226
+ */
1227
+ template <class B>
1228
+ XSIMD_INLINE B infinity()
1229
+ {
1230
+ using T = typename B::value_type;
1231
+ using A = typename B::arch_type;
1232
+ detail::static_check_supported_config<T, A>();
1233
+ return B(std::numeric_limits<T>::infinity());
1234
+ }
1235
+ #endif
1236
+
1237
+ /**
1238
+ * @ingroup batch_data_transfer
1239
+ *
1240
+ * Create a new batch equivalent to \c x but with element \c val set at position \c pos
1241
+ * @param x batch
1242
+ * @param val value to set
1243
+ * @param pos index of the updated slot
1244
+ * @return copy of \c x with position \c pos set to \c val
1245
+ */
1246
+ template <class T, class A, size_t I>
1247
+ XSIMD_INLINE batch<T, A> insert(batch<T, A> const& x, T val, index<I> pos) noexcept
1248
+ {
1249
+ detail::static_check_supported_config<T, A>();
1250
+ return kernel::insert<A>(x, val, pos, A {});
1251
+ }
1252
+
1253
+ /**
1254
+ * @ingroup batch_logical
1255
+ *
1256
+ * Determines if the scalars in the given batch \c x represent an even integer value
1257
+ * @param x batch of floating point values.
1258
+ * @return a batch of booleans.
1259
+ */
1260
+ template <class T, class A>
1261
+ XSIMD_INLINE batch_bool<T, A> is_even(batch<T, A> const& x) noexcept
1262
+ {
1263
+ detail::static_check_supported_config<T, A>();
1264
+ return kernel::is_even<A>(x, A {});
1265
+ }
1266
+
1267
+ /**
1268
+ * @ingroup batch_logical
1269
+ *
1270
+ * Determines if the floating-point scalars in the given batch \c x represent integer value
1271
+ * @param x batch of floating point values.
1272
+ * @return a batch of booleans.
1273
+ */
1274
+ template <class T, class A>
1275
+ XSIMD_INLINE batch_bool<T, A> is_flint(batch<T, A> const& x) noexcept
1276
+ {
1277
+ detail::static_check_supported_config<T, A>();
1278
+ return kernel::is_flint<A>(x, A {});
1279
+ }
1280
+
1281
+ /**
1282
+ * @ingroup batch_logical
1283
+ *
1284
+ * Determines if the scalars in the given batch \c x represent an odd integer value
1285
+ * @param x batch of floating point values.
1286
+ * @return a batch of booleans.
1287
+ */
1288
+ template <class T, class A>
1289
+ XSIMD_INLINE batch_bool<T, A> is_odd(batch<T, A> const& x) noexcept
1290
+ {
1291
+ detail::static_check_supported_config<T, A>();
1292
+ return kernel::is_odd<A>(x, A {});
1293
+ }
1294
+
1295
+ /**
1296
+ * @ingroup batch_logical
1297
+ *
1298
+ * Determines if the scalars in the given batch \c x are inf values.
1299
+ * @param x batch of floating point values.
1300
+ * @return a batch of booleans.
1301
+ */
1302
+ template <class T, class A>
1303
+ XSIMD_INLINE typename batch<T, A>::batch_bool_type isinf(batch<T, A> const& x) noexcept
1304
+ {
1305
+ detail::static_check_supported_config<T, A>();
1306
+ return kernel::isinf<A>(x, A {});
1307
+ }
1308
+
1309
+ /**
1310
+ * @ingroup batch_logical
1311
+ *
1312
+ * Determines if the scalars in the given batch \c x are finite values.
1313
+ * @param x batch of floating point values.
1314
+ * @return a batch of booleans.
1315
+ */
1316
+ template <class T, class A>
1317
+ XSIMD_INLINE typename batch<T, A>::batch_bool_type isfinite(batch<T, A> const& x) noexcept
1318
+ {
1319
+ detail::static_check_supported_config<T, A>();
1320
+ return kernel::isfinite<A>(x, A {});
1321
+ }
1322
+
1323
+ /**
1324
+ * @ingroup batch_logical
1325
+ *
1326
+ * Determines if the scalars in the given batch \c x are NaN values.
1327
+ * @param x batch of floating point values.
1328
+ * @return a batch of booleans.
1329
+ */
1330
+ template <class T, class A>
1331
+ XSIMD_INLINE typename batch<T, A>::batch_bool_type isnan(batch<T, A> const& x) noexcept
1332
+ {
1333
+ detail::static_check_supported_config<T, A>();
1334
+ return kernel::isnan<A>(x, A {});
1335
+ }
1336
+
1337
+ /**
1338
+ * @ingroup batch_math_extra
1339
+ *
1340
+ * Computes the multiplication of the floating point number \c x by 2 raised to the power \c y.
1341
+ * @param x batch of floating point values.
1342
+ * @param y batch of integer values.
1343
+ * @return a batch of floating point values.
1344
+ */
1345
+ template <class T, class A>
1346
+ XSIMD_INLINE batch<T, A> ldexp(const batch<T, A>& x, const batch<as_integer_t<T>, A>& y) noexcept
1347
+ {
1348
+ detail::static_check_supported_config<T, A>();
1349
+ return kernel::ldexp<A>(x, y, A {});
1350
+ }
1351
+
1352
+ /**
1353
+ * @ingroup batch_logical
1354
+ *
1355
+ * Element-wise lesser or equal to comparison of batches \c x and \c y.
1356
+ * @param x batch involved in the comparison.
1357
+ * @param y batch involved in the comparison.
1358
+ * @return a boolean batch.
1359
+ */
1360
+ template <class T, class A>
1361
+ XSIMD_INLINE batch_bool<T, A> le(batch<T, A> const& x, batch<T, A> const& y) noexcept
1362
+ {
1363
+ detail::static_check_supported_config<T, A>();
1364
+ return x <= y;
1365
+ }
1366
+
1367
+ /**
1368
+ * @ingroup batch_math_extra
1369
+ *
1370
+ * Computes the natural logarithm of the gamma function of the batch \c x.
1371
+ * @param x batch of floating point values.
1372
+ * @return the natural logarithm of the gamma function of \c x.
1373
+ */
1374
+ template <class T, class A>
1375
+ XSIMD_INLINE batch<T, A> lgamma(batch<T, A> const& x) noexcept
1376
+ {
1377
+ detail::static_check_supported_config<T, A>();
1378
+ return kernel::lgamma<A>(x, A {});
1379
+ }
1380
+
1381
+ /**
1382
+ * @ingroup batch_data_transfer
1383
+ *
1384
+ * Creates a batch from the buffer \c ptr and the specifed
1385
+ * batch value type \c To. The memory needs to be aligned.
1386
+ * @param ptr the memory buffer to read
1387
+ * @return a new batch instance
1388
+ */
1389
+ template <class To, class A = default_arch, class From>
1390
+ XSIMD_INLINE simd_return_type<From, To, A> load_as(From const* ptr, aligned_mode) noexcept
1391
+ {
1392
+ using batch_value_type = typename simd_return_type<From, To, A>::value_type;
1393
+ detail::static_check_supported_config<From, A>();
1394
+ detail::static_check_supported_config<To, A>();
1395
+ return kernel::load_aligned<A>(ptr, kernel::convert<batch_value_type> {}, A {});
1396
+ }
1397
+
1398
+ template <class To, class A = default_arch>
1399
+ XSIMD_INLINE simd_return_type<bool, To, A> load_as(bool const* ptr, aligned_mode) noexcept
1400
+ {
1401
+ detail::static_check_supported_config<To, A>();
1402
+ return simd_return_type<bool, To, A>::load_aligned(ptr);
1403
+ }
1404
+
1405
+ template <class To, class A = default_arch, class From>
1406
+ XSIMD_INLINE simd_return_type<std::complex<From>, To, A> load_as(std::complex<From> const* ptr, aligned_mode) noexcept
1407
+ {
1408
+ detail::static_check_supported_config<To, A>();
1409
+ using batch_value_type = typename simd_return_type<std::complex<From>, To, A>::value_type;
1410
+ return kernel::load_complex_aligned<A>(ptr, kernel::convert<batch_value_type> {}, A {});
1411
+ }
1412
+
1413
+ template <class To, class A = default_arch, class From>
1414
+ XSIMD_INLINE simd_return_type<From, To, A> load_as(From const* ptr, stream_mode) noexcept
1415
+ {
1416
+ using batch_value_type = typename simd_return_type<From, To, A>::value_type;
1417
+ detail::static_check_supported_config<From, A>();
1418
+ detail::static_check_supported_config<To, A>();
1419
+ return kernel::load_stream<A>(ptr, kernel::convert<batch_value_type> {}, A {});
1420
+ }
1421
+
1422
+ template <class To, class A = default_arch>
1423
+ XSIMD_INLINE simd_return_type<bool, To, A> load_as(bool const* ptr, stream_mode) noexcept
1424
+ {
1425
+ detail::static_check_supported_config<To, A>();
1426
+ return simd_return_type<bool, To, A>::load_stream(ptr);
1427
+ }
1428
+
1429
+ template <class To, class A = default_arch, class From>
1430
+ XSIMD_INLINE simd_return_type<std::complex<From>, To, A> load_as(std::complex<From> const* ptr, stream_mode) noexcept
1431
+ {
1432
+ detail::static_check_supported_config<To, A>();
1433
+ using batch_value_type = typename simd_return_type<std::complex<From>, To, A>::value_type;
1434
+ return kernel::load_complex_stream<A>(ptr, kernel::convert<batch_value_type> {}, A {});
1435
+ }
1436
+
1437
+ #ifdef XSIMD_ENABLE_XTL_COMPLEX
1438
+ template <class To, class A = default_arch, class From, bool i3ec>
1439
+ XSIMD_INLINE simd_return_type<xtl::xcomplex<From, From, i3ec>, To, A> load_as(xtl::xcomplex<From, From, i3ec> const* ptr, aligned_mode) noexcept
1440
+ {
1441
+ detail::static_check_supported_config<To, A>();
1442
+ detail::static_check_supported_config<From, A>();
1443
+ return load_as<To>(reinterpret_cast<std::complex<From> const*>(ptr), aligned_mode());
1444
+ }
1445
+
1446
+ template <class To, class A = default_arch, class From, bool i3ec>
1447
+ XSIMD_INLINE simd_return_type<xtl::xcomplex<From, From, i3ec>, To, A> load_as(xtl::xcomplex<From, From, i3ec> const* ptr, stream_mode) noexcept
1448
+ {
1449
+ detail::static_check_supported_config<To, A>();
1450
+ detail::static_check_supported_config<From, A>();
1451
+ return load_as<To>(reinterpret_cast<std::complex<From> const*>(ptr), stream_mode());
1452
+ }
1453
+ #endif
1454
+
1455
+ /**
1456
+ * @ingroup batch_data_transfer
1457
+ *
1458
+ * Creates a batch from the buffer \c ptr and the specifed
1459
+ * batch value type \c To. The memory does not need to be aligned.
1460
+ * @param ptr the memory buffer to read
1461
+ * @return a new batch instance
1462
+ */
1463
+ template <class To, class A = default_arch, class From>
1464
+ XSIMD_INLINE simd_return_type<From, To, A> load_as(From const* ptr, unaligned_mode) noexcept
1465
+ {
1466
+ using batch_value_type = typename simd_return_type<From, To, A>::value_type;
1467
+ detail::static_check_supported_config<To, A>();
1468
+ detail::static_check_supported_config<From, A>();
1469
+ return kernel::load_unaligned<A>(ptr, kernel::convert<batch_value_type> {}, A {});
1470
+ }
1471
+
1472
+ template <class To, class A = default_arch>
1473
+ XSIMD_INLINE simd_return_type<bool, To, A> load_as(bool const* ptr, unaligned_mode) noexcept
1474
+ {
1475
+ return simd_return_type<bool, To, A>::load_unaligned(ptr);
1476
+ }
1477
+
1478
+ template <class To, class A = default_arch, class From>
1479
+ XSIMD_INLINE simd_return_type<std::complex<From>, To, A> load_as(std::complex<From> const* ptr, unaligned_mode) noexcept
1480
+ {
1481
+ detail::static_check_supported_config<To, A>();
1482
+ detail::static_check_supported_config<From, A>();
1483
+ using batch_value_type = typename simd_return_type<std::complex<From>, To, A>::value_type;
1484
+ return kernel::load_complex_unaligned<A>(ptr, kernel::convert<batch_value_type> {}, A {});
1485
+ }
1486
+
1487
+ #ifdef XSIMD_ENABLE_XTL_COMPLEX
1488
+ template <class To, class A = default_arch, class From, bool i3ec>
1489
+ XSIMD_INLINE simd_return_type<xtl::xcomplex<From, From, i3ec>, To, A> load_as(xtl::xcomplex<From, From, i3ec> const* ptr, unaligned_mode) noexcept
1490
+ {
1491
+ detail::static_check_supported_config<To, A>();
1492
+ detail::static_check_supported_config<From, A>();
1493
+ return load_as<To>(reinterpret_cast<std::complex<From> const*>(ptr), unaligned_mode());
1494
+ }
1495
+ #endif
1496
+
1497
+ /**
1498
+ * @ingroup batch_data_transfer
1499
+ *
1500
+ * Creates a batch from the buffer \c ptr. The
1501
+ * memory needs to be aligned.
1502
+ * @param ptr the memory buffer to read
1503
+ * @return a new batch instance
1504
+ */
1505
+ template <class A = default_arch, class From>
1506
+ XSIMD_INLINE batch<From, A> load(From const* ptr, aligned_mode = {}) noexcept
1507
+ {
1508
+ detail::static_check_supported_config<From, A>();
1509
+ return load_as<From, A>(ptr, aligned_mode {});
1510
+ }
1511
+
1512
+ /**
1513
+ * @ingroup batch_data_transfer
1514
+ *
1515
+ * Creates a batch from the buffer \c ptr. The
1516
+ * memory does not need to be aligned.
1517
+ * @param ptr the memory buffer to read
1518
+ * @return a new batch instance
1519
+ */
1520
+ template <class A = default_arch, class From>
1521
+ XSIMD_INLINE batch<From, A> load(From const* ptr, unaligned_mode) noexcept
1522
+ {
1523
+ detail::static_check_supported_config<From, A>();
1524
+ return load_as<From, A>(ptr, unaligned_mode {});
1525
+ }
1526
+
1527
+ template <class A = default_arch, class From>
1528
+ XSIMD_INLINE batch<From, A> load(From const* ptr, stream_mode) noexcept
1529
+ {
1530
+ detail::static_check_supported_config<From, A>();
1531
+ return load_as<From, A>(ptr, stream_mode {});
1532
+ }
1533
+
1534
+ /**
1535
+ * @ingroup batch_data_transfer
1536
+ *
1537
+ * Creates a batch from the buffer \c ptr using a mask. Elements
1538
+ * corresponding to \c false in the mask are not accessed in memory and are
1539
+ * zero-initialized in the resulting batch.
1540
+ * @param ptr the memory buffer to read
1541
+ * @param mask selection mask for the elements to load
1542
+ * @return a new batch instance
1543
+ */
1544
+ template <class T, class A = default_arch, bool... Values, class From>
1545
+ XSIMD_INLINE batch<T, A> load(From const* ptr,
1546
+ batch_bool_constant<T, A, Values...> const& mask,
1547
+ aligned_mode = {}) noexcept
1548
+ {
1549
+ detail::static_check_supported_config<T, A>();
1550
+ return batch<T, A>::load(ptr, mask, aligned_mode {});
1551
+ }
1552
+
1553
+ /**
1554
+ * @ingroup batch_data_transfer
1555
+ *
1556
+ * Creates a batch from the buffer \c ptr using a mask. Elements
1557
+ * corresponding to \c false in the mask are not accessed in memory and are
1558
+ * zero-initialized in the resulting batch.
1559
+ * @param ptr the memory buffer to read. The buffer does not need to be
1560
+ * aligned.
1561
+ * @param mask selection mask for the elements to load
1562
+ * @return a new batch instance
1563
+ */
1564
+ template <class T, class A = default_arch, bool... Values, class From>
1565
+ XSIMD_INLINE batch<T, A> load(From const* ptr,
1566
+ batch_bool_constant<T, A, Values...> const& mask,
1567
+ unaligned_mode) noexcept
1568
+ {
1569
+ detail::static_check_supported_config<T, A>();
1570
+ return batch<T, A>::load(ptr, mask, unaligned_mode {});
1571
+ }
1572
+
1573
+ /**
1574
+ * @ingroup batch_data_transfer
1575
+ *
1576
+ * Creates a batch from the buffer \c ptr. The
1577
+ * memory needs to be aligned.
1578
+ * @param ptr the memory buffer to read
1579
+ * @return a new batch instance
1580
+ */
1581
+ template <class A = default_arch, class From>
1582
+ XSIMD_INLINE batch<From, A> load_aligned(From const* ptr) noexcept
1583
+ {
1584
+ detail::static_check_supported_config<From, A>();
1585
+ return load_as<From, A>(ptr, aligned_mode {});
1586
+ }
1587
+
1588
+ /**
1589
+ * @ingroup batch_data_transfer
1590
+ *
1591
+ * Creates a batch from the buffer \c ptr. The
1592
+ * memory does not need to be aligned.
1593
+ * @param ptr the memory buffer to read
1594
+ * @return a new batch instance
1595
+ */
1596
+ template <class A = default_arch, class From>
1597
+ XSIMD_INLINE batch<From, A> load_unaligned(From const* ptr) noexcept
1598
+ {
1599
+ detail::static_check_supported_config<From, A>();
1600
+ return load_as<From, A>(ptr, unaligned_mode {});
1601
+ }
1602
+
1603
+ /**
1604
+ * @ingroup batch_math
1605
+ *
1606
+ * Computes the natural logarithm of the batch \c x.
1607
+ * @param x batch of floating point values.
1608
+ * @return the natural logarithm of \c x.
1609
+ */
1610
+ template <class T, class A>
1611
+ XSIMD_INLINE batch<T, A> log(batch<T, A> const& x) noexcept
1612
+ {
1613
+ detail::static_check_supported_config<T, A>();
1614
+ return kernel::log<A>(x, A {});
1615
+ }
1616
+
1617
+ /**
1618
+ * @ingroup batch_math
1619
+ * Computes the base 2 logarithm of the batch \c x.
1620
+ * @param x batch of floating point values.
1621
+ * @return the base 2 logarithm of \c x.
1622
+ */
1623
+ template <class T, class A>
1624
+ XSIMD_INLINE batch<T, A> log2(batch<T, A> const& x) noexcept
1625
+ {
1626
+ detail::static_check_supported_config<T, A>();
1627
+ return kernel::log2<A>(x, A {});
1628
+ }
1629
+
1630
+ /**
1631
+ * @ingroup batch_math
1632
+ * Computes the base 10 logarithm of the batch \c x.
1633
+ * @param x batch of floating point values.
1634
+ * @return the base 10 logarithm of \c x.
1635
+ */
1636
+ template <class T, class A>
1637
+ XSIMD_INLINE batch<T, A> log10(batch<T, A> const& x) noexcept
1638
+ {
1639
+ detail::static_check_supported_config<T, A>();
1640
+ return kernel::log10<A>(x, A {});
1641
+ }
1642
+
1643
+ /**
1644
+ * @ingroup batch_math
1645
+ * Computes the natural logarithm of one plus the batch \c x.
1646
+ * @param x batch of floating point values.
1647
+ * @return the natural logarithm of one plus \c x.
1648
+ */
1649
+ template <class T, class A>
1650
+ XSIMD_INLINE batch<T, A> log1p(batch<T, A> const& x) noexcept
1651
+ {
1652
+ detail::static_check_supported_config<T, A>();
1653
+ return kernel::log1p<A>(x, A {});
1654
+ }
1655
+
1656
+ /**
1657
+ * @ingroup batch_logical
1658
+ *
1659
+ * Element-wise lesser than comparison of batches \c x and \c y.
1660
+ * @param x batch involved in the comparison.
1661
+ * @param y batch involved in the comparison.
1662
+ * @return a boolean batch.
1663
+ */
1664
+ template <class T, class A>
1665
+ XSIMD_INLINE batch_bool<T, A> lt(batch<T, A> const& x, batch<T, A> const& y) noexcept
1666
+ {
1667
+ detail::static_check_supported_config<T, A>();
1668
+ return x < y;
1669
+ }
1670
+
1671
+ /**
1672
+ * @ingroup batch_math
1673
+ *
1674
+ * Computes the larger values of the batches \c x and \c y.
1675
+ * @param x a batch of integer or floating point values.
1676
+ * @param y a batch of integer or floating point values.
1677
+ * @return a batch of the larger values.
1678
+ */
1679
+ template <class T, class A>
1680
+ XSIMD_INLINE batch<T, A> max(batch<T, A> const& x, batch<T, A> const& y) noexcept
1681
+ {
1682
+ detail::static_check_supported_config<T, A>();
1683
+ return kernel::max<A>(x, y, A {});
1684
+ }
1685
+
1686
+ /**
1687
+ * @ingroup batch_math
1688
+ *
1689
+ * Computes the smaller values of the batches \c x and \c y.
1690
+ * @param x a batch of integer or floating point values.
1691
+ * @param y a batch of integer or floating point values.
1692
+ * @return a batch of the smaller values.
1693
+ */
1694
+ template <class T, class A>
1695
+ XSIMD_INLINE batch<T, A> min(batch<T, A> const& x, batch<T, A> const& y) noexcept
1696
+ {
1697
+ detail::static_check_supported_config<T, A>();
1698
+ return kernel::min<A>(x, y, A {});
1699
+ }
1700
+
1701
+ /**
1702
+ * @ingroup batch_constant
1703
+ *
1704
+ * Return a batch of scalars representing positive infinity
1705
+ * @return a batch of positive infinity
1706
+ */
1707
+ template <class B>
1708
+ XSIMD_INLINE B minusinfinity() noexcept
1709
+ {
1710
+ using T = typename B::value_type;
1711
+ using A = typename B::arch_type;
1712
+ detail::static_check_supported_config<T, A>();
1713
+ return B(-std::numeric_limits<T>::infinity());
1714
+ }
1715
+
1716
+ /**
1717
+ * @ingroup batch_arithmetic
1718
+ *
1719
+ * Computes the integer modulo of the batch \c x by the batch \c y.
1720
+ * @param x batch involved in the modulo.
1721
+ * @param y batch involved in the modulo.
1722
+ * @return the result of the modulo.
1723
+ */
1724
+ template <class T, class A>
1725
+ XSIMD_INLINE batch<T, A> mod(batch<T, A> const& x, batch<T, A> const& y) noexcept
1726
+ {
1727
+ detail::static_check_supported_config<T, A>();
1728
+ return x % y;
1729
+ }
1730
+
1731
+ /**
1732
+ * @ingroup batch_arithmetic
1733
+ *
1734
+ * Computes the product of the batches \c x and \c y.
1735
+ * @tparam X the actual type of batch.
1736
+ * @param x batch involved in the product.
1737
+ * @param y batch involved in the product.
1738
+ * @return the result of the product.
1739
+ */
1740
+ template <class T, class A>
1741
+ XSIMD_INLINE batch<T, A> mul(batch<T, A> const& x, batch<T, A> const& y) noexcept
1742
+ {
1743
+ detail::static_check_supported_config<T, A>();
1744
+ return x * y;
1745
+ }
1746
+
1747
+ /**
1748
+ * @ingroup batch_rounding
1749
+ *
1750
+ * Rounds the scalars in \c x to integer values (in floating point format), using
1751
+ * the current rounding mode.
1752
+ * @param x batch of floating point values.
1753
+ * @return the batch of nearest integer values.
1754
+ */
1755
+ template <class T, class A>
1756
+ XSIMD_INLINE batch<T, A> nearbyint(batch<T, A> const& x) noexcept
1757
+ {
1758
+ detail::static_check_supported_config<T, A>();
1759
+ return kernel::nearbyint<A>(x, A {});
1760
+ }
1761
+
1762
+ /**
1763
+ * @ingroup batch_rounding
1764
+ *
1765
+ * Rounds the scalars in \c x to integer values (in integer format) using
1766
+ * the current rounding mode.
1767
+ * @param x batch of floating point values.
1768
+ * @return the batch of nearest integer values.
1769
+ *
1770
+ * @warning For very large values the conversion to int silently overflows.
1771
+ */
1772
+ template <class T, class A>
1773
+ XSIMD_INLINE batch<as_integer_t<T>, A>
1774
+ nearbyint_as_int(batch<T, A> const& x) noexcept
1775
+ {
1776
+ detail::static_check_supported_config<T, A>();
1777
+ return kernel::nearbyint_as_int(x, A {});
1778
+ }
1779
+
1780
+ /**
1781
+ * @ingroup batch_logical
1782
+ *
1783
+ * Element-wise inequality comparison of batches \c x and \c y.
1784
+ * @param x batch involved in the comparison.
1785
+ * @param y batch involved in the comparison.
1786
+ * @return a boolean batch.
1787
+ */
1788
+ template <class T, class A>
1789
+ XSIMD_INLINE auto neq(batch<T, A> const& x, batch<T, A> const& y) noexcept
1790
+ {
1791
+ detail::static_check_supported_config<T, A>();
1792
+ return x != y;
1793
+ }
1794
+
1795
+ /**
1796
+ * @ingroup batch_logical
1797
+ *
1798
+ * Element-wise inequality comparison of batches of boolean values \c x and \c y.
1799
+ * @param x batch of booleans involved in the comparison.
1800
+ * @param y batch of booleans involved in the comparison.
1801
+ * @return a boolean batch.
1802
+ */
1803
+ template <class T, class A>
1804
+ XSIMD_INLINE batch_bool<T, A> neq(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
1805
+ {
1806
+ detail::static_check_supported_config<T, A>();
1807
+ return x != y;
1808
+ }
1809
+
1810
+ /**
1811
+ * @ingroup batch_arithmetic
1812
+ *
1813
+ * Computes the opposite of the batch \c x.
1814
+ * @param x batch involved in the operation.
1815
+ * @return the opposite of \c x.
1816
+ */
1817
+ template <class T, class A>
1818
+ XSIMD_INLINE batch<T, A> neg(batch<T, A> const& x) noexcept
1819
+ {
1820
+ detail::static_check_supported_config<T, A>();
1821
+ return -x;
1822
+ }
1823
+
1824
+ /**
1825
+ * @ingroup batch_math_extra
1826
+ *
1827
+ * Computes the next representable floating-point
1828
+ * value following x in the direction of y
1829
+ * @param x batch of floating point values.
1830
+ * @param y batch of floating point values.
1831
+ * @return \c x raised to the power \c y.
1832
+ */
1833
+ template <class T, class A>
1834
+ XSIMD_INLINE batch<T, A> nextafter(batch<T, A> const& x, batch<T, A> const& y) noexcept
1835
+ {
1836
+ detail::static_check_supported_config<T, A>();
1837
+ return kernel::nextafter<A>(x, y, A {});
1838
+ }
1839
+
1840
+ /**
1841
+ * @ingroup batch_complex
1842
+ *
1843
+ * Computes the norm of the batch \c x.
1844
+ * @param x batch of complex or real values.
1845
+ * @return the norm of \c x.
1846
+ */
1847
+ template <class T, class A>
1848
+ XSIMD_INLINE real_batch_type_t<batch<T, A>> norm(batch<T, A> const& x) noexcept
1849
+ {
1850
+ detail::static_check_supported_config<T, A>();
1851
+ return kernel::norm(x, A {});
1852
+ }
1853
+
1854
+ /**
1855
+ * @ingroup batch_math
1856
+ *
1857
+ * Returns a complex batch with magnitude \c r and phase angle \c theta.
1858
+ * @param r The magnitude of the desired complex result.
1859
+ * @param theta The phase angle of the desired complex result.
1860
+ * @return \c r exp(i * \c theta).
1861
+ */
1862
+ template <class T, class A>
1863
+ XSIMD_INLINE complex_batch_type_t<batch<T, A>> polar(batch<T, A> const& r, batch<T, A> const& theta = batch<T, A> {}) noexcept
1864
+ {
1865
+ detail::static_check_supported_config<T, A>();
1866
+ return kernel::polar<A>(r, theta, A {});
1867
+ }
1868
+
1869
+ /**
1870
+ * @ingroup batch_arithmetic
1871
+ *
1872
+ * No-op on \c x.
1873
+ * @param x batch involved in the operation.
1874
+ * @return \c x.
1875
+ */
1876
+ template <class T, class A>
1877
+ XSIMD_INLINE batch<T, A> pos(batch<T, A> const& x) noexcept
1878
+ {
1879
+ detail::static_check_supported_config<T, A>();
1880
+ return +x;
1881
+ }
1882
+
1883
+ /**
1884
+ * @ingroup batch_math
1885
+ *
1886
+ * Computes the value of the batch \c x raised to the power
1887
+ * \c y.
1888
+ * @param x batch of floating point values.
1889
+ * @param y batch of floating point values.
1890
+ * @return \c x raised to the power \c y.
1891
+ */
1892
+ template <class T, class A>
1893
+ XSIMD_INLINE batch<T, A> pow(batch<T, A> const& x, batch<T, A> const& y) noexcept
1894
+ {
1895
+ detail::static_check_supported_config<T, A>();
1896
+ return kernel::pow<A>(x, y, A {});
1897
+ }
1898
+
1899
+ /**
1900
+ * @ingroup batch_math
1901
+ *
1902
+ * Computes the value of the batch \c x raised to the power
1903
+ * \c y.
1904
+ * @param x batch of complex floating point values.
1905
+ * @param y batch of floating point values.
1906
+ * @return \c x raised to the power \c y.
1907
+ */
1908
+ template <class T, class A>
1909
+ XSIMD_INLINE batch<std::complex<T>, A> pow(batch<std::complex<T>, A> const& x, batch<T, A> const& y) noexcept
1910
+ {
1911
+ detail::static_check_supported_config<T, A>();
1912
+ return kernel::pow<A>(x, y, A {});
1913
+ }
1914
+
1915
+ /**
1916
+ * @ingroup batch_math
1917
+ *
1918
+ * Computes the value of the batch \c x raised to the power
1919
+ * \c y.
1920
+ * @param x batch of complex floating point values.
1921
+ * @param y batch of floating point values.
1922
+ * @return \c x raised to the power \c y.
1923
+ */
1924
+ template <class T, class A>
1925
+ XSIMD_INLINE batch<std::complex<T>, A> pow(batch<T, A> const& x, batch<std::complex<T>, A> const& y) noexcept
1926
+ {
1927
+ detail::static_check_supported_config<T, A>();
1928
+ return kernel::pow<A>(x, y, A {});
1929
+ }
1930
+
1931
+ /**
1932
+ * @ingroup batch_math
1933
+ *
1934
+ * Computes the value of the batch \c x raised to the power
1935
+ * \c y.
1936
+ * @param x batch of integral values.
1937
+ * @param y batch of integral values.
1938
+ * @return \c x raised to the power \c y.
1939
+ */
1940
+ template <class T, class ITy, class A, class = std::enable_if_t<std::is_integral<ITy>::value>>
1941
+ XSIMD_INLINE batch<T, A> pow(batch<T, A> const& x, ITy y) noexcept
1942
+ {
1943
+ detail::static_check_supported_config<T, A>();
1944
+ return kernel::ipow<A>(x, y, A {});
1945
+ }
1946
+
1947
+ /**
1948
+ * @ingroup batch_complex
1949
+ *
1950
+ * Computes the projection of the batch \c z.
1951
+ * @param z batch of complex or real values.
1952
+ * @return the projection of \c z.
1953
+ */
1954
+ template <class T, class A>
1955
+ XSIMD_INLINE complex_batch_type_t<batch<T, A>> proj(batch<T, A> const& z) noexcept
1956
+ {
1957
+ detail::static_check_supported_config<T, A>();
1958
+ return kernel::proj(z, A {});
1959
+ }
1960
+
1961
+ /**
1962
+ * @ingroup batch_complex
1963
+ *
1964
+ * Computes the real part of the batch \c z.
1965
+ * @param z batch of complex or real values.
1966
+ * @return the argument of \c z.
1967
+ */
1968
+ template <class T, class A>
1969
+ XSIMD_INLINE real_batch_type_t<batch<T, A>> real(batch<T, A> const& z) noexcept
1970
+ {
1971
+ detail::static_check_supported_config<T, A>();
1972
+ return kernel::real<A>(z, A {});
1973
+ }
1974
+
1975
+ /**
1976
+ * @ingroup batch_arithmetic
1977
+ *
1978
+ * Computes the approximate reciprocal of the batch \c x.
1979
+ * The maximum relative error for this approximation is
1980
+ * less than 1.5*2^-12.
1981
+ * @param x batch of floating point numbers.
1982
+ * @return the reciprocal.
1983
+ */
1984
+ template <class T, class A, class = std::enable_if_t<std::is_floating_point<T>::value>>
1985
+ XSIMD_INLINE batch<T, A> reciprocal(batch<T, A> const& x) noexcept
1986
+ {
1987
+ detail::static_check_supported_config<T, A>();
1988
+ return kernel::reciprocal(x, A {});
1989
+ }
1990
+
1991
+ /**
1992
+ * @ingroup batch_reducers
1993
+ *
1994
+ * Generic reducer using only batch operations
1995
+ * @param f reducing function, accepting `batch ()(batch, batch)`
1996
+ * @param x batch involved in the reduction
1997
+ * @return the result of the reduction, as a scalar.
1998
+ */
1999
+ template <class T, class A, class F>
2000
+ XSIMD_INLINE T reduce(F&& f, batch<T, A> const& x) noexcept
2001
+ {
2002
+ detail::static_check_supported_config<T, A>();
2003
+ return kernel::detail::reduce(std::forward<F>(f), x, std::integral_constant<unsigned, batch<T, A>::size>());
2004
+ }
2005
+
2006
+ /**
2007
+ * @ingroup batch_reducers
2008
+ *
2009
+ * Adds all the scalars of the batch \c x.
2010
+ * @param x batch involved in the reduction
2011
+ * @return the result of the reduction.
2012
+ */
2013
+ template <class T, class A>
2014
+ XSIMD_INLINE T reduce_add(batch<T, A> const& x) noexcept
2015
+ {
2016
+ detail::static_check_supported_config<T, A>();
2017
+ return kernel::reduce_add<A>(x, A {});
2018
+ }
2019
+
2020
+ /**
2021
+ * @ingroup batch_reducers
2022
+ *
2023
+ * Max of all the scalars of the batch \c x.
2024
+ * @param x batch involved in the reduction
2025
+ * @return the result of the reduction.
2026
+ */
2027
+ template <class T, class A>
2028
+ XSIMD_INLINE T reduce_max(batch<T, A> const& x) noexcept
2029
+ {
2030
+ detail::static_check_supported_config<T, A>();
2031
+ return kernel::reduce_max<A>(x, A {});
2032
+ }
2033
+
2034
+ /**
2035
+ * @ingroup batch_reducers
2036
+ *
2037
+ * Min of all the scalars of the batch \c x.
2038
+ * @param x batch involved in the reduction
2039
+ * @return the result of the reduction.
2040
+ */
2041
+ template <class T, class A>
2042
+ XSIMD_INLINE T reduce_min(batch<T, A> const& x) noexcept
2043
+ {
2044
+ detail::static_check_supported_config<T, A>();
2045
+ return kernel::reduce_min<A>(x, A {});
2046
+ }
2047
+
2048
+ /**
2049
+ * @ingroup batch_reducers
2050
+ *
2051
+ * Multiplies of all the scalars of the batch \c x.
2052
+ * @param x batch involved in the reduction
2053
+ * @return the result of the reduction.
2054
+ */
2055
+ template <class T, class A>
2056
+ XSIMD_INLINE T reduce_mul(batch<T, A> const& x) noexcept
2057
+ {
2058
+ detail::static_check_supported_config<T, A>();
2059
+ return kernel::reduce_mul<A>(x, A {});
2060
+ }
2061
+
2062
+ /**
2063
+ * @ingroup batch_math
2064
+ *
2065
+ * Computes the remainder of dividing \c x by \c y
2066
+ * @param x batch of scalar values
2067
+ * @param y batch of scalar values
2068
+ * @return the result of the addition.
2069
+ */
2070
+ template <class T, class A>
2071
+ XSIMD_INLINE batch<T, A> remainder(batch<T, A> const& x, batch<T, A> const& y) noexcept
2072
+ {
2073
+ detail::static_check_supported_config<T, A>();
2074
+ return kernel::remainder<A>(x, y, A {});
2075
+ }
2076
+
2077
+ /**
2078
+ * @ingroup batch_rounding
2079
+ *
2080
+ * Rounds the scalars in \c x to integer values (in floating point format), using
2081
+ * the current rounding mode.
2082
+ * @param x batch of floating point values.
2083
+ * @return the batch of rounded values.
2084
+ */
2085
+ template <class T, class A>
2086
+ XSIMD_INLINE batch<T, A> rint(batch<T, A> const& x) noexcept
2087
+ {
2088
+ detail::static_check_supported_config<T, A>();
2089
+ return nearbyint(x);
2090
+ }
2091
+
2092
+ /**
2093
+ * @ingroup batch_data_transfer
2094
+ *
2095
+ * Slide the whole batch to the left by \c n elements, and reintroduce the
2096
+ * slided out elements from the right. This is different from
2097
+ * \c rotl that rotates each batch element to the left.
2098
+ *
2099
+ * @tparam N Amount of elements to rotate to the left.
2100
+ * @param x batch of integer values.
2101
+ * @return rotated batch.
2102
+ */
2103
+ template <size_t N, class T, class A>
2104
+ XSIMD_INLINE batch<T, A> rotate_left(batch<T, A> const& x) noexcept
2105
+ {
2106
+ detail::static_check_supported_config<T, A>();
2107
+ return kernel::rotate_left<N, A>(x, A {});
2108
+ }
2109
+
2110
+ /**
2111
+ * @ingroup batch_data_transfer
2112
+ *
2113
+ * Slide the whole batch to the right by \c n elements, and reintroduce the
2114
+ * slided out elements from the left. This is different from
2115
+ * \c rotr that rotates each batch element to the right.
2116
+ *
2117
+ * @tparam N Amount of elements to rotate to the right.
2118
+ * @param x batch of integer values.
2119
+ * @return rotated batch.
2120
+ */
2121
+ template <size_t N, class T, class A>
2122
+ XSIMD_INLINE batch<T, A> rotate_right(batch<T, A> const& x) noexcept
2123
+ {
2124
+ detail::static_check_supported_config<T, A>();
2125
+ return kernel::rotate_right<N, A>(x, A {});
2126
+ }
2127
+
2128
+ /**
2129
+ * @ingroup batch_bitwise
2130
+ *
2131
+ * Perform a bitwise shift to the left, reintroducing the shifted out bits
2132
+ * to the right
2133
+ * @param x batch to rotate
2134
+ * @param shift scalar amount to shift
2135
+ * @return rotated \c x.
2136
+ */
2137
+ template <class T, class A>
2138
+ XSIMD_INLINE batch<T, A> rotl(batch<T, A> const& x, int shift) noexcept
2139
+ {
2140
+ detail::static_check_supported_config<T, A>();
2141
+ return kernel::rotl<A>(x, shift, A {});
2142
+ }
2143
+ template <class T, class A>
2144
+ XSIMD_INLINE batch<T, A> rotl(batch<T, A> const& x, batch<T, A> const& shift) noexcept
2145
+ {
2146
+ detail::static_check_supported_config<T, A>();
2147
+ return kernel::rotl<A>(x, shift, A {});
2148
+ }
2149
+ template <size_t count, class T, class A>
2150
+ XSIMD_INLINE batch<T, A> rotl(batch<T, A> const& x) noexcept
2151
+ {
2152
+ detail::static_check_supported_config<T, A>();
2153
+ return kernel::rotl<count, A>(x, A {});
2154
+ }
2155
+
2156
+ /**
2157
+ * @ingroup batch_bitwise
2158
+ *
2159
+ * Perform a bitwise shift to the right, reintroducing the shifted out bits
2160
+ * to the left.
2161
+ * @param x batch to rotate
2162
+ * @param shift scalar amount to shift
2163
+ * @return rotated \c x.
2164
+ */
2165
+ template <class T, class A>
2166
+ XSIMD_INLINE batch<T, A> rotr(batch<T, A> const& x, int shift) noexcept
2167
+ {
2168
+ detail::static_check_supported_config<T, A>();
2169
+ return kernel::rotr<A>(x, shift, A {});
2170
+ }
2171
+ template <class T, class A>
2172
+ XSIMD_INLINE batch<T, A> rotr(batch<T, A> const& x, batch<T, A> const& shift) noexcept
2173
+ {
2174
+ detail::static_check_supported_config<T, A>();
2175
+ return kernel::rotr<A>(x, shift, A {});
2176
+ }
2177
+ template <size_t count, class T, class A>
2178
+ XSIMD_INLINE batch<T, A> rotr(batch<T, A> const& x) noexcept
2179
+ {
2180
+ detail::static_check_supported_config<T, A>();
2181
+ return kernel::rotr<count, A>(x, A {});
2182
+ }
2183
+
2184
+ /**
2185
+ * @ingroup batch_rounding
2186
+ *
2187
+ * Computes the batch of nearest integer values to scalars in \c x (in
2188
+ * floating point format), rounding halfway cases away from zero, regardless
2189
+ * of the current rounding mode.
2190
+ * @param x batch of flaoting point values.
2191
+ * @return the batch of nearest integer values.
2192
+ */
2193
+ template <class T, class A>
2194
+ XSIMD_INLINE batch<T, A> round(batch<T, A> const& x) noexcept
2195
+ {
2196
+ detail::static_check_supported_config<T, A>();
2197
+ return kernel::round<A>(x, A {});
2198
+ }
2199
+
2200
+ /**
2201
+ * @ingroup batch_math
2202
+ *
2203
+ * Computes an estimate of the inverse square root of the batch \c x.
2204
+ *
2205
+ * @warning Unlike most xsimd function, this does not return the same result as the
2206
+ * equivalent scalar operation, trading accuracy for speed.
2207
+ *
2208
+ * @param x batch of floating point values.
2209
+ * @return the inverse square root of \c x.
2210
+ */
2211
+ template <class T, class A>
2212
+ XSIMD_INLINE batch<T, A> rsqrt(batch<T, A> const& x) noexcept
2213
+ {
2214
+ detail::static_check_supported_config<T, A>();
2215
+ return kernel::rsqrt<A>(x, A {});
2216
+ }
2217
+
2218
+ /**
2219
+ * @ingroup batch_arithmetic
2220
+ *
2221
+ * Computes the saturate sum of the batch \c x and the batch \c y.
2222
+
2223
+ * @tparam X the actual type of batch.
2224
+ * @param x batch involved in the saturated addition.
2225
+ * @param y batch involved in the saturated addition.
2226
+ * @return the result of the saturated addition.
2227
+ */
2228
+ template <class T, class A>
2229
+ XSIMD_INLINE batch<T, A> sadd(batch<T, A> const& x, batch<T, A> const& y) noexcept
2230
+ {
2231
+ detail::static_check_supported_config<T, A>();
2232
+ return kernel::sadd<A>(x, y, A {});
2233
+ }
2234
+
2235
+ /**
2236
+ * @ingroup batch_cond
2237
+ *
2238
+ * Ternary operator for batches: selects values from the batches \c true_br or \c false_br
2239
+ * depending on the boolean values in the constant batch \c cond. Equivalent to
2240
+ * \code{.cpp}
2241
+ * for(std::size_t i = 0; i < N; ++i)
2242
+ * res[i] = cond[i] ? true_br[i] : false_br[i];
2243
+ * \endcode
2244
+ * @param cond batch condition.
2245
+ * @param true_br batch values for truthy condition.
2246
+ * @param false_br batch value for falsy condition.
2247
+ * @return the result of the selection.
2248
+ */
2249
+ template <class T, class A>
2250
+ XSIMD_INLINE batch<T, A> select(batch_bool<T, A> const& cond, batch<T, A> const& true_br, batch<T, A> const& false_br) noexcept
2251
+ {
2252
+ detail::static_check_supported_config<T, A>();
2253
+ return kernel::select<A>(cond, true_br, false_br, A {});
2254
+ }
2255
+
2256
+ /**
2257
+ * @ingroup batch_bool_logical
2258
+ *
2259
+ * Ternary operator for conditions: selects values from the batches \c true_br or \c false_br
2260
+ * depending on the boolean values in the constant batch \c cond. Equivalent to
2261
+ * \code{.cpp}
2262
+ * for(std::size_t i = 0; i < N; ++i)
2263
+ * res[i] = cond[i] ? true_br[i] : false_br[i];
2264
+ * \endcode
2265
+ * @param cond batch condition.
2266
+ * @param true_br batch values for truthy condition.
2267
+ * @param false_br batch value for falsy condition.
2268
+ * @return the result of the selection.
2269
+ */
2270
+ template <class T, class A>
2271
+ XSIMD_INLINE batch_bool<T, A> select(batch_bool<T, A> const& cond, batch_bool<T, A> const& true_br, batch_bool<T, A> const& false_br) noexcept
2272
+ {
2273
+ detail::static_check_supported_config<T, A>();
2274
+ return kernel::select<A>(cond, true_br, false_br, A {});
2275
+ }
2276
+
2277
+ /**
2278
+ * @ingroup batch_cond
2279
+ *
2280
+ * Ternary operator for batches: selects values from the batches \c true_br or \c false_br
2281
+ * depending on the boolean values in the constant batch \c cond. Equivalent to
2282
+ * \code{.cpp}
2283
+ * for(std::size_t i = 0; i < N; ++i)
2284
+ * res[i] = cond[i] ? true_br[i] : false_br[i];
2285
+ * \endcode
2286
+ * @param cond batch condition.
2287
+ * @param true_br batch values for truthy condition.
2288
+ * @param false_br batch value for falsy condition.
2289
+ * @return the result of the selection.
2290
+ */
2291
+ template <class T, class A>
2292
+ XSIMD_INLINE batch<std::complex<T>, A> select(batch_bool<T, A> const& cond, batch<std::complex<T>, A> const& true_br, batch<std::complex<T>, A> const& false_br) noexcept
2293
+ {
2294
+ detail::static_check_supported_config<T, A>();
2295
+ return kernel::select<A>(cond, true_br, false_br, A {});
2296
+ }
2297
+
2298
+ /**
2299
+ * @ingroup batch_cond
2300
+ *
2301
+ * Ternary operator for batches: selects values from the batches \c true_br or \c false_br
2302
+ * depending on the boolean values in the constant batch \c cond. Equivalent to
2303
+ * \code{.cpp}
2304
+ * for(std::size_t i = 0; i < N; ++i)
2305
+ * res[i] = cond[i] ? true_br[i] : false_br[i];
2306
+ * \endcode
2307
+ * @param cond constant batch condition.
2308
+ * @param true_br batch values for truthy condition.
2309
+ * @param false_br batch value for falsy condition.
2310
+ * @return the result of the selection.
2311
+ */
2312
+ template <class T, class A, bool... Values>
2313
+ XSIMD_INLINE batch<T, A> select(batch_bool_constant<T, A, Values...> const& cond, batch<T, A> const& true_br, batch<T, A> const& false_br) noexcept
2314
+ {
2315
+ detail::static_check_supported_config<T, A>();
2316
+ return kernel::select<A>(cond, true_br, false_br, A {});
2317
+ }
2318
+
2319
+ /**
2320
+ * @ingroup batch_cond
2321
+ *
2322
+ * Ternary operator for mask batches: selects values from the masks \c true_br or \c false_br
2323
+ * depending on the boolean values in the constant batch \c cond. Equivalent to
2324
+ * \code{.cpp}
2325
+ * for(std::size_t i = 0; i < N; ++i)
2326
+ * res[i] = cond[i] ? true_br[i] : false_br[i];
2327
+ * \endcode
2328
+ * @param cond constant batch condition.
2329
+ * @param true_br batch values for truthy condition.
2330
+ * @param false_br batch value for falsy condition.
2331
+ * @return the result of the selection.
2332
+ */
2333
+ template <class T, class A, bool... Values>
2334
+ XSIMD_INLINE batch_bool<T, A> select(batch_bool_constant<T, A, Values...> const& cond, batch_bool<T, A> const& true_br, batch_bool<T, A> const& false_br) noexcept
2335
+ {
2336
+ detail::static_check_supported_config<T, A>();
2337
+ return kernel::select<A>(cond, true_br, false_br, A {});
2338
+ }
2339
+
2340
+ /**
2341
+ * @ingroup batch_data_transfer
2342
+ *
2343
+ * Combine elements from \c x and \c y according to selector \c mask
2344
+ * @param x batch
2345
+ * @param y batch
2346
+ * @param mask constant batch mask of integer elements of the same size as
2347
+ * element of \c x and \c y. Each element of the mask index the vector that
2348
+ * would be formed by the concatenation of \c x and \c y. For instance
2349
+ * \code{.cpp}
2350
+ * batch_constant<uint32_t, sse2, 0, 4, 3, 7>
2351
+ * \endcode
2352
+ * Picks \c x[0], \c y[0], \c x[3], \c y[3]
2353
+ *
2354
+ * @return combined batch
2355
+ */
2356
+ template <class T, class A, class Vt, Vt... Values>
2357
+ XSIMD_INLINE std::enable_if_t<std::is_arithmetic<T>::value, batch<T, A>>
2358
+ shuffle(batch<T, A> const& x, batch<T, A> const& y, batch_constant<Vt, A, Values...> mask) noexcept
2359
+ {
2360
+ static_assert(sizeof(T) == sizeof(Vt), "consistent mask");
2361
+ static_assert(std::is_unsigned<Vt>::value, "mask must hold unsigned indices");
2362
+ detail::static_check_supported_config<T, A>();
2363
+ return kernel::shuffle<A>(x, y, mask, A {});
2364
+ }
2365
+
2366
+ /**
2367
+ * @ingroup batch_miscellaneous
2368
+ *
2369
+ * Computes the sign of \c x
2370
+ * @param x batch
2371
+ * @return -1 for each negative element, -1 or +1 for each null element and +1 for each element
2372
+ */
2373
+ template <class T, class A>
2374
+ XSIMD_INLINE batch<T, A> sign(batch<T, A> const& x) noexcept
2375
+ {
2376
+ detail::static_check_supported_config<T, A>();
2377
+ return kernel::sign<A>(x, A {});
2378
+ }
2379
+
2380
+ /**
2381
+ * @ingroup batch_miscellaneous
2382
+ *
2383
+ * Computes the sign of \c x, assuming x doesn't have any zero
2384
+ * @param x batch
2385
+ * @return -1 for each negative element, -1 or +1 for each null element and +1 for each element
2386
+ */
2387
+ template <class T, class A>
2388
+ XSIMD_INLINE batch<T, A> signnz(batch<T, A> const& x) noexcept
2389
+ {
2390
+ detail::static_check_supported_config<T, A>();
2391
+ return kernel::signnz<A>(x, A {});
2392
+ }
2393
+
2394
+ /**
2395
+ * @ingroup batch_trigo
2396
+ *
2397
+ * Computes the sine of the batch \c x.
2398
+ * @param x batch of floating point values.
2399
+ * @return the sine of \c x.
2400
+ */
2401
+ template <class T, class A>
2402
+ XSIMD_INLINE batch<T, A> sin(batch<T, A> const& x) noexcept
2403
+ {
2404
+ detail::static_check_supported_config<T, A>();
2405
+ return kernel::sin<A>(x, A {});
2406
+ }
2407
+
2408
+ /**
2409
+ * @ingroup batch_trigo
2410
+ *
2411
+ * Computes the sine and the cosine of the batch \c x. This method is faster
2412
+ * than calling sine and cosine independently.
2413
+ * @param x batch of floating point values.
2414
+ * @return a pair containing the sine then the cosine of batch \c x
2415
+ */
2416
+ template <class T, class A>
2417
+ XSIMD_INLINE std::pair<batch<T, A>, batch<T, A>> sincos(batch<T, A> const& x) noexcept
2418
+ {
2419
+ detail::static_check_supported_config<T, A>();
2420
+ return kernel::sincos<A>(x, A {});
2421
+ }
2422
+
2423
+ /**
2424
+ * @ingroup batch_trigo
2425
+ *
2426
+ * Computes the hyperbolic sine of the batch \c x.
2427
+ * @param x batch of floating point values.
2428
+ * @return the hyperbolic sine of \c x.
2429
+ */
2430
+ template <class T, class A>
2431
+ XSIMD_INLINE batch<T, A> sinh(batch<T, A> const& x) noexcept
2432
+ {
2433
+ detail::static_check_supported_config<T, A>();
2434
+ return kernel::sinh<A>(x, A {});
2435
+ }
2436
+
2437
+ /**
2438
+ * @ingroup batch_data_transfer
2439
+ *
2440
+ * Slide the whole batch to the left by \c n bytes. This is different from
2441
+ * \c bitwise_lshift that shifts each batch element to the left.
2442
+ *
2443
+ * @warning The behavior of this function is platform-dependent on big
2444
+ * endian architectures.
2445
+ *
2446
+ * @tparam N Amount of bytes to slide to the left.
2447
+ * @param x batch of integer values.
2448
+ * @return slided batch.
2449
+ */
2450
+ template <size_t N, class T, class A>
2451
+ XSIMD_INLINE batch<T, A> slide_left(batch<T, A> const& x) noexcept
2452
+ {
2453
+ static_assert(std::is_integral<T>::value, "can only slide batch of integers");
2454
+ detail::static_check_supported_config<T, A>();
2455
+ return kernel::slide_left<N, A>(x, A {});
2456
+ }
2457
+
2458
+ /**
2459
+ * @ingroup batch_data_transfer
2460
+ *
2461
+ * Slide the whole batch to the right by \c N bytes. This is different from
2462
+ * \c bitwise_rshift that shifts each batch element to the right.
2463
+ *
2464
+ * @warning The behavior of this function is platform-dependent on big
2465
+ * endian architectures.
2466
+ *
2467
+ * @tparam N Amount of bytes to slide to the right.
2468
+ * @param x batch of integer values.
2469
+ * @return slided batch.
2470
+ */
2471
+ template <size_t N, class T, class A>
2472
+ XSIMD_INLINE batch<T, A> slide_right(batch<T, A> const& x) noexcept
2473
+ {
2474
+ static_assert(std::is_integral<T>::value, "can only slide batch of integers");
2475
+ detail::static_check_supported_config<T, A>();
2476
+ return kernel::slide_right<N, A>(x, A {});
2477
+ }
2478
+
2479
+ /**
2480
+ * @ingroup batch_math
2481
+ *
2482
+ * Computes the square root of the batch \c x.
2483
+ * @param x batch of floating point values.
2484
+ * @return the square root of \c x.
2485
+ */
2486
+ template <class T, class A>
2487
+ XSIMD_INLINE batch<T, A> sqrt(batch<T, A> const& x) noexcept
2488
+ {
2489
+ detail::static_check_supported_config<T, A>();
2490
+ return kernel::sqrt<A>(x, A {});
2491
+ }
2492
+
2493
+ /**
2494
+ * @ingroup batch_arithmetic
2495
+ *
2496
+ * Computes the saturate difference of the batch \c x and the batch \c y.
2497
+ * @tparam X the actual type of batch.
2498
+ * @param x batch involved in the saturated difference.
2499
+ * @param y batch involved in the saturated difference.
2500
+ * @return the result of the saturated difference.
2501
+ */
2502
+ template <class T, class A>
2503
+ XSIMD_INLINE batch<T, A> ssub(batch<T, A> const& x, batch<T, A> const& y) noexcept
2504
+ {
2505
+ detail::static_check_supported_config<T, A>();
2506
+ return kernel::ssub<A>(x, y, A {});
2507
+ }
2508
+
2509
+ /**
2510
+ * @ingroup batch_data_transfer
2511
+ *
2512
+ * Copy content of batch \c src to the buffer \c dst. The
2513
+ * memory needs to be aligned.
2514
+ * @param dst the memory buffer to write to
2515
+ * @param src the batch to copy
2516
+ */
2517
+ template <class To, class A = default_arch, class From>
2518
+ XSIMD_INLINE void store_as(To* dst, batch<From, A> const& src, aligned_mode) noexcept
2519
+ {
2520
+ detail::static_check_supported_config<From, A>();
2521
+ kernel::store_aligned<A>(dst, src, A {});
2522
+ }
2523
+
2524
+ template <class A = default_arch, class From>
2525
+ XSIMD_INLINE void store_as(bool* dst, batch_bool<From, A> const& src, aligned_mode) noexcept
2526
+ {
2527
+ detail::static_check_supported_config<From, A>();
2528
+ kernel::store<A>(src, dst, A {});
2529
+ }
2530
+
2531
+ template <class To, class A = default_arch, class From>
2532
+ XSIMD_INLINE void store_as(std::complex<To>* dst, batch<std::complex<From>, A> const& src, aligned_mode) noexcept
2533
+ {
2534
+ detail::static_check_supported_config<std::complex<From>, A>();
2535
+ kernel::store_complex_aligned<A>(dst, src, A {});
2536
+ }
2537
+
2538
+ template <class To, class A = default_arch, class From>
2539
+ XSIMD_INLINE void store_as(To* dst, batch<From, A> const& src, stream_mode) noexcept
2540
+ {
2541
+ detail::static_check_supported_config<From, A>();
2542
+ kernel::store_stream<A>(dst, src, A {});
2543
+ }
2544
+
2545
+ template <class A = default_arch, class From>
2546
+ XSIMD_INLINE void store_as(bool* dst, batch_bool<From, A> const& src, stream_mode) noexcept
2547
+ {
2548
+ detail::static_check_supported_config<From, A>();
2549
+ kernel::store_stream<A>(src, dst, A {});
2550
+ }
2551
+
2552
+ template <class To, class A = default_arch, class From>
2553
+ XSIMD_INLINE void store_as(std::complex<To>* dst, batch<std::complex<From>, A> const& src, stream_mode) noexcept
2554
+ {
2555
+ detail::static_check_supported_config<std::complex<From>, A>();
2556
+ kernel::store_complex_stream<A>(dst, src, A {});
2557
+ }
2558
+
2559
+ #ifdef XSIMD_ENABLE_XTL_COMPLEX
2560
+ template <class To, class A = default_arch, class From, bool i3ec>
2561
+ XSIMD_INLINE void store_as(xtl::xcomplex<To, To, i3ec>* dst, batch<std::complex<From>, A> const& src, aligned_mode) noexcept
2562
+ {
2563
+ store_as(reinterpret_cast<std::complex<To>*>(dst), src, aligned_mode());
2564
+ }
2565
+
2566
+ template <class To, class A = default_arch, class From, bool i3ec>
2567
+ XSIMD_INLINE void store_as(xtl::xcomplex<To, To, i3ec>* dst, batch<std::complex<From>, A> const& src, stream_mode) noexcept
2568
+ {
2569
+ detail::static_check_supported_config<std::complex<From>, A>();
2570
+ store_as(reinterpret_cast<std::complex<To>*>(dst), src, stream_mode());
2571
+ }
2572
+ #endif
2573
+
2574
+ /**
2575
+ * @ingroup batch_data_transfer
2576
+ *
2577
+ * Copy content of batch \c src to the buffer \c dst. The
2578
+ * memory does not need to be aligned.
2579
+ * @param dst the memory buffer to write to
2580
+ * @param src the batch to copy
2581
+ */
2582
+ template <class To, class A = default_arch, class From>
2583
+ XSIMD_INLINE void store_as(To* dst, batch<From, A> const& src, unaligned_mode) noexcept
2584
+ {
2585
+ detail::static_check_supported_config<From, A>();
2586
+ kernel::store_unaligned<A>(dst, src, A {});
2587
+ }
2588
+
2589
+ template <class A = default_arch, class From>
2590
+ XSIMD_INLINE void store_as(bool* dst, batch_bool<From, A> const& src, unaligned_mode) noexcept
2591
+ {
2592
+ detail::static_check_supported_config<From, A>();
2593
+ kernel::store<A>(src, dst, A {});
2594
+ }
2595
+
2596
+ template <class To, class A = default_arch, class From>
2597
+ XSIMD_INLINE void store_as(std::complex<To>* dst, batch<std::complex<From>, A> const& src, unaligned_mode) noexcept
2598
+ {
2599
+ detail::static_check_supported_config<std::complex<From>, A>();
2600
+ kernel::store_complex_unaligned<A>(dst, src, A {});
2601
+ }
2602
+
2603
+ #ifdef XSIMD_ENABLE_XTL_COMPLEX
2604
+ template <class To, class A = default_arch, class From, bool i3ec>
2605
+ XSIMD_INLINE void store_as(xtl::xcomplex<To, To, i3ec>* dst, batch<std::complex<From>, A> const& src, unaligned_mode) noexcept
2606
+ {
2607
+ detail::static_check_supported_config<std::complex<From>, A>();
2608
+ store_as(reinterpret_cast<std::complex<To>*>(dst), src, unaligned_mode());
2609
+ }
2610
+ #endif
2611
+
2612
+ /**
2613
+ * @ingroup batch_data_transfer
2614
+ *
2615
+ * Copy content of batch \c val to the buffer \c mem. The
2616
+ * memory does not need to be aligned.
2617
+ * @param mem the memory buffer to write to
2618
+ * @param val the batch to copy from
2619
+ */
2620
+ template <class A, class T>
2621
+ XSIMD_INLINE void store(T* mem, batch<T, A> const& val, aligned_mode = {}) noexcept
2622
+ {
2623
+ store_as<T, A>(mem, val, aligned_mode {});
2624
+ }
2625
+
2626
+ /**
2627
+ * @ingroup batch_data_transfer
2628
+ *
2629
+ * Copy content of batch \c val to the buffer \c mem. The
2630
+ * memory does not need to be aligned.
2631
+ * @param mem the memory buffer to write to
2632
+ * @param val the batch to copy from
2633
+ */
2634
+ template <class A, class T>
2635
+ XSIMD_INLINE void store(T* mem, batch<T, A> const& val, unaligned_mode) noexcept
2636
+ {
2637
+ store_as<T, A>(mem, val, unaligned_mode {});
2638
+ }
2639
+
2640
+ template <class A, class T>
2641
+ XSIMD_INLINE void store(T* mem, batch<T, A> const& val, stream_mode) noexcept
2642
+ {
2643
+ store_as<T, A>(mem, val, stream_mode {});
2644
+ }
2645
+
2646
+ /**
2647
+ * @ingroup batch_data_transfer
2648
+ *
2649
+ * Copy selected elements of batch \c val to the buffer \c mem using
2650
+ * a mask. Elements corresponding to \c false in the mask are not
2651
+ * written to memory.
2652
+ * @param mem the memory buffer to write to
2653
+ * @param val the batch to copy from
2654
+ * @param mask selection mask for the elements to store
2655
+ */
2656
+ template <class T, class A = default_arch, bool... Values>
2657
+ XSIMD_INLINE void store(T* mem,
2658
+ batch<T, A> const& val,
2659
+ batch_bool_constant<T, A, Values...> const& mask,
2660
+ aligned_mode = {}) noexcept
2661
+ {
2662
+ detail::static_check_supported_config<T, A>();
2663
+ val.store(mem, mask, aligned_mode {});
2664
+ }
2665
+
2666
+ /**
2667
+ * @ingroup batch_data_transfer
2668
+ *
2669
+ * Copy selected elements of batch \c val to the buffer \c mem using a mask.
2670
+ * Elements corresponding to \c false in the mask are not written to memory.
2671
+ * @param mem the memory buffer to write to. The buffer does not need to be
2672
+ * aligned.
2673
+ * @param val the batch to copy from
2674
+ * @param mask selection mask for the elements to store
2675
+ */
2676
+ template <class T, class A = default_arch, bool... Values>
2677
+ XSIMD_INLINE void store(T* mem,
2678
+ batch<T, A> const& val,
2679
+ batch_bool_constant<T, A, Values...> const& mask,
2680
+ unaligned_mode) noexcept
2681
+ {
2682
+ detail::static_check_supported_config<T, A>();
2683
+ val.store(mem, mask, unaligned_mode {});
2684
+ }
2685
+
2686
+ /**
2687
+ * @ingroup batch_data_transfer
2688
+ *
2689
+ * Copy content of batch \c val to the buffer \c mem. The
2690
+ * memory needs to be aligned.
2691
+ * @param mem the memory buffer to write to
2692
+ * @param val the batch to copy from
2693
+ */
2694
+ template <class A, class T>
2695
+ XSIMD_INLINE void store_aligned(T* mem, batch<T, A> const& val) noexcept
2696
+ {
2697
+ store_as<T, A>(mem, val, aligned_mode {});
2698
+ }
2699
+
2700
+ /**
2701
+ * @ingroup batch_data_transfer
2702
+ *
2703
+ * Copy content of batch \c val to the buffer \c mem. The
2704
+ * memory does not need to be aligned.
2705
+ * @param mem the memory buffer to write to
2706
+ * @param val the batch to copy
2707
+ */
2708
+ template <class A, class T>
2709
+ XSIMD_INLINE void store_unaligned(T* mem, batch<T, A> const& val) noexcept
2710
+ {
2711
+ store_as<T, A>(mem, val, unaligned_mode {});
2712
+ }
2713
+
2714
+ /**
2715
+ * @ingroup batch_arithmetic
2716
+ *
2717
+ * Computes the difference between \c x and \c y
2718
+ * @tparam X the actual type of batch.
2719
+ * @param x scalar or batch of scalars
2720
+ * @param y scalar or batch of scalars
2721
+ * @return the difference between \c x and \c y
2722
+ */
2723
+ template <class T, class A>
2724
+ XSIMD_INLINE batch<T, A> sub(batch<T, A> const& x, batch<T, A> const& y) noexcept
2725
+ {
2726
+ detail::static_check_supported_config<T, A>();
2727
+ return x - y;
2728
+ }
2729
+
2730
+ /**
2731
+ * @ingroup batch_data_transfer
2732
+ *
2733
+ * Rearrange elements from \c x according to constant mask \c mask
2734
+ * @param x batch
2735
+ * @param mask constant batch mask of integer elements of the same size as
2736
+ * element of \c x
2737
+ * @return swizzled batch
2738
+ */
2739
+ template <class T, class A, class Vt, Vt... Values>
2740
+ XSIMD_INLINE std::enable_if_t<std::is_arithmetic<T>::value, batch<T, A>>
2741
+ swizzle(batch<T, A> const& x, batch_constant<Vt, A, Values...> mask) noexcept
2742
+ {
2743
+ static_assert(sizeof(T) == sizeof(Vt), "consistent mask");
2744
+ detail::static_check_supported_config<T, A>();
2745
+ return kernel::swizzle<A>(x, mask, A {});
2746
+ }
2747
+ template <class T, class A, class Vt, Vt... Values>
2748
+ XSIMD_INLINE batch<std::complex<T>, A> swizzle(batch<std::complex<T>, A> const& x, batch_constant<Vt, A, Values...> mask) noexcept
2749
+ {
2750
+ static_assert(sizeof(T) == sizeof(Vt), "consistent mask");
2751
+ static_assert(std::is_unsigned<Vt>::value, "mask must hold unsigned indices");
2752
+ detail::static_check_supported_config<T, A>();
2753
+ return kernel::swizzle<A>(x, mask, A {});
2754
+ }
2755
+
2756
+ /**
2757
+ * @ingroup batch_data_transfer
2758
+ *
2759
+ * Rearrange elements from \c x according to mask \c mask
2760
+ * @param x batch
2761
+ * @param mask batch mask of integer elements of the same size as
2762
+ * element of \c x
2763
+ * @return swizzled batch
2764
+ */
2765
+ template <class T, class A, class Vt>
2766
+ XSIMD_INLINE std::enable_if_t<std::is_arithmetic<T>::value, batch<T, A>>
2767
+ swizzle(batch<T, A> const& x, batch<Vt, A> mask) noexcept
2768
+ {
2769
+ static_assert(sizeof(T) == sizeof(Vt), "consistent mask");
2770
+ detail::static_check_supported_config<T, A>();
2771
+ return kernel::swizzle<A>(x, mask, A {});
2772
+ }
2773
+
2774
+ template <class T, class A, class Vt>
2775
+ XSIMD_INLINE batch<std::complex<T>, A> swizzle(batch<std::complex<T>, A> const& x, batch<Vt, A> mask) noexcept
2776
+ {
2777
+ static_assert(sizeof(T) == sizeof(Vt), "consistent mask");
2778
+ detail::static_check_supported_config<T, A>();
2779
+ return kernel::swizzle<A>(x, mask, A {});
2780
+ }
2781
+
2782
+ /**
2783
+ * @ingroup batch_trigo
2784
+ *
2785
+ * Computes the tangent of the batch \c x.
2786
+ * @param x batch of floating point values.
2787
+ * @return the tangent of \c x.
2788
+ */
2789
+ template <class T, class A>
2790
+ XSIMD_INLINE batch<T, A> tan(batch<T, A> const& x) noexcept
2791
+ {
2792
+ detail::static_check_supported_config<T, A>();
2793
+ return kernel::tan<A>(x, A {});
2794
+ }
2795
+
2796
+ /**
2797
+ * @ingroup batch_trigo
2798
+ *
2799
+ * Computes the hyperbolic tangent of the batch \c x.
2800
+ * @param x batch of floating point values.
2801
+ * @return the hyperbolic tangent of \c x.
2802
+ */
2803
+ template <class T, class A>
2804
+ XSIMD_INLINE batch<T, A> tanh(batch<T, A> const& x) noexcept
2805
+ {
2806
+ detail::static_check_supported_config<T, A>();
2807
+ return kernel::tanh<A>(x, A {});
2808
+ }
2809
+
2810
+ /**
2811
+ * @ingroup batch_math_extra
2812
+ *
2813
+ * Computes the gamma function of the batch \c x.
2814
+ * @param x batch of floating point values.
2815
+ * @return the gamma function of \c x.
2816
+ */
2817
+ template <class T, class A>
2818
+ XSIMD_INLINE batch<T, A> tgamma(batch<T, A> const& x) noexcept
2819
+ {
2820
+ detail::static_check_supported_config<T, A>();
2821
+ return kernel::tgamma<A>(x, A {});
2822
+ }
2823
+
2824
+ /**
2825
+ * @ingroup batch_conversion
2826
+ *
2827
+ * Perform a conversion from \c i to a value of an floating point type of the same size as \c T.
2828
+ * This is equivalent to \c batch_cast<as_float_t<T>>(i)
2829
+ * @param i batch of integers.
2830
+ * @return \c i converted to a value of an floating point type of the same size as \c T
2831
+ */
2832
+ template <class T, class A>
2833
+ XSIMD_INLINE batch<as_float_t<T>, A> to_float(batch<T, A> const& i) noexcept
2834
+ {
2835
+ detail::static_check_supported_config<T, A>();
2836
+ return batch_cast<as_float_t<T>>(i);
2837
+ }
2838
+
2839
+ /**
2840
+ * @ingroup batch_conversion
2841
+ *
2842
+ * Perform a conversion from \c x to a value of an integer type of the same size as \c T
2843
+ * This is equivalent to \c batch_cast<as_integer_t<T>>(x)
2844
+ * @param x batch.
2845
+ * @return \c x converted to a value of an integer type of the same size as \c T
2846
+ */
2847
+ template <class T, class A>
2848
+ XSIMD_INLINE batch<as_integer_t<T>, A> to_int(batch<T, A> const& x) noexcept
2849
+ {
2850
+ detail::static_check_supported_config<T, A>();
2851
+ return batch_cast<as_integer_t<T>>(x);
2852
+ }
2853
+
2854
+ /**
2855
+ * @ingroup batch_data_transfer
2856
+ *
2857
+ * Transposes in place the matrix whose line are each of the batch passed as
2858
+ * argument.
2859
+ * @param matrix_begin pointer to the first line of the matrix to transpose
2860
+ * @param matrix_end pointer to one element after the last line of the matrix to transpose
2861
+ *
2862
+ */
2863
+ template <class T, class A>
2864
+ XSIMD_INLINE void transpose(batch<T, A>* matrix_begin, batch<T, A>* matrix_end) noexcept
2865
+ {
2866
+ assert((matrix_end - matrix_begin == batch<T, A>::size) && "correctly sized matrix");
2867
+ detail::static_check_supported_config<T, A>();
2868
+ return kernel::transpose(matrix_begin, matrix_end, A {});
2869
+ }
2870
+
2871
+ /**
2872
+ * @ingroup batch_rounding
2873
+ *
2874
+ * Computes the batch of nearest integer values not greater in magnitude
2875
+ * than scalars in \c x.
2876
+ * @param x batch of floating point values.
2877
+ * @return the batch of nearest integer values not greater in magnitude than \c x.
2878
+ */
2879
+ template <class T, class A>
2880
+ XSIMD_INLINE batch<T, A> trunc(batch<T, A> const& x) noexcept
2881
+ {
2882
+ detail::static_check_supported_config<T, A>();
2883
+ return kernel::trunc<A>(x, A {});
2884
+ }
2885
+
2886
+ /**
2887
+ * @ingroup batch_data_transfer
2888
+ *
2889
+ * Unpack and interleave data from the HIGH half of batches \c x and \c y.
2890
+ * Store the results in the Return value.
2891
+ * @param x a batch of integer or floating point or double precision values.
2892
+ * @param y a batch of integer or floating point or double precision values.
2893
+ * @return a batch of the high part of shuffled values.
2894
+ */
2895
+ template <class T, class A>
2896
+ XSIMD_INLINE batch<T, A> zip_hi(batch<T, A> const& x, batch<T, A> const& y) noexcept
2897
+ {
2898
+ detail::static_check_supported_config<T, A>();
2899
+ return kernel::zip_hi<A>(x, y, A {});
2900
+ }
2901
+
2902
+ /**
2903
+ * @ingroup batch_data_transfer
2904
+ *
2905
+ * Unpack and interleave data from the LOW half of batches \c x and \c y.
2906
+ * Store the results in the Return value.
2907
+ * @param x a batch of integer or floating point or double precision values.
2908
+ * @param y a batch of integer or floating point or double precision values.
2909
+ * @return a batch of the low part of shuffled values.
2910
+ */
2911
+ template <class T, class A>
2912
+ XSIMD_INLINE batch<T, A> zip_lo(batch<T, A> const& x, batch<T, A> const& y) noexcept
2913
+ {
2914
+ detail::static_check_supported_config<T, A>();
2915
+ return kernel::zip_lo<A>(x, y, A {});
2916
+ }
2917
+
2918
+ /**
2919
+ * @ingroup batch_conversion
2920
+ *
2921
+ * Cast a \c batch_bool of \c T into a \c batch of the same type using the
2922
+ * following rule: if an element of \c self is true, it maps to -1 in the
2923
+ * returned integral batch, otherwise it maps to 0.
2924
+ *
2925
+ * @param self batch_bool of \c T
2926
+ * @return \c self cast to a \c batch of \c T
2927
+ */
2928
+ template <class T, class A, std::enable_if_t<std::is_integral<T>::value, int> = 3>
2929
+ XSIMD_INLINE batch<T, A> bitwise_cast(batch_bool<T, A> const& self) noexcept
2930
+ {
2931
+ T z(0);
2932
+ detail::static_check_supported_config<T, A>();
2933
+ return select(self, batch<T, A>(T(~z)), batch<T, A>(z));
2934
+ }
2935
+
2936
+ template <class T, class A, std::enable_if_t<std::is_floating_point<T>::value, int> = 3>
2937
+ XSIMD_INLINE batch<T, A> bitwise_cast(batch_bool<T, A> const& self) noexcept
2938
+ {
2939
+ T z0(0), z1(0);
2940
+ using int_type = as_unsigned_integer_t<T>;
2941
+ int_type value(~int_type(0));
2942
+ std::memcpy(&z1, &value, sizeof(int_type));
2943
+ detail::static_check_supported_config<T, A>();
2944
+ return select(self, batch<T, A>(z1), batch<T, A>(z0));
2945
+ }
2946
+
2947
+ /**
2948
+ * @ingroup batch_bool_reducers
2949
+ *
2950
+ * Returns true if all the boolean values in the batch are true,
2951
+ * false otherwise.
2952
+ * @param x the batch to reduce.
2953
+ * @return a boolean scalar.
2954
+ */
2955
+ template <class T, class A>
2956
+ XSIMD_INLINE bool all(batch_bool<T, A> const& x) noexcept
2957
+ {
2958
+ detail::static_check_supported_config<T, A>();
2959
+ return kernel::all<A>(x, A {});
2960
+ }
2961
+
2962
+ /**
2963
+ * @ingroup batch_bool_reducers
2964
+ *
2965
+ * Return true if any of the boolean values in the batch is true,
2966
+ * false otherwise.
2967
+ * @param x the batch to reduce.
2968
+ * @return a boolean scalar.
2969
+ */
2970
+ template <class T, class A>
2971
+ XSIMD_INLINE bool any(batch_bool<T, A> const& x) noexcept
2972
+ {
2973
+ detail::static_check_supported_config<T, A>();
2974
+ return kernel::any<A>(x, A {});
2975
+ }
2976
+
2977
+ /**
2978
+ * @ingroup batch_bool_reducers
2979
+ *
2980
+ * Return true if none of the boolean values in the batch is true,
2981
+ * false otherwise.
2982
+ * @param x the batch to reduce.
2983
+ * @return a boolean scalar.
2984
+ */
2985
+ template <class T, class A>
2986
+ XSIMD_INLINE bool none(batch_bool<T, A> const& x) noexcept
2987
+ {
2988
+ detail::static_check_supported_config<T, A>();
2989
+ return !xsimd::any(x);
2990
+ }
2991
+
2992
+ /**
2993
+ * @ingroup batch_bool_reducers
2994
+ *
2995
+ * Return the number of leading `false` values in the batch.
2996
+ * @param x the batch to reduce.
2997
+ * @return an integer scalar.
2998
+ */
2999
+ template <class T, class A>
3000
+ XSIMD_INLINE size_t countl_zero(batch_bool<T, A> const& x) noexcept
3001
+ {
3002
+ detail::static_check_supported_config<T, A>();
3003
+ return kernel::countl_zero<A>(x, A {});
3004
+ }
3005
+
3006
+ /**
3007
+ * @ingroup batch_bool_reducers
3008
+ *
3009
+ * Return the number of leading `true` values in the batch.
3010
+ * @param x the batch to reduce.
3011
+ * @return an integer scalar.
3012
+ */
3013
+ template <class T, class A>
3014
+ XSIMD_INLINE size_t countl_one(batch_bool<T, A> const& x) noexcept
3015
+ {
3016
+ detail::static_check_supported_config<T, A>();
3017
+ return kernel::countl_one<A>(x, A {});
3018
+ }
3019
+
3020
+ /**
3021
+ * @ingroup batch_bool_reducers
3022
+ *
3023
+ * Return the number of trailing `false` values in the batch.
3024
+ * @param x the batch to reduce.
3025
+ * @return an integer scalar.
3026
+ */
3027
+ template <class T, class A>
3028
+ XSIMD_INLINE size_t countr_zero(batch_bool<T, A> const& x) noexcept
3029
+ {
3030
+ detail::static_check_supported_config<T, A>();
3031
+ return kernel::countr_zero<A>(x, A {});
3032
+ }
3033
+
3034
+ /**
3035
+ * @ingroup batch_bool_reducers
3036
+ *
3037
+ * Return the number of trailing `true` values in the batch.
3038
+ * @param x the batch to reduce.
3039
+ * @return an integer scalar.
3040
+ */
3041
+ template <class T, class A>
3042
+ XSIMD_INLINE size_t countr_one(batch_bool<T, A> const& x) noexcept
3043
+ {
3044
+ detail::static_check_supported_config<T, A>();
3045
+ return kernel::countr_one<A>(x, A {});
3046
+ }
3047
+
3048
+ /**
3049
+ * @ingroup batch_conversion
3050
+ *
3051
+ * Widen batch \c x from type \c T to a type with twice as many bytes and
3052
+ * the same sign (for integers) or from float to double.
3053
+ * @param x batch of \c T
3054
+ * @return two batches of \c widen_t<T>
3055
+ */
3056
+ template <class T, class A>
3057
+ XSIMD_INLINE std::array<batch<widen_t<T>, A>, 2> widen(batch<T, A> const& x) noexcept
3058
+ {
3059
+ detail::static_check_supported_config<T, A>();
3060
+ return kernel::widen<A>(x, A {});
3061
+ }
3062
+
3063
+ /**
3064
+ * @ingroup batch_miscellaneous
3065
+ *
3066
+ * Dump the content of batch \c x to stream \c o
3067
+ * @param o the stream where the batch is dumped
3068
+ * @param x batch to dump.
3069
+ * @return a reference to \c o
3070
+ */
3071
+ template <class T, class A>
3072
+ XSIMD_INLINE std::ostream& operator<<(std::ostream& o, batch<T, A> const& x) noexcept
3073
+ {
3074
+ detail::static_check_supported_config<T, A>();
3075
+ constexpr auto size = batch<T, A>::size;
3076
+ alignas(A::alignment()) T buffer[size];
3077
+ x.store_aligned(&buffer[0]);
3078
+ o << '(';
3079
+ for (std::size_t i = 0; i < size - 1; ++i)
3080
+ o << buffer[i] << ", ";
3081
+ return o << buffer[size - 1] << ')';
3082
+ }
3083
+
3084
+ /**
3085
+ * @ingroup batch_miscellaneous
3086
+ *
3087
+ * Dump the content of batch \c x to stream \c o
3088
+ * @param o the stream where the batch is dumped
3089
+ * @param x batch to dump.
3090
+ * @return a reference to \c o
3091
+ */
3092
+ template <class T, class A>
3093
+ XSIMD_INLINE std::ostream& operator<<(std::ostream& o, batch_bool<T, A> const& x) noexcept
3094
+ {
3095
+ detail::static_check_supported_config<T, A>();
3096
+ constexpr auto size = batch_bool<T, A>::size;
3097
+ alignas(A::alignment()) bool buffer[size];
3098
+ x.store_aligned(&buffer[0]);
3099
+ o << '(';
3100
+ for (std::size_t i = 0; i < size - 1; ++i)
3101
+ o << buffer[i] << ", ";
3102
+ return o << buffer[size - 1] << ')';
3103
+ }
3104
+ }
3105
+
3106
+ #endif