noobs 0.0.6

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 (185) hide show
  1. package/COPYING +339 -0
  2. package/README.md +46 -0
  3. package/bin/64bit/obs.lib +0 -0
  4. package/binding.gyp +23 -0
  5. package/dist/bin/Qt6Core.dll +0 -0
  6. package/dist/bin/Qt6Gui.dll +0 -0
  7. package/dist/bin/Qt6Network.dll +0 -0
  8. package/dist/bin/Qt6Svg.dll +0 -0
  9. package/dist/bin/Qt6Widgets.dll +0 -0
  10. package/dist/bin/Qt6Xml.dll +0 -0
  11. package/dist/bin/avcodec-61.dll +0 -0
  12. package/dist/bin/avdevice-61.dll +0 -0
  13. package/dist/bin/avfilter-10.dll +0 -0
  14. package/dist/bin/avformat-61.dll +0 -0
  15. package/dist/bin/avutil-59.dll +0 -0
  16. package/dist/bin/datachannel.dll +0 -0
  17. package/dist/bin/libcurl.dll +0 -0
  18. package/dist/bin/libobs-d3d11.dll +0 -0
  19. package/dist/bin/libobs-opengl.dll +0 -0
  20. package/dist/bin/libobs-winrt.dll +0 -0
  21. package/dist/bin/librist.dll +0 -0
  22. package/dist/bin/libx264-164.dll +0 -0
  23. package/dist/bin/lua51.dll +0 -0
  24. package/dist/bin/obs-amf-test.exe +0 -0
  25. package/dist/bin/obs-ffmpeg-mux.exe +0 -0
  26. package/dist/bin/obs-frontend-api.dll +0 -0
  27. package/dist/bin/obs-scripting.dll +0 -0
  28. package/dist/bin/obs.dll +0 -0
  29. package/dist/bin/srt.dll +0 -0
  30. package/dist/bin/swresample-5.dll +0 -0
  31. package/dist/bin/swscale-8.dll +0 -0
  32. package/dist/bin/w32-pthreads.dll +0 -0
  33. package/dist/bin/zlib.dll +0 -0
  34. package/dist/effects/area.effect +250 -0
  35. package/dist/effects/bicubic_scale.effect +236 -0
  36. package/dist/effects/bilinear_lowres_scale.effect +123 -0
  37. package/dist/effects/color.effect +172 -0
  38. package/dist/effects/default.effect +254 -0
  39. package/dist/effects/default_rect.effect +84 -0
  40. package/dist/effects/deinterlace_base.effect +325 -0
  41. package/dist/effects/deinterlace_blend.effect +21 -0
  42. package/dist/effects/deinterlace_blend_2x.effect +21 -0
  43. package/dist/effects/deinterlace_discard.effect +21 -0
  44. package/dist/effects/deinterlace_discard_2x.effect +21 -0
  45. package/dist/effects/deinterlace_linear.effect +21 -0
  46. package/dist/effects/deinterlace_linear_2x.effect +21 -0
  47. package/dist/effects/deinterlace_yadif.effect +21 -0
  48. package/dist/effects/deinterlace_yadif_2x.effect +21 -0
  49. package/dist/effects/format_conversion.effect +1823 -0
  50. package/dist/effects/lanczos_scale.effect +292 -0
  51. package/dist/effects/opaque.effect +159 -0
  52. package/dist/effects/premultiplied_alpha.effect +38 -0
  53. package/dist/effects/repeat.effect +36 -0
  54. package/dist/effects/solid.effect +80 -0
  55. package/dist/noobs.node +0 -0
  56. package/dist/plugins/obs-ffmpeg.dll +0 -0
  57. package/dist/plugins/obs-x264.dll +0 -0
  58. package/dist/plugins/win-capture.dll +0 -0
  59. package/include/audio-monitoring/osx/mac-helpers.h +13 -0
  60. package/include/audio-monitoring/pulse/pulseaudio-wrapper.h +212 -0
  61. package/include/audio-monitoring/win32/wasapi-output.h +22 -0
  62. package/include/callback/calldata.h +195 -0
  63. package/include/callback/decl.h +61 -0
  64. package/include/callback/proc.h +52 -0
  65. package/include/callback/signal.h +73 -0
  66. package/include/graphics/axisang.h +65 -0
  67. package/include/graphics/bounds.h +108 -0
  68. package/include/graphics/device-exports.h +177 -0
  69. package/include/graphics/effect-parser.h +290 -0
  70. package/include/graphics/effect.h +190 -0
  71. package/include/graphics/graphics-internal.h +335 -0
  72. package/include/graphics/graphics.h +1024 -0
  73. package/include/graphics/half.h +100 -0
  74. package/include/graphics/image-file.h +124 -0
  75. package/include/graphics/input.h +34 -0
  76. package/include/graphics/libnsgif/libnsgif.h +142 -0
  77. package/include/graphics/math-defs.h +45 -0
  78. package/include/graphics/math-extra.h +61 -0
  79. package/include/graphics/matrix3.h +98 -0
  80. package/include/graphics/matrix4.h +102 -0
  81. package/include/graphics/plane.h +85 -0
  82. package/include/graphics/quat.h +170 -0
  83. package/include/graphics/shader-parser.h +273 -0
  84. package/include/graphics/srgb.h +177 -0
  85. package/include/graphics/vec2.h +148 -0
  86. package/include/graphics/vec3.h +224 -0
  87. package/include/graphics/vec4.h +241 -0
  88. package/include/media-io/audio-io.h +228 -0
  89. package/include/media-io/audio-math.h +43 -0
  90. package/include/media-io/audio-resampler.h +44 -0
  91. package/include/media-io/format-conversion.h +50 -0
  92. package/include/media-io/frame-rate.h +29 -0
  93. package/include/media-io/media-io-defs.h +20 -0
  94. package/include/media-io/media-remux.h +37 -0
  95. package/include/media-io/video-frame.h +64 -0
  96. package/include/media-io/video-io.h +338 -0
  97. package/include/media-io/video-scaler.h +43 -0
  98. package/include/obs-audio-controls.h +250 -0
  99. package/include/obs-av1.h +47 -0
  100. package/include/obs-avc.h +55 -0
  101. package/include/obs-config.h +52 -0
  102. package/include/obs-data.h +311 -0
  103. package/include/obs-defs.h +52 -0
  104. package/include/obs-encoder.h +361 -0
  105. package/include/obs-ffmpeg-compat.h +13 -0
  106. package/include/obs-hevc.h +81 -0
  107. package/include/obs-hotkey.h +271 -0
  108. package/include/obs-hotkeys.h +653 -0
  109. package/include/obs-interaction.h +56 -0
  110. package/include/obs-internal.h +1459 -0
  111. package/include/obs-missing-files.h +53 -0
  112. package/include/obs-module.h +181 -0
  113. package/include/obs-nal.h +37 -0
  114. package/include/obs-nix-platform.h +53 -0
  115. package/include/obs-nix-wayland.h +24 -0
  116. package/include/obs-nix-x11.h +22 -0
  117. package/include/obs-nix.h +42 -0
  118. package/include/obs-output.h +96 -0
  119. package/include/obs-properties.h +364 -0
  120. package/include/obs-scene.h +127 -0
  121. package/include/obs-service.h +115 -0
  122. package/include/obs-source.h +568 -0
  123. package/include/obs.h +2608 -0
  124. package/include/obsconfig.h +13 -0
  125. package/include/obsversion.h +5 -0
  126. package/include/util/apple/cfstring-utils.h +16 -0
  127. package/include/util/array-serializer.h +37 -0
  128. package/include/util/base.h +97 -0
  129. package/include/util/bitstream.h +28 -0
  130. package/include/util/bmem.h +94 -0
  131. package/include/util/buffered-file-serializer.h +32 -0
  132. package/include/util/c99defs.h +75 -0
  133. package/include/util/cf-lexer.h +199 -0
  134. package/include/util/cf-parser.h +281 -0
  135. package/include/util/circlebuf.h +319 -0
  136. package/include/util/config-file.h +103 -0
  137. package/include/util/crc32.h +29 -0
  138. package/include/util/curl/curl-helper.h +35 -0
  139. package/include/util/darray.h +606 -0
  140. package/include/util/deque.h +319 -0
  141. package/include/util/dstr.h +320 -0
  142. package/include/util/file-serializer.h +34 -0
  143. package/include/util/lexer.h +273 -0
  144. package/include/util/pipe.h +52 -0
  145. package/include/util/platform.h +223 -0
  146. package/include/util/profiler.h +97 -0
  147. package/include/util/serializer.h +158 -0
  148. package/include/util/simde/check.h +285 -0
  149. package/include/util/simde/debug-trap.h +117 -0
  150. package/include/util/simde/hedley.h +2123 -0
  151. package/include/util/simde/simde-align.h +481 -0
  152. package/include/util/simde/simde-arch.h +537 -0
  153. package/include/util/simde/simde-common.h +918 -0
  154. package/include/util/simde/simde-constify.h +925 -0
  155. package/include/util/simde/simde-detect-clang.h +114 -0
  156. package/include/util/simde/simde-diagnostic.h +447 -0
  157. package/include/util/simde/simde-features.h +550 -0
  158. package/include/util/simde/simde-math.h +1858 -0
  159. package/include/util/simde/x86/mmx.h +2456 -0
  160. package/include/util/simde/x86/sse.h +4479 -0
  161. package/include/util/simde/x86/sse2.h +7549 -0
  162. package/include/util/source-profiler.h +66 -0
  163. package/include/util/sse-intrin.h +32 -0
  164. package/include/util/task.h +22 -0
  165. package/include/util/text-lookup.h +45 -0
  166. package/include/util/threading-posix.h +77 -0
  167. package/include/util/threading-windows.h +142 -0
  168. package/include/util/threading.h +103 -0
  169. package/include/util/utf8.h +35 -0
  170. package/include/util/uthash.h +34 -0
  171. package/include/util/util_uint128.h +108 -0
  172. package/include/util/util_uint64.h +34 -0
  173. package/include/util/windows/device-enum.h +14 -0
  174. package/include/util/windows/obfuscate.h +16 -0
  175. package/include/util/windows/win-registry.h +37 -0
  176. package/include/util/windows/win-version.h +57 -0
  177. package/include/util/windows/window-helpers.h +47 -0
  178. package/index.d.ts +38 -0
  179. package/index.js +8 -0
  180. package/package.json +31 -0
  181. package/src/main.cpp +321 -0
  182. package/src/obs_interface.cpp +605 -0
  183. package/src/obs_interface.h +74 -0
  184. package/src/utils.cpp +80 -0
  185. package/src/utils.h +3 -0
@@ -0,0 +1,1858 @@
1
+ /* SPDX-License-Identifier: MIT
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person
4
+ * obtaining a copy of this software and associated documentation
5
+ * files (the "Software"), to deal in the Software without
6
+ * restriction, including without limitation the rights to use, copy,
7
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
8
+ * of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be
12
+ * included in all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ *
23
+ * Copyright:
24
+ * 2017-2020 Evan Nemerson <evan@nemerson.com>
25
+ */
26
+
27
+ /* Attempt to find math functions. Functions may be in <cmath>,
28
+ * <math.h>, compiler built-ins/intrinsics, or platform/architecture
29
+ * specific headers. In some cases, especially those not built in to
30
+ * libm, we may need to define our own implementations. */
31
+
32
+ #if !defined(SIMDE_MATH_H)
33
+
34
+ #include "hedley.h"
35
+ #include "simde-features.h"
36
+
37
+ #include <stdint.h>
38
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
39
+ #include <arm_neon.h>
40
+ #endif
41
+
42
+ HEDLEY_DIAGNOSTIC_PUSH
43
+ SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
44
+
45
+ /* SLEEF support
46
+ * https://sleef.org/
47
+ *
48
+ * If you include <sleef.h> prior to including SIMDe, SIMDe will use
49
+ * SLEEF. You can also define SIMDE_MATH_SLEEF_ENABLE prior to
50
+ * including SIMDe to force the issue.
51
+ *
52
+ * Note that SLEEF does requires linking to libsleef.
53
+ *
54
+ * By default, SIMDe will use the 1 ULP functions, but if you use
55
+ * SIMDE_ACCURACY_PREFERENCE of 0 we will use up to 4 ULP. This is
56
+ * only the case for the simde_math_* functions; for code in other
57
+ * SIMDe headers which calls SLEEF directly we may use functions with
58
+ * greater error if the API we're implementing is less precise (for
59
+ * example, SVML guarantees 4 ULP, so we will generally use the 3.5
60
+ * ULP functions from SLEEF). */
61
+ #if !defined(SIMDE_MATH_SLEEF_DISABLE)
62
+ #if defined(__SLEEF_H__)
63
+ #define SIMDE_MATH_SLEEF_ENABLE
64
+ #endif
65
+ #endif
66
+
67
+ #if defined(SIMDE_MATH_SLEEF_ENABLE) && !defined(__SLEEF_H__)
68
+ HEDLEY_DIAGNOSTIC_PUSH
69
+ SIMDE_DIAGNOSTIC_DISABLE_IGNORED_QUALIFIERS_
70
+ #include <sleef.h>
71
+ HEDLEY_DIAGNOSTIC_POP
72
+ #endif
73
+
74
+ #if defined(SIMDE_MATH_SLEEF_ENABLE) && defined(__SLEEF_H__)
75
+ #if defined(SLEEF_VERSION_MAJOR)
76
+ #define SIMDE_MATH_SLEEF_VERSION_CHECK(major, minor, patch) \
77
+ (HEDLEY_VERSION_ENCODE(SLEEF_VERSION_MAJOR, SLEEF_VERSION_MINOR, \
78
+ SLEEF_VERSION_PATCHLEVEL) >= \
79
+ HEDLEY_VERSION_ENCODE(major, minor, patch))
80
+ #else
81
+ #define SIMDE_MATH_SLEEF_VERSION_CHECK(major, minor, patch) \
82
+ (HEDLEY_VERSION_ENCODE(3, 0, 0) >= \
83
+ HEDLEY_VERSION_ENCODE(major, minor, patch))
84
+ #endif
85
+ #else
86
+ #define SIMDE_MATH_SLEEF_VERSION_CHECK(major, minor, patch) (0)
87
+ #endif
88
+
89
+ #if defined(__has_builtin)
90
+ #define SIMDE_MATH_BUILTIN_LIBM(func) __has_builtin(__builtin_##func)
91
+ #elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
92
+ HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || HEDLEY_GCC_VERSION_CHECK(4, 4, 0)
93
+ #define SIMDE_MATH_BUILTIN_LIBM(func) (1)
94
+ #else
95
+ #define SIMDE_MATH_BUILTIN_LIBM(func) (0)
96
+ #endif
97
+
98
+ #if defined(HUGE_VAL)
99
+ /* Looks like <math.h> or <cmath> has already been included. */
100
+
101
+ /* The math.h from libc++ (yes, the C header from the C++ standard
102
+ * library) will define an isnan function, but not an isnan macro
103
+ * like the C standard requires. So we detect the header guards
104
+ * macro libc++ uses. */
105
+ #if defined(isnan) || (defined(_LIBCPP_MATH_H) && !defined(_LIBCPP_CMATH))
106
+ #define SIMDE_MATH_HAVE_MATH_H
107
+ #elif defined(__cplusplus)
108
+ #define SIMDE_MATH_HAVE_CMATH
109
+ #endif
110
+ #elif defined(__has_include)
111
+ #if defined(__cplusplus) && (__cplusplus >= 201103L) && __has_include(<cmath>)
112
+ #define SIMDE_MATH_HAVE_CMATH
113
+ #include <cmath>
114
+ #elif __has_include(<math.h>)
115
+ #define SIMDE_MATH_HAVE_MATH_H
116
+ #include <math.h>
117
+ #elif !defined(SIMDE_MATH_NO_LIBM)
118
+ #define SIMDE_MATH_NO_LIBM
119
+ #endif
120
+ #elif !defined(SIMDE_MATH_NO_LIBM)
121
+ #if defined(__cplusplus) && (__cplusplus >= 201103L)
122
+ #define SIMDE_MATH_HAVE_CMATH
123
+ HEDLEY_DIAGNOSTIC_PUSH
124
+ #if defined(HEDLEY_MSVC_VERSION)
125
+ /* VS 14 emits this diagnostic about noexcept being used on a
126
+ * <cmath> function, which we can't do anything about. */
127
+ #pragma warning(disable : 4996)
128
+ #endif
129
+ #include <cmath>
130
+ HEDLEY_DIAGNOSTIC_POP
131
+ #else
132
+ #define SIMDE_MATH_HAVE_MATH_H
133
+ #include <math.h>
134
+ #endif
135
+ #endif
136
+
137
+ /* Try to avoid including <complex> since it pulls in a *lot* of code. */
138
+ #if HEDLEY_HAS_BUILTIN(__builtin_creal) || \
139
+ HEDLEY_GCC_VERSION_CHECK(4, 7, 0) || \
140
+ HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
141
+ HEDLEY_DIAGNOSTIC_PUSH
142
+ SIMDE_DIAGNOSTIC_DISABLE_C99_EXTENSIONS_
143
+ typedef __complex__ float simde_cfloat32;
144
+ typedef __complex__ double simde_cfloat64;
145
+ HEDLEY_DIAGNOSTIC_POP
146
+ #define SIMDE_MATH_CMPLX(x, y) \
147
+ (HEDLEY_STATIC_CAST(double, x) + \
148
+ HEDLEY_STATIC_CAST(double, y) * (__extension__ 1.0j))
149
+ #define SIMDE_MATH_CMPLXF(x, y) \
150
+ (HEDLEY_STATIC_CAST(float, x) + \
151
+ HEDLEY_STATIC_CAST(float, y) * (__extension__ 1.0fj))
152
+
153
+ #if !defined(simde_math_creal)
154
+ #define simde_math_crealf(z) __builtin_crealf(z)
155
+ #endif
156
+ #if !defined(simde_math_crealf)
157
+ #define simde_math_creal(z) __builtin_creal(z)
158
+ #endif
159
+ #if !defined(simde_math_cimag)
160
+ #define simde_math_cimagf(z) __builtin_cimagf(z)
161
+ #endif
162
+ #if !defined(simde_math_cimagf)
163
+ #define simde_math_cimag(z) __builtin_cimag(z)
164
+ #endif
165
+ #elif !defined(__cplusplus)
166
+ #include <complex.h>
167
+
168
+ #if !defined(HEDLEY_MSVC_VERSION)
169
+ typedef float _Complex simde_cfloat32;
170
+ typedef double _Complex simde_cfloat64;
171
+ #else
172
+ typedef _Fcomplex simde_cfloat32;
173
+ typedef _Dcomplex simde_cfloat64;
174
+ #endif
175
+
176
+ #if defined(HEDLEY_MSVC_VERSION)
177
+ #define SIMDE_MATH_CMPLX(x, y) ((simde_cfloat64){(x), (y)})
178
+ #define SIMDE_MATH_CMPLXF(x, y) ((simde_cfloat32){(x), (y)})
179
+ #elif defined(CMPLX) && defined(CMPLXF)
180
+ #define SIMDE_MATH_CMPLX(x, y) CMPLX(x, y)
181
+ #define SIMDE_MATH_CMPLXF(x, y) CMPLXF(x, y)
182
+ #else
183
+ #define SIMDE_MATH_CMPLX(x, y) \
184
+ (HEDLEY_STATIC_CAST(double, x) + HEDLEY_STATIC_CAST(double, y) * I)
185
+ #define SIMDE_MATH_CMPLXF(x, y) \
186
+ (HEDLEY_STATIC_CAST(float, x) + HEDLEY_STATIC_CAST(float, y) * I)
187
+ #endif
188
+
189
+ #if !defined(simde_math_creal)
190
+ #define simde_math_creal(z) creal(z)
191
+ #endif
192
+ #if !defined(simde_math_crealf)
193
+ #define simde_math_crealf(z) crealf(z)
194
+ #endif
195
+ #if !defined(simde_math_cimag)
196
+ #define simde_math_cimag(z) cimag(z)
197
+ #endif
198
+ #if !defined(simde_math_cimagf)
199
+ #define simde_math_cimagf(z) cimagf(z)
200
+ #endif
201
+ #else
202
+ HEDLEY_DIAGNOSTIC_PUSH
203
+ #if defined(HEDLEY_MSVC_VERSION)
204
+ #pragma warning(disable : 4530)
205
+ #endif
206
+ #include <complex>
207
+ HEDLEY_DIAGNOSTIC_POP
208
+
209
+ typedef std::complex<float> simde_cfloat32;
210
+ typedef std::complex<double> simde_cfloat64;
211
+ #define SIMDE_MATH_CMPLX(x, y) (std::complex<double>(x, y))
212
+ #define SIMDE_MATH_CMPLXF(x, y) (std::complex<float>(x, y))
213
+
214
+ #if !defined(simde_math_creal)
215
+ #define simde_math_creal(z) ((z).real())
216
+ #endif
217
+ #if !defined(simde_math_crealf)
218
+ #define simde_math_crealf(z) ((z).real())
219
+ #endif
220
+ #if !defined(simde_math_cimag)
221
+ #define simde_math_cimag(z) ((z).imag())
222
+ #endif
223
+ #if !defined(simde_math_cimagf)
224
+ #define simde_math_cimagf(z) ((z).imag())
225
+ #endif
226
+ #endif
227
+
228
+ #if !defined(SIMDE_MATH_INFINITY)
229
+ #if HEDLEY_HAS_BUILTIN(__builtin_inf) || HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \
230
+ HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
231
+ HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
232
+ HEDLEY_CRAY_VERSION_CHECK(8, 1, 0)
233
+ #define SIMDE_MATH_INFINITY (__builtin_inf())
234
+ #elif defined(INFINITY)
235
+ #define SIMDE_MATH_INFINITY INFINITY
236
+ #endif
237
+ #endif
238
+
239
+ #if !defined(SIMDE_INFINITYF)
240
+ #if HEDLEY_HAS_BUILTIN(__builtin_inff) || HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \
241
+ HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
242
+ HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \
243
+ HEDLEY_IBM_VERSION_CHECK(13, 1, 0)
244
+ #define SIMDE_MATH_INFINITYF (__builtin_inff())
245
+ #elif defined(INFINITYF)
246
+ #define SIMDE_MATH_INFINITYF INFINITYF
247
+ #elif defined(SIMDE_MATH_INFINITY)
248
+ #define SIMDE_MATH_INFINITYF HEDLEY_STATIC_CAST(float, SIMDE_MATH_INFINITY)
249
+ #endif
250
+ #endif
251
+
252
+ #if !defined(SIMDE_MATH_NAN)
253
+ #if HEDLEY_HAS_BUILTIN(__builtin_nan) || HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \
254
+ HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
255
+ HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
256
+ HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \
257
+ HEDLEY_IBM_VERSION_CHECK(13, 1, 0)
258
+ #define SIMDE_MATH_NAN (__builtin_nan(""))
259
+ #elif defined(NAN)
260
+ #define SIMDE_MATH_NAN NAN
261
+ #endif
262
+ #endif
263
+
264
+ #if !defined(SIMDE_NANF)
265
+ #if HEDLEY_HAS_BUILTIN(__builtin_nanf) || HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \
266
+ HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
267
+ HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
268
+ HEDLEY_CRAY_VERSION_CHECK(8, 1, 0)
269
+ #define SIMDE_MATH_NANF (__builtin_nanf(""))
270
+ #elif defined(NANF)
271
+ #define SIMDE_MATH_NANF NANF
272
+ #elif defined(SIMDE_MATH_NAN)
273
+ #define SIMDE_MATH_NANF HEDLEY_STATIC_CAST(float, SIMDE_MATH_NAN)
274
+ #endif
275
+ #endif
276
+
277
+ #if !defined(SIMDE_MATH_PI)
278
+ #if defined(M_PI)
279
+ #define SIMDE_MATH_PI M_PI
280
+ #else
281
+ #define SIMDE_MATH_PI 3.14159265358979323846
282
+ #endif
283
+ #endif
284
+
285
+ #if !defined(SIMDE_MATH_PIF)
286
+ #if defined(M_PI)
287
+ #define SIMDE_MATH_PIF HEDLEY_STATIC_CAST(float, M_PI)
288
+ #else
289
+ #define SIMDE_MATH_PIF 3.14159265358979323846f
290
+ #endif
291
+ #endif
292
+
293
+ #if !defined(SIMDE_MATH_PI_OVER_180)
294
+ #define SIMDE_MATH_PI_OVER_180 \
295
+ 0.0174532925199432957692369076848861271344287188854172545609719144
296
+ #endif
297
+
298
+ #if !defined(SIMDE_MATH_PI_OVER_180F)
299
+ #define SIMDE_MATH_PI_OVER_180F \
300
+ 0.0174532925199432957692369076848861271344287188854172545609719144f
301
+ #endif
302
+
303
+ #if !defined(SIMDE_MATH_180_OVER_PI)
304
+ #define SIMDE_MATH_180_OVER_PI \
305
+ 57.295779513082320876798154814105170332405472466564321549160243861
306
+ #endif
307
+
308
+ #if !defined(SIMDE_MATH_180_OVER_PIF)
309
+ #define SIMDE_MATH_180_OVER_PIF \
310
+ 57.295779513082320876798154814105170332405472466564321549160243861f
311
+ #endif
312
+
313
+ #if !defined(SIMDE_MATH_FLT_MIN)
314
+ #if defined(FLT_MIN)
315
+ #define SIMDE_MATH_FLT_MIN FLT_MIN
316
+ #elif defined(__FLT_MIN__)
317
+ #define SIMDE_MATH_FLT_MIN __FLT_MIN__
318
+ #elif defined(__cplusplus)
319
+ #include <cfloat>
320
+ #define SIMDE_MATH_FLT_MIN FLT_MIN
321
+ #else
322
+ #include <float.h>
323
+ #define SIMDE_MATH_FLT_MIN FLT_MIN
324
+ #endif
325
+ #endif
326
+
327
+ #if !defined(SIMDE_MATH_DBL_MIN)
328
+ #if defined(DBL_MIN)
329
+ #define SIMDE_MATH_DBL_MIN DBL_MIN
330
+ #elif defined(__DBL_MIN__)
331
+ #define SIMDE_MATH_DBL_MIN __DBL_MIN__
332
+ #elif defined(__cplusplus)
333
+ #include <cfloat>
334
+ #define SIMDE_MATH_DBL_MIN DBL_MIN
335
+ #else
336
+ #include <float.h>
337
+ #define SIMDE_MATH_DBL_MIN DBL_MIN
338
+ #endif
339
+ #endif
340
+
341
+ /*** Classification macros from C99 ***/
342
+
343
+ #if !defined(simde_math_isinf)
344
+ #if SIMDE_MATH_BUILTIN_LIBM(isinf)
345
+ #define simde_math_isinf(v) __builtin_isinf(v)
346
+ #elif defined(isinf) || defined(SIMDE_MATH_HAVE_MATH_H)
347
+ #define simde_math_isinf(v) isinf(v)
348
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
349
+ #define simde_math_isinf(v) std::isinf(v)
350
+ #endif
351
+ #endif
352
+
353
+ #if !defined(simde_math_isinff)
354
+ #if HEDLEY_HAS_BUILTIN(__builtin_isinff) || \
355
+ HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
356
+ HEDLEY_ARM_VERSION_CHECK(4, 1, 0)
357
+ #define simde_math_isinff(v) __builtin_isinff(v)
358
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
359
+ #define simde_math_isinff(v) std::isinf(v)
360
+ #elif defined(simde_math_isinf)
361
+ #define simde_math_isinff(v) simde_math_isinf(HEDLEY_STATIC_CAST(double, v))
362
+ #endif
363
+ #endif
364
+
365
+ #if !defined(simde_math_isnan)
366
+ #if SIMDE_MATH_BUILTIN_LIBM(isnan)
367
+ #define simde_math_isnan(v) __builtin_isnan(v)
368
+ #elif defined(isnan) || defined(SIMDE_MATH_HAVE_MATH_H)
369
+ #define simde_math_isnan(v) isnan(v)
370
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
371
+ #define simde_math_isnan(v) std::isnan(v)
372
+ #endif
373
+ #endif
374
+
375
+ #if !defined(simde_math_isnanf)
376
+ #if HEDLEY_HAS_BUILTIN(__builtin_isnanf) || \
377
+ HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
378
+ HEDLEY_ARM_VERSION_CHECK(4, 1, 0)
379
+ /* XL C/C++ has __builtin_isnan but not __builtin_isnanf */
380
+ #define simde_math_isnanf(v) __builtin_isnanf(v)
381
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
382
+ #define simde_math_isnanf(v) std::isnan(v)
383
+ #elif defined(simde_math_isnan)
384
+ #define simde_math_isnanf(v) simde_math_isnan(HEDLEY_STATIC_CAST(double, v))
385
+ #endif
386
+ #endif
387
+
388
+ #if !defined(simde_math_isnormal)
389
+ #if SIMDE_MATH_BUILTIN_LIBM(isnormal)
390
+ #define simde_math_isnormal(v) __builtin_isnormal(v)
391
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
392
+ #define simde_math_isnormal(v) isnormal(v)
393
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
394
+ #define simde_math_isnormal(v) std::isnormal(v)
395
+ #endif
396
+ #endif
397
+
398
+ #if !defined(simde_math_isnormalf)
399
+ #if HEDLEY_HAS_BUILTIN(__builtin_isnormalf)
400
+ #define simde_math_isnormalf(v) __builtin_isnormalf(v)
401
+ #elif SIMDE_MATH_BUILTIN_LIBM(isnormal)
402
+ #define simde_math_isnormalf(v) __builtin_isnormal(v)
403
+ #elif defined(isnormalf)
404
+ #define simde_math_isnormalf(v) isnormalf(v)
405
+ #elif defined(isnormal) || defined(SIMDE_MATH_HAVE_MATH_H)
406
+ #define simde_math_isnormalf(v) isnormal(v)
407
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
408
+ #define simde_math_isnormalf(v) std::isnormal(v)
409
+ #elif defined(simde_math_isnormal)
410
+ #define simde_math_isnormalf(v) simde_math_isnormal(v)
411
+ #endif
412
+ #endif
413
+
414
+ /*** Manipulation functions ***/
415
+
416
+ #if !defined(simde_math_nextafter)
417
+ #if (HEDLEY_HAS_BUILTIN(__builtin_nextafter) && \
418
+ !defined(HEDLEY_IBM_VERSION)) || \
419
+ HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
420
+ HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \
421
+ HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
422
+ #define simde_math_nextafter(x, y) __builtin_nextafter(x, y)
423
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
424
+ #define simde_math_nextafter(x, y) std::nextafter(x, y)
425
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
426
+ #define simde_math_nextafter(x, y) nextafter(x, y)
427
+ #endif
428
+ #endif
429
+
430
+ #if !defined(simde_math_nextafterf)
431
+ #if (HEDLEY_HAS_BUILTIN(__builtin_nextafterf) && \
432
+ !defined(HEDLEY_IBM_VERSION)) || \
433
+ HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
434
+ HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \
435
+ HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
436
+ #define simde_math_nextafterf(x, y) __builtin_nextafterf(x, y)
437
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
438
+ #define simde_math_nextafterf(x, y) std::nextafter(x, y)
439
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
440
+ #define simde_math_nextafterf(x, y) nextafterf(x, y)
441
+ #endif
442
+ #endif
443
+
444
+ /*** Functions from C99 ***/
445
+
446
+ #if !defined(simde_math_abs)
447
+ #if SIMDE_MATH_BUILTIN_LIBM(abs)
448
+ #define simde_math_abs(v) __builtin_abs(v)
449
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
450
+ #define simde_math_abs(v) std::abs(v)
451
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
452
+ #define simde_math_abs(v) abs(v)
453
+ #endif
454
+ #endif
455
+
456
+ #if !defined(simde_math_fabsf)
457
+ #if SIMDE_MATH_BUILTIN_LIBM(fabsf)
458
+ #define simde_math_fabsf(v) __builtin_fabsf(v)
459
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
460
+ #define simde_math_fabsf(v) std::abs(v)
461
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
462
+ #define simde_math_fabsf(v) fabsf(v)
463
+ #endif
464
+ #endif
465
+
466
+ #if !defined(simde_math_acos)
467
+ #if SIMDE_MATH_BUILTIN_LIBM(acos)
468
+ #define simde_math_acos(v) __builtin_acos(v)
469
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
470
+ #define simde_math_acos(v) std::acos(v)
471
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
472
+ #define simde_math_acos(v) acos(v)
473
+ #endif
474
+ #endif
475
+
476
+ #if !defined(simde_math_acosf)
477
+ #if SIMDE_MATH_BUILTIN_LIBM(acosf)
478
+ #define simde_math_acosf(v) __builtin_acosf(v)
479
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
480
+ #define simde_math_acosf(v) std::acos(v)
481
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
482
+ #define simde_math_acosf(v) acosf(v)
483
+ #endif
484
+ #endif
485
+
486
+ #if !defined(simde_math_acosh)
487
+ #if SIMDE_MATH_BUILTIN_LIBM(acosh)
488
+ #define simde_math_acosh(v) __builtin_acosh(v)
489
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
490
+ #define simde_math_acosh(v) std::acosh(v)
491
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
492
+ #define simde_math_acosh(v) acosh(v)
493
+ #endif
494
+ #endif
495
+
496
+ #if !defined(simde_math_acoshf)
497
+ #if SIMDE_MATH_BUILTIN_LIBM(acoshf)
498
+ #define simde_math_acoshf(v) __builtin_acoshf(v)
499
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
500
+ #define simde_math_acoshf(v) std::acosh(v)
501
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
502
+ #define simde_math_acoshf(v) acoshf(v)
503
+ #endif
504
+ #endif
505
+
506
+ #if !defined(simde_math_asin)
507
+ #if SIMDE_MATH_BUILTIN_LIBM(asin)
508
+ #define simde_math_asin(v) __builtin_asin(v)
509
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
510
+ #define simde_math_asin(v) std::asin(v)
511
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
512
+ #define simde_math_asin(v) asin(v)
513
+ #endif
514
+ #endif
515
+
516
+ #if !defined(simde_math_asinf)
517
+ #if SIMDE_MATH_BUILTIN_LIBM(asinf)
518
+ #define simde_math_asinf(v) __builtin_asinf(v)
519
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
520
+ #define simde_math_asinf(v) std::asin(v)
521
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
522
+ #define simde_math_asinf(v) asinf(v)
523
+ #endif
524
+ #endif
525
+
526
+ #if !defined(simde_math_asinh)
527
+ #if SIMDE_MATH_BUILTIN_LIBM(asinh)
528
+ #define simde_math_asinh(v) __builtin_asinh(v)
529
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
530
+ #define simde_math_asinh(v) std::asinh(v)
531
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
532
+ #define simde_math_asinh(v) asinh(v)
533
+ #endif
534
+ #endif
535
+
536
+ #if !defined(simde_math_asinhf)
537
+ #if SIMDE_MATH_BUILTIN_LIBM(asinhf)
538
+ #define simde_math_asinhf(v) __builtin_asinhf(v)
539
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
540
+ #define simde_math_asinhf(v) std::asinh(v)
541
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
542
+ #define simde_math_asinhf(v) asinhf(v)
543
+ #endif
544
+ #endif
545
+
546
+ #if !defined(simde_math_atan)
547
+ #if SIMDE_MATH_BUILTIN_LIBM(atan)
548
+ #define simde_math_atan(v) __builtin_atan(v)
549
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
550
+ #define simde_math_atan(v) std::atan(v)
551
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
552
+ #define simde_math_atan(v) atan(v)
553
+ #endif
554
+ #endif
555
+
556
+ #if !defined(simde_math_atan2)
557
+ #if SIMDE_MATH_BUILTIN_LIBM(atan2)
558
+ #define simde_math_atan2(y, x) __builtin_atan2(y, x)
559
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
560
+ #define simde_math_atan2(y, x) std::atan2(y, x)
561
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
562
+ #define simde_math_atan2(y, x) atan2(y, x)
563
+ #endif
564
+ #endif
565
+
566
+ #if !defined(simde_math_atan2f)
567
+ #if SIMDE_MATH_BUILTIN_LIBM(atan2f)
568
+ #define simde_math_atan2f(y, x) __builtin_atan2f(y, x)
569
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
570
+ #define simde_math_atan2f(y, x) std::atan2(y, x)
571
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
572
+ #define simde_math_atan2f(y, x) atan2f(y, x)
573
+ #endif
574
+ #endif
575
+
576
+ #if !defined(simde_math_atanf)
577
+ #if SIMDE_MATH_BUILTIN_LIBM(atanf)
578
+ #define simde_math_atanf(v) __builtin_atanf(v)
579
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
580
+ #define simde_math_atanf(v) std::atan(v)
581
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
582
+ #define simde_math_atanf(v) atanf(v)
583
+ #endif
584
+ #endif
585
+
586
+ #if !defined(simde_math_atanh)
587
+ #if SIMDE_MATH_BUILTIN_LIBM(atanh)
588
+ #define simde_math_atanh(v) __builtin_atanh(v)
589
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
590
+ #define simde_math_atanh(v) std::atanh(v)
591
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
592
+ #define simde_math_atanh(v) atanh(v)
593
+ #endif
594
+ #endif
595
+
596
+ #if !defined(simde_math_atanhf)
597
+ #if SIMDE_MATH_BUILTIN_LIBM(atanhf)
598
+ #define simde_math_atanhf(v) __builtin_atanhf(v)
599
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
600
+ #define simde_math_atanhf(v) std::atanh(v)
601
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
602
+ #define simde_math_atanhf(v) atanhf(v)
603
+ #endif
604
+ #endif
605
+
606
+ #if !defined(simde_math_cbrt)
607
+ #if SIMDE_MATH_BUILTIN_LIBM(cbrt)
608
+ #define simde_math_cbrt(v) __builtin_cbrt(v)
609
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
610
+ #define simde_math_cbrt(v) std::cbrt(v)
611
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
612
+ #define simde_math_cbrt(v) cbrt(v)
613
+ #endif
614
+ #endif
615
+
616
+ #if !defined(simde_math_cbrtf)
617
+ #if SIMDE_MATH_BUILTIN_LIBM(cbrtf)
618
+ #define simde_math_cbrtf(v) __builtin_cbrtf(v)
619
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
620
+ #define simde_math_cbrtf(v) std::cbrt(v)
621
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
622
+ #define simde_math_cbrtf(v) cbrtf(v)
623
+ #endif
624
+ #endif
625
+
626
+ #if !defined(simde_math_ceil)
627
+ #if SIMDE_MATH_BUILTIN_LIBM(ceil)
628
+ #define simde_math_ceil(v) __builtin_ceil(v)
629
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
630
+ #define simde_math_ceil(v) std::ceil(v)
631
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
632
+ #define simde_math_ceil(v) ceil(v)
633
+ #endif
634
+ #endif
635
+
636
+ #if !defined(simde_math_ceilf)
637
+ #if SIMDE_MATH_BUILTIN_LIBM(ceilf)
638
+ #define simde_math_ceilf(v) __builtin_ceilf(v)
639
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
640
+ #define simde_math_ceilf(v) std::ceil(v)
641
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
642
+ #define simde_math_ceilf(v) ceilf(v)
643
+ #endif
644
+ #endif
645
+
646
+ #if !defined(simde_math_copysign)
647
+ #if SIMDE_MATH_BUILTIN_LIBM(copysign)
648
+ #define simde_math_copysign(x, y) __builtin_copysign(x, y)
649
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
650
+ #define simde_math_copysign(x, y) std::copysign(x, y)
651
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
652
+ #define simde_math_copysign(x, y) copysign(x, y)
653
+ #endif
654
+ #endif
655
+
656
+ #if !defined(simde_math_copysignf)
657
+ #if SIMDE_MATH_BUILTIN_LIBM(copysignf)
658
+ #define simde_math_copysignf(x, y) __builtin_copysignf(x, y)
659
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
660
+ #define simde_math_copysignf(x, y) std::copysignf(x, y)
661
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
662
+ #define simde_math_copysignf(x, y) copysignf(x, y)
663
+ #endif
664
+ #endif
665
+
666
+ #if !defined(simde_math_cos)
667
+ #if SIMDE_MATH_BUILTIN_LIBM(cos)
668
+ #define simde_math_cos(v) __builtin_cos(v)
669
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
670
+ #define simde_math_cos(v) std::cos(v)
671
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
672
+ #define simde_math_cos(v) cos(v)
673
+ #endif
674
+ #endif
675
+
676
+ #if !defined(simde_math_cosf)
677
+ #if defined(SIMDE_MATH_SLEEF_ENABLE)
678
+ #if SIMDE_ACCURACY_PREFERENCE < 1
679
+ #define simde_math_cosf(v) Sleef_cosf_u35(v)
680
+ #else
681
+ #define simde_math_cosf(v) Sleef_cosf_u10(v)
682
+ #endif
683
+ #elif SIMDE_MATH_BUILTIN_LIBM(cosf)
684
+ #define simde_math_cosf(v) __builtin_cosf(v)
685
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
686
+ #define simde_math_cosf(v) std::cos(v)
687
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
688
+ #define simde_math_cosf(v) cosf(v)
689
+ #endif
690
+ #endif
691
+
692
+ #if !defined(simde_math_cosh)
693
+ #if SIMDE_MATH_BUILTIN_LIBM(cosh)
694
+ #define simde_math_cosh(v) __builtin_cosh(v)
695
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
696
+ #define simde_math_cosh(v) std::cosh(v)
697
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
698
+ #define simde_math_cosh(v) cosh(v)
699
+ #endif
700
+ #endif
701
+
702
+ #if !defined(simde_math_coshf)
703
+ #if SIMDE_MATH_BUILTIN_LIBM(coshf)
704
+ #define simde_math_coshf(v) __builtin_coshf(v)
705
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
706
+ #define simde_math_coshf(v) std::cosh(v)
707
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
708
+ #define simde_math_coshf(v) coshf(v)
709
+ #endif
710
+ #endif
711
+
712
+ #if !defined(simde_math_erf)
713
+ #if SIMDE_MATH_BUILTIN_LIBM(erf)
714
+ #define simde_math_erf(v) __builtin_erf(v)
715
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
716
+ #define simde_math_erf(v) std::erf(v)
717
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
718
+ #define simde_math_erf(v) erf(v)
719
+ #endif
720
+ #endif
721
+
722
+ #if !defined(simde_math_erff)
723
+ #if SIMDE_MATH_BUILTIN_LIBM(erff)
724
+ #define simde_math_erff(v) __builtin_erff(v)
725
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
726
+ #define simde_math_erff(v) std::erf(v)
727
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
728
+ #define simde_math_erff(v) erff(v)
729
+ #endif
730
+ #endif
731
+
732
+ #if !defined(simde_math_erfc)
733
+ #if SIMDE_MATH_BUILTIN_LIBM(erfc)
734
+ #define simde_math_erfc(v) __builtin_erfc(v)
735
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
736
+ #define simde_math_erfc(v) std::erfc(v)
737
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
738
+ #define simde_math_erfc(v) erfc(v)
739
+ #endif
740
+ #endif
741
+
742
+ #if !defined(simde_math_erfcf)
743
+ #if SIMDE_MATH_BUILTIN_LIBM(erfcf)
744
+ #define simde_math_erfcf(v) __builtin_erfcf(v)
745
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
746
+ #define simde_math_erfcf(v) std::erfc(v)
747
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
748
+ #define simde_math_erfcf(v) erfcf(v)
749
+ #endif
750
+ #endif
751
+
752
+ #if !defined(simde_math_exp)
753
+ #if SIMDE_MATH_BUILTIN_LIBM(exp)
754
+ #define simde_math_exp(v) __builtin_exp(v)
755
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
756
+ #define simde_math_exp(v) std::exp(v)
757
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
758
+ #define simde_math_exp(v) exp(v)
759
+ #endif
760
+ #endif
761
+
762
+ #if !defined(simde_math_expf)
763
+ #if SIMDE_MATH_BUILTIN_LIBM(expf)
764
+ #define simde_math_expf(v) __builtin_expf(v)
765
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
766
+ #define simde_math_expf(v) std::exp(v)
767
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
768
+ #define simde_math_expf(v) expf(v)
769
+ #endif
770
+ #endif
771
+
772
+ #if !defined(simde_math_expm1)
773
+ #if SIMDE_MATH_BUILTIN_LIBM(expm1)
774
+ #define simde_math_expm1(v) __builtin_expm1(v)
775
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
776
+ #define simde_math_expm1(v) std::expm1(v)
777
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
778
+ #define simde_math_expm1(v) expm1(v)
779
+ #endif
780
+ #endif
781
+
782
+ #if !defined(simde_math_expm1f)
783
+ #if SIMDE_MATH_BUILTIN_LIBM(expm1f)
784
+ #define simde_math_expm1f(v) __builtin_expm1f(v)
785
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
786
+ #define simde_math_expm1f(v) std::expm1(v)
787
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
788
+ #define simde_math_expm1f(v) expm1f(v)
789
+ #endif
790
+ #endif
791
+
792
+ #if !defined(simde_math_exp2)
793
+ #if SIMDE_MATH_BUILTIN_LIBM(exp2)
794
+ #define simde_math_exp2(v) __builtin_exp2(v)
795
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
796
+ #define simde_math_exp2(v) std::exp2(v)
797
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
798
+ #define simde_math_exp2(v) exp2(v)
799
+ #endif
800
+ #endif
801
+
802
+ #if !defined(simde_math_exp2f)
803
+ #if SIMDE_MATH_BUILTIN_LIBM(exp2f)
804
+ #define simde_math_exp2f(v) __builtin_exp2f(v)
805
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
806
+ #define simde_math_exp2f(v) std::exp2(v)
807
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
808
+ #define simde_math_exp2f(v) exp2f(v)
809
+ #endif
810
+ #endif
811
+
812
+ #if HEDLEY_HAS_BUILTIN(__builtin_exp10) || HEDLEY_GCC_VERSION_CHECK(3, 4, 0)
813
+ #define simde_math_exp10(v) __builtin_exp10(v)
814
+ #else
815
+ #define simde_math_exp10(v) pow(10.0, (v))
816
+ #endif
817
+
818
+ #if HEDLEY_HAS_BUILTIN(__builtin_exp10f) || HEDLEY_GCC_VERSION_CHECK(3, 4, 0)
819
+ #define simde_math_exp10f(v) __builtin_exp10f(v)
820
+ #else
821
+ #define simde_math_exp10f(v) powf(10.0f, (v))
822
+ #endif
823
+
824
+ #if !defined(simde_math_fabs)
825
+ #if SIMDE_MATH_BUILTIN_LIBM(fabs)
826
+ #define simde_math_fabs(v) __builtin_fabs(v)
827
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
828
+ #define simde_math_fabs(v) std::fabs(v)
829
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
830
+ #define simde_math_fabs(v) fabs(v)
831
+ #endif
832
+ #endif
833
+
834
+ #if !defined(simde_math_fabsf)
835
+ #if SIMDE_MATH_BUILTIN_LIBM(fabsf)
836
+ #define simde_math_fabsf(v) __builtin_fabsf(v)
837
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
838
+ #define simde_math_fabsf(v) std::fabs(v)
839
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
840
+ #define simde_math_fabsf(v) fabsf(v)
841
+ #endif
842
+ #endif
843
+
844
+ #if !defined(simde_math_floor)
845
+ #if SIMDE_MATH_BUILTIN_LIBM(floor)
846
+ #define simde_math_floor(v) __builtin_floor(v)
847
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
848
+ #define simde_math_floor(v) std::floor(v)
849
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
850
+ #define simde_math_floor(v) floor(v)
851
+ #endif
852
+ #endif
853
+
854
+ #if !defined(simde_math_floorf)
855
+ #if SIMDE_MATH_BUILTIN_LIBM(floorf)
856
+ #define simde_math_floorf(v) __builtin_floorf(v)
857
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
858
+ #define simde_math_floorf(v) std::floor(v)
859
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
860
+ #define simde_math_floorf(v) floorf(v)
861
+ #endif
862
+ #endif
863
+
864
+ #if !defined(simde_math_fma)
865
+ #if SIMDE_MATH_BUILTIN_LIBM(fma)
866
+ #define simde_math_fma(x, y, z) __builtin_fma(x, y, z)
867
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
868
+ #define simde_math_fma(x, y, z) std::fma(x, y, z)
869
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
870
+ #define simde_math_fma(x, y, z) fma(x, y, z)
871
+ #endif
872
+ #endif
873
+
874
+ #if !defined(simde_math_fmaf)
875
+ #if SIMDE_MATH_BUILTIN_LIBM(fmaf)
876
+ #define simde_math_fmaf(x, y, z) __builtin_fmaf(x, y, z)
877
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
878
+ #define simde_math_fmaf(x, y, z) std::fma(x, y, z)
879
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
880
+ #define simde_math_fmaf(x, y, z) fmaf(x, y, z)
881
+ #endif
882
+ #endif
883
+
884
+ #if !defined(simde_math_fmax)
885
+ #if SIMDE_MATH_BUILTIN_LIBM(fmax)
886
+ #define simde_math_fmax(x, y, z) __builtin_fmax(x, y, z)
887
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
888
+ #define simde_math_fmax(x, y, z) std::fmax(x, y, z)
889
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
890
+ #define simde_math_fmax(x, y, z) fmax(x, y, z)
891
+ #endif
892
+ #endif
893
+
894
+ #if !defined(simde_math_fmaxf)
895
+ #if SIMDE_MATH_BUILTIN_LIBM(fmaxf)
896
+ #define simde_math_fmaxf(x, y, z) __builtin_fmaxf(x, y, z)
897
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
898
+ #define simde_math_fmaxf(x, y, z) std::fmax(x, y, z)
899
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
900
+ #define simde_math_fmaxf(x, y, z) fmaxf(x, y, z)
901
+ #endif
902
+ #endif
903
+
904
+ #if !defined(simde_math_hypot)
905
+ #if SIMDE_MATH_BUILTIN_LIBM(hypot)
906
+ #define simde_math_hypot(y, x) __builtin_hypot(y, x)
907
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
908
+ #define simde_math_hypot(y, x) std::hypot(y, x)
909
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
910
+ #define simde_math_hypot(y, x) hypot(y, x)
911
+ #endif
912
+ #endif
913
+
914
+ #if !defined(simde_math_hypotf)
915
+ #if SIMDE_MATH_BUILTIN_LIBM(hypotf)
916
+ #define simde_math_hypotf(y, x) __builtin_hypotf(y, x)
917
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
918
+ #define simde_math_hypotf(y, x) std::hypot(y, x)
919
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
920
+ #define simde_math_hypotf(y, x) hypotf(y, x)
921
+ #endif
922
+ #endif
923
+
924
+ #if !defined(simde_math_log)
925
+ #if SIMDE_MATH_BUILTIN_LIBM(log)
926
+ #define simde_math_log(v) __builtin_log(v)
927
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
928
+ #define simde_math_log(v) std::log(v)
929
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
930
+ #define simde_math_log(v) log(v)
931
+ #endif
932
+ #endif
933
+
934
+ #if !defined(simde_math_logf)
935
+ #if SIMDE_MATH_BUILTIN_LIBM(logf)
936
+ #define simde_math_logf(v) __builtin_logf(v)
937
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
938
+ #define simde_math_logf(v) std::log(v)
939
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
940
+ #define simde_math_logf(v) logf(v)
941
+ #endif
942
+ #endif
943
+
944
+ #if !defined(simde_math_logb)
945
+ #if SIMDE_MATH_BUILTIN_LIBM(logb)
946
+ #define simde_math_logb(v) __builtin_logb(v)
947
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
948
+ #define simde_math_logb(v) std::logb(v)
949
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
950
+ #define simde_math_logb(v) logb(v)
951
+ #endif
952
+ #endif
953
+
954
+ #if !defined(simde_math_logbf)
955
+ #if SIMDE_MATH_BUILTIN_LIBM(logbf)
956
+ #define simde_math_logbf(v) __builtin_logbf(v)
957
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
958
+ #define simde_math_logbf(v) std::logb(v)
959
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
960
+ #define simde_math_logbf(v) logbf(v)
961
+ #endif
962
+ #endif
963
+
964
+ #if !defined(simde_math_log1p)
965
+ #if SIMDE_MATH_BUILTIN_LIBM(log1p)
966
+ #define simde_math_log1p(v) __builtin_log1p(v)
967
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
968
+ #define simde_math_log1p(v) std::log1p(v)
969
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
970
+ #define simde_math_log1p(v) log1p(v)
971
+ #endif
972
+ #endif
973
+
974
+ #if !defined(simde_math_log1pf)
975
+ #if SIMDE_MATH_BUILTIN_LIBM(log1pf)
976
+ #define simde_math_log1pf(v) __builtin_log1pf(v)
977
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
978
+ #define simde_math_log1pf(v) std::log1p(v)
979
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
980
+ #define simde_math_log1pf(v) log1pf(v)
981
+ #endif
982
+ #endif
983
+
984
+ #if !defined(simde_math_log2)
985
+ #if SIMDE_MATH_BUILTIN_LIBM(log2)
986
+ #define simde_math_log2(v) __builtin_log2(v)
987
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
988
+ #define simde_math_log2(v) std::log2(v)
989
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
990
+ #define simde_math_log2(v) log2(v)
991
+ #endif
992
+ #endif
993
+
994
+ #if !defined(simde_math_log2f)
995
+ #if SIMDE_MATH_BUILTIN_LIBM(log2f)
996
+ #define simde_math_log2f(v) __builtin_log2f(v)
997
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
998
+ #define simde_math_log2f(v) std::log2(v)
999
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1000
+ #define simde_math_log2f(v) log2f(v)
1001
+ #endif
1002
+ #endif
1003
+
1004
+ #if !defined(simde_math_log10)
1005
+ #if SIMDE_MATH_BUILTIN_LIBM(log10)
1006
+ #define simde_math_log10(v) __builtin_log10(v)
1007
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1008
+ #define simde_math_log10(v) std::log10(v)
1009
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1010
+ #define simde_math_log10(v) log10(v)
1011
+ #endif
1012
+ #endif
1013
+
1014
+ #if !defined(simde_math_log10f)
1015
+ #if SIMDE_MATH_BUILTIN_LIBM(log10f)
1016
+ #define simde_math_log10f(v) __builtin_log10f(v)
1017
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1018
+ #define simde_math_log10f(v) std::log10(v)
1019
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1020
+ #define simde_math_log10f(v) log10f(v)
1021
+ #endif
1022
+ #endif
1023
+
1024
+ #if !defined(simde_math_modf)
1025
+ #if SIMDE_MATH_BUILTIN_LIBM(modf)
1026
+ #define simde_math_modf(x, iptr) __builtin_modf(x, iptr)
1027
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1028
+ #define simde_math_modf(x, iptr) std::modf(x, iptr)
1029
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1030
+ #define simde_math_modf(x, iptr) modf(x, iptr)
1031
+ #endif
1032
+ #endif
1033
+
1034
+ #if !defined(simde_math_modff)
1035
+ #if SIMDE_MATH_BUILTIN_LIBM(modff)
1036
+ #define simde_math_modff(x, iptr) __builtin_modff(x, iptr)
1037
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1038
+ #define simde_math_modff(x, iptr) std::modf(x, iptr)
1039
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1040
+ #define simde_math_modff(x, iptr) modff(x, iptr)
1041
+ #endif
1042
+ #endif
1043
+
1044
+ #if !defined(simde_math_nearbyint)
1045
+ #if SIMDE_MATH_BUILTIN_LIBM(nearbyint)
1046
+ #define simde_math_nearbyint(v) __builtin_nearbyint(v)
1047
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1048
+ #define simde_math_nearbyint(v) std::nearbyint(v)
1049
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1050
+ #define simde_math_nearbyint(v) nearbyint(v)
1051
+ #endif
1052
+ #endif
1053
+
1054
+ #if !defined(simde_math_nearbyintf)
1055
+ #if SIMDE_MATH_BUILTIN_LIBM(nearbyintf)
1056
+ #define simde_math_nearbyintf(v) __builtin_nearbyintf(v)
1057
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1058
+ #define simde_math_nearbyintf(v) std::nearbyint(v)
1059
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1060
+ #define simde_math_nearbyintf(v) nearbyintf(v)
1061
+ #endif
1062
+ #endif
1063
+
1064
+ #if !defined(simde_math_pow)
1065
+ #if SIMDE_MATH_BUILTIN_LIBM(pow)
1066
+ #define simde_math_pow(y, x) __builtin_pow(y, x)
1067
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1068
+ #define simde_math_pow(y, x) std::pow(y, x)
1069
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1070
+ #define simde_math_pow(y, x) pow(y, x)
1071
+ #endif
1072
+ #endif
1073
+
1074
+ #if !defined(simde_math_powf)
1075
+ #if SIMDE_MATH_BUILTIN_LIBM(powf)
1076
+ #define simde_math_powf(y, x) __builtin_powf(y, x)
1077
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1078
+ #define simde_math_powf(y, x) std::pow(y, x)
1079
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1080
+ #define simde_math_powf(y, x) powf(y, x)
1081
+ #endif
1082
+ #endif
1083
+
1084
+ #if !defined(simde_math_rint)
1085
+ #if SIMDE_MATH_BUILTIN_LIBM(rint)
1086
+ #define simde_math_rint(v) __builtin_rint(v)
1087
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1088
+ #define simde_math_rint(v) std::rint(v)
1089
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1090
+ #define simde_math_rint(v) rint(v)
1091
+ #endif
1092
+ #endif
1093
+
1094
+ #if !defined(simde_math_rintf)
1095
+ #if SIMDE_MATH_BUILTIN_LIBM(rintf)
1096
+ #define simde_math_rintf(v) __builtin_rintf(v)
1097
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1098
+ #define simde_math_rintf(v) std::rint(v)
1099
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1100
+ #define simde_math_rintf(v) rintf(v)
1101
+ #endif
1102
+ #endif
1103
+
1104
+ #if !defined(simde_math_round)
1105
+ #if SIMDE_MATH_BUILTIN_LIBM(round)
1106
+ #define simde_math_round(v) __builtin_round(v)
1107
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1108
+ #define simde_math_round(v) std::round(v)
1109
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1110
+ #define simde_math_round(v) round(v)
1111
+ #endif
1112
+ #endif
1113
+
1114
+ #if !defined(simde_math_roundf)
1115
+ #if SIMDE_MATH_BUILTIN_LIBM(roundf)
1116
+ #define simde_math_roundf(v) __builtin_roundf(v)
1117
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1118
+ #define simde_math_roundf(v) std::round(v)
1119
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1120
+ #define simde_math_roundf(v) roundf(v)
1121
+ #endif
1122
+ #endif
1123
+
1124
+ #if !defined(simde_math_roundeven)
1125
+ #if HEDLEY_HAS_BUILTIN(__builtin_roundeven) || \
1126
+ HEDLEY_GCC_VERSION_CHECK(10, 0, 0)
1127
+ #define simde_math_roundeven(v) __builtin_roundeven(v)
1128
+ #elif defined(simde_math_round) && defined(simde_math_fabs)
1129
+ static HEDLEY_INLINE double simde_math_roundeven(double v)
1130
+ {
1131
+ double rounded = simde_math_round(v);
1132
+ double diff = rounded - v;
1133
+ if (HEDLEY_UNLIKELY(simde_math_fabs(diff) == 0.5) &&
1134
+ (HEDLEY_STATIC_CAST(int64_t, rounded) & 1)) {
1135
+ rounded = v - diff;
1136
+ }
1137
+ return rounded;
1138
+ }
1139
+ #define simde_math_roundeven simde_math_roundeven
1140
+ #endif
1141
+ #endif
1142
+
1143
+ #if !defined(simde_math_roundevenf)
1144
+ #if HEDLEY_HAS_BUILTIN(__builtin_roundevenf) || \
1145
+ HEDLEY_GCC_VERSION_CHECK(10, 0, 0)
1146
+ #define simde_math_roundevenf(v) __builtin_roundevenf(v)
1147
+ #elif defined(simde_math_roundf) && defined(simde_math_fabsf)
1148
+ static HEDLEY_INLINE float simde_math_roundevenf(float v)
1149
+ {
1150
+ float rounded = simde_math_roundf(v);
1151
+ float diff = rounded - v;
1152
+ if (HEDLEY_UNLIKELY(simde_math_fabsf(diff) == 0.5f) &&
1153
+ (HEDLEY_STATIC_CAST(int32_t, rounded) & 1)) {
1154
+ rounded = v - diff;
1155
+ }
1156
+ return rounded;
1157
+ }
1158
+ #define simde_math_roundevenf simde_math_roundevenf
1159
+ #endif
1160
+ #endif
1161
+
1162
+ #if !defined(simde_math_sin)
1163
+ #if SIMDE_MATH_BUILTIN_LIBM(sin)
1164
+ #define simde_math_sin(v) __builtin_sin(v)
1165
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1166
+ #define simde_math_sin(v) std::sin(v)
1167
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1168
+ #define simde_math_sin(v) sin(v)
1169
+ #endif
1170
+ #endif
1171
+
1172
+ #if !defined(simde_math_sinf)
1173
+ #if SIMDE_MATH_BUILTIN_LIBM(sinf)
1174
+ #define simde_math_sinf(v) __builtin_sinf(v)
1175
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1176
+ #define simde_math_sinf(v) std::sin(v)
1177
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1178
+ #define simde_math_sinf(v) sinf(v)
1179
+ #endif
1180
+ #endif
1181
+
1182
+ #if !defined(simde_math_sinh)
1183
+ #if SIMDE_MATH_BUILTIN_LIBM(sinh)
1184
+ #define simde_math_sinh(v) __builtin_sinh(v)
1185
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1186
+ #define simde_math_sinh(v) std::sinh(v)
1187
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1188
+ #define simde_math_sinh(v) sinh(v)
1189
+ #endif
1190
+ #endif
1191
+
1192
+ #if !defined(simde_math_sinhf)
1193
+ #if SIMDE_MATH_BUILTIN_LIBM(sinhf)
1194
+ #define simde_math_sinhf(v) __builtin_sinhf(v)
1195
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1196
+ #define simde_math_sinhf(v) std::sinh(v)
1197
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1198
+ #define simde_math_sinhf(v) sinhf(v)
1199
+ #endif
1200
+ #endif
1201
+
1202
+ #if !defined(simde_math_sqrt)
1203
+ #if SIMDE_MATH_BUILTIN_LIBM(sqrt)
1204
+ #define simde_math_sqrt(v) __builtin_sqrt(v)
1205
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1206
+ #define simde_math_sqrt(v) std::sqrt(v)
1207
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1208
+ #define simde_math_sqrt(v) sqrt(v)
1209
+ #endif
1210
+ #endif
1211
+
1212
+ #if !defined(simde_math_sqrtf)
1213
+ #if SIMDE_MATH_BUILTIN_LIBM(sqrtf)
1214
+ #define simde_math_sqrtf(v) __builtin_sqrtf(v)
1215
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1216
+ #define simde_math_sqrtf(v) std::sqrt(v)
1217
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1218
+ #define simde_math_sqrtf(v) sqrtf(v)
1219
+ #endif
1220
+ #endif
1221
+
1222
+ #if !defined(simde_math_tan)
1223
+ #if SIMDE_MATH_BUILTIN_LIBM(tan)
1224
+ #define simde_math_tan(v) __builtin_tan(v)
1225
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1226
+ #define simde_math_tan(v) std::tan(v)
1227
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1228
+ #define simde_math_tan(v) tan(v)
1229
+ #endif
1230
+ #endif
1231
+
1232
+ #if !defined(simde_math_tanf)
1233
+ #if SIMDE_MATH_BUILTIN_LIBM(tanf)
1234
+ #define simde_math_tanf(v) __builtin_tanf(v)
1235
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1236
+ #define simde_math_tanf(v) std::tan(v)
1237
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1238
+ #define simde_math_tanf(v) tanf(v)
1239
+ #endif
1240
+ #endif
1241
+
1242
+ #if !defined(simde_math_tanh)
1243
+ #if SIMDE_MATH_BUILTIN_LIBM(tanh)
1244
+ #define simde_math_tanh(v) __builtin_tanh(v)
1245
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1246
+ #define simde_math_tanh(v) std::tanh(v)
1247
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1248
+ #define simde_math_tanh(v) tanh(v)
1249
+ #endif
1250
+ #endif
1251
+
1252
+ #if !defined(simde_math_tanhf)
1253
+ #if SIMDE_MATH_BUILTIN_LIBM(tanhf)
1254
+ #define simde_math_tanhf(v) __builtin_tanhf(v)
1255
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1256
+ #define simde_math_tanhf(v) std::tanh(v)
1257
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1258
+ #define simde_math_tanhf(v) tanhf(v)
1259
+ #endif
1260
+ #endif
1261
+
1262
+ #if !defined(simde_math_trunc)
1263
+ #if SIMDE_MATH_BUILTIN_LIBM(trunc)
1264
+ #define simde_math_trunc(v) __builtin_trunc(v)
1265
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1266
+ #define simde_math_trunc(v) std::trunc(v)
1267
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1268
+ #define simde_math_trunc(v) trunc(v)
1269
+ #endif
1270
+ #endif
1271
+
1272
+ #if !defined(simde_math_truncf)
1273
+ #if SIMDE_MATH_BUILTIN_LIBM(truncf)
1274
+ #define simde_math_truncf(v) __builtin_truncf(v)
1275
+ #elif defined(SIMDE_MATH_HAVE_CMATH)
1276
+ #define simde_math_truncf(v) std::trunc(v)
1277
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1278
+ #define simde_math_truncf(v) truncf(v)
1279
+ #endif
1280
+ #endif
1281
+
1282
+ /*** Complex functions ***/
1283
+
1284
+ #if !defined(simde_math_cexp)
1285
+ #if SIMDE_MATH_BUILTIN_LIBM(cexp)
1286
+ #define simde_math_cexp(v) __builtin_cexp(v)
1287
+ #elif defined(__cplusplus)
1288
+ #define simde_math_cexp(v) std::cexp(v)
1289
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1290
+ #define simde_math_cexp(v) cexp(v)
1291
+ #endif
1292
+ #endif
1293
+
1294
+ #if !defined(simde_math_cexpf)
1295
+ #if SIMDE_MATH_BUILTIN_LIBM(cexpf)
1296
+ #define simde_math_cexpf(v) __builtin_cexpf(v)
1297
+ #elif defined(__cplusplus)
1298
+ #define simde_math_cexpf(v) std::exp(v)
1299
+ #elif defined(SIMDE_MATH_HAVE_MATH_H)
1300
+ #define simde_math_cexpf(v) cexpf(v)
1301
+ #endif
1302
+ #endif
1303
+
1304
+ /*** Additional functions not in libm ***/
1305
+
1306
+ #if defined(simde_math_fabs) && defined(simde_math_sqrt) && \
1307
+ defined(simde_math_exp)
1308
+ static HEDLEY_INLINE double simde_math_cdfnorm(double x)
1309
+ {
1310
+ /* https://www.johndcook.com/blog/cpp_phi/
1311
+ * Public Domain */
1312
+ static const double a1 = 0.254829592;
1313
+ static const double a2 = -0.284496736;
1314
+ static const double a3 = 1.421413741;
1315
+ static const double a4 = -1.453152027;
1316
+ static const double a5 = 1.061405429;
1317
+ static const double p = 0.3275911;
1318
+
1319
+ const int sign = x < 0;
1320
+ x = simde_math_fabs(x) / simde_math_sqrt(2.0);
1321
+
1322
+ /* A&S formula 7.1.26 */
1323
+ double t = 1.0 / (1.0 + p * x);
1324
+ double y = 1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t *
1325
+ simde_math_exp(-x * x);
1326
+
1327
+ return 0.5 * (1.0 + (sign ? -y : y));
1328
+ }
1329
+ #define simde_math_cdfnorm simde_math_cdfnorm
1330
+ #endif
1331
+
1332
+ #if defined(simde_math_fabsf) && defined(simde_math_sqrtf) && \
1333
+ defined(simde_math_expf)
1334
+ static HEDLEY_INLINE float simde_math_cdfnormf(float x)
1335
+ {
1336
+ /* https://www.johndcook.com/blog/cpp_phi/
1337
+ * Public Domain */
1338
+ static const float a1 = 0.254829592f;
1339
+ static const float a2 = -0.284496736f;
1340
+ static const float a3 = 1.421413741f;
1341
+ static const float a4 = -1.453152027f;
1342
+ static const float a5 = 1.061405429f;
1343
+ static const float p = 0.3275911f;
1344
+
1345
+ const int sign = x < 0;
1346
+ x = simde_math_fabsf(x) / simde_math_sqrtf(2.0f);
1347
+
1348
+ /* A&S formula 7.1.26 */
1349
+ float t = 1.0f / (1.0f + p * x);
1350
+ float y = 1.0f - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t *
1351
+ simde_math_expf(-x * x);
1352
+
1353
+ return 0.5f * (1.0f + (sign ? -y : y));
1354
+ }
1355
+ #define simde_math_cdfnormf simde_math_cdfnormf
1356
+ #endif
1357
+
1358
+ HEDLEY_DIAGNOSTIC_PUSH
1359
+ SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL_
1360
+
1361
+ #if !defined(simde_math_cdfnorminv) && defined(simde_math_log) && \
1362
+ defined(simde_math_sqrt)
1363
+ /*https://web.archive.org/web/20150910081113/http://home.online.no/~pjacklam/notes/invnorm/impl/sprouse/ltqnorm.c*/
1364
+ static HEDLEY_INLINE double simde_math_cdfnorminv(double p)
1365
+ {
1366
+ static const double a[] = {
1367
+ -3.969683028665376e+01, 2.209460984245205e+02,
1368
+ -2.759285104469687e+02, 1.383577518672690e+02,
1369
+ -3.066479806614716e+01, 2.506628277459239e+00};
1370
+
1371
+ static const double b[] = {-5.447609879822406e+01,
1372
+ 1.615858368580409e+02,
1373
+ -1.556989798598866e+02,
1374
+ 6.680131188771972e+01,
1375
+ -1.328068155288572e+01};
1376
+
1377
+ static const double c[] = {
1378
+ -7.784894002430293e-03, -3.223964580411365e-01,
1379
+ -2.400758277161838e+00, -2.549732539343734e+00,
1380
+ 4.374664141464968e+00, 2.938163982698783e+00};
1381
+
1382
+ static const double d[] = {7.784695709041462e-03, 3.224671290700398e-01,
1383
+ 2.445134137142996e+00,
1384
+ 3.754408661907416e+00};
1385
+
1386
+ static const double low = 0.02425;
1387
+ static const double high = 0.97575;
1388
+ double q, r;
1389
+
1390
+ if (p < 0 || p > 1) {
1391
+ return 0.0;
1392
+ } else if (p == 0) {
1393
+ return -SIMDE_MATH_INFINITY;
1394
+ } else if (p == 1) {
1395
+ return SIMDE_MATH_INFINITY;
1396
+ } else if (p < low) {
1397
+ q = simde_math_sqrt(-2.0 * simde_math_log(p));
1398
+ return (((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q +
1399
+ c[4]) * q +
1400
+ c[5]) /
1401
+ (((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1));
1402
+ } else if (p > high) {
1403
+ q = simde_math_sqrt(-2.0 * simde_math_log(1.0 - p));
1404
+ return -(((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q +
1405
+ c[4]) * q +
1406
+ c[5]) /
1407
+ (((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1));
1408
+ } else {
1409
+ q = p - 0.5;
1410
+ r = q * q;
1411
+ return (((((a[0] * r + a[1]) * r + a[2]) * r + a[3]) * r +
1412
+ a[4]) * r +
1413
+ a[5]) *
1414
+ q /
1415
+ (((((b[0] * r + b[1]) * r + b[2]) * r + b[3]) * r +
1416
+ b[4]) * r +
1417
+ 1);
1418
+ }
1419
+ }
1420
+ #define simde_math_cdfnorminv simde_math_cdfnorminv
1421
+ #endif
1422
+
1423
+ #if !defined(simde_math_cdfnorminvf) && defined(simde_math_logf) && \
1424
+ defined(simde_math_sqrtf)
1425
+ static HEDLEY_INLINE float simde_math_cdfnorminvf(float p)
1426
+ {
1427
+ static const float a[] = {
1428
+ -3.969683028665376e+01f, 2.209460984245205e+02f,
1429
+ -2.759285104469687e+02f, 1.383577518672690e+02f,
1430
+ -3.066479806614716e+01f, 2.506628277459239e+00f};
1431
+ static const float b[] = {-5.447609879822406e+01f,
1432
+ 1.615858368580409e+02f,
1433
+ -1.556989798598866e+02f,
1434
+ 6.680131188771972e+01f,
1435
+ -1.328068155288572e+01f};
1436
+ static const float c[] = {
1437
+ -7.784894002430293e-03f, -3.223964580411365e-01f,
1438
+ -2.400758277161838e+00f, -2.549732539343734e+00f,
1439
+ 4.374664141464968e+00f, 2.938163982698783e+00f};
1440
+ static const float d[] = {7.784695709041462e-03f,
1441
+ 3.224671290700398e-01f,
1442
+ 2.445134137142996e+00f,
1443
+ 3.754408661907416e+00f};
1444
+ static const float low = 0.02425f;
1445
+ static const float high = 0.97575f;
1446
+ float q, r;
1447
+
1448
+ if (p < 0 || p > 1) {
1449
+ return 0.0f;
1450
+ } else if (p == 0) {
1451
+ return -SIMDE_MATH_INFINITYF;
1452
+ } else if (p == 1) {
1453
+ return SIMDE_MATH_INFINITYF;
1454
+ } else if (p < low) {
1455
+ q = simde_math_sqrtf(-2.0f * simde_math_logf(p));
1456
+ return (((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q +
1457
+ c[4]) * q +
1458
+ c[5]) /
1459
+ (((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1));
1460
+ } else if (p > high) {
1461
+ q = simde_math_sqrtf(-2.0f * simde_math_logf(1.0f - p));
1462
+ return -(((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q +
1463
+ c[4]) * q +
1464
+ c[5]) /
1465
+ (((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1));
1466
+ } else {
1467
+ q = p - 0.5f;
1468
+ r = q * q;
1469
+ return (((((a[0] * r + a[1]) * r + a[2]) * r + a[3]) * r +
1470
+ a[4]) * r +
1471
+ a[5]) *
1472
+ q /
1473
+ (((((b[0] * r + b[1]) * r + b[2]) * r + b[3]) * r +
1474
+ b[4]) * r +
1475
+ 1);
1476
+ }
1477
+ }
1478
+ #define simde_math_cdfnorminvf simde_math_cdfnorminvf
1479
+ #endif
1480
+
1481
+ #if !defined(simde_math_erfinv) && defined(simde_math_log) && \
1482
+ defined(simde_math_copysign) && defined(simde_math_sqrt)
1483
+ static HEDLEY_INLINE double simde_math_erfinv(double x)
1484
+ {
1485
+ /* https://stackoverflow.com/questions/27229371/inverse-error-function-in-c
1486
+ *
1487
+ * The original answer on SO uses a constant of 0.147, but in my
1488
+ * testing 0.14829094707965850830078125 gives a lower average absolute error
1489
+ * (0.0001410958211636170744895935 vs. 0.0001465479290345683693885803).
1490
+ * That said, if your goal is to minimize the *maximum* absolute
1491
+ * error, 0.15449436008930206298828125 provides significantly better
1492
+ * results; 0.0009250640869140625000000000 vs ~ 0.005. */
1493
+ double tt1, tt2, lnx;
1494
+ double sgn = simde_math_copysign(1.0, x);
1495
+
1496
+ x = (1.0 - x) * (1.0 + x);
1497
+ lnx = simde_math_log(x);
1498
+
1499
+ tt1 = 2.0 / (SIMDE_MATH_PI * 0.14829094707965850830078125) + 0.5 * lnx;
1500
+ tt2 = (1.0 / 0.14829094707965850830078125) * lnx;
1501
+
1502
+ return sgn * simde_math_sqrt(-tt1 + simde_math_sqrt(tt1 * tt1 - tt2));
1503
+ }
1504
+ #define simde_math_erfinv simde_math_erfinv
1505
+ #endif
1506
+
1507
+ #if !defined(simde_math_erfinvf) && defined(simde_math_logf) && \
1508
+ defined(simde_math_copysignf) && defined(simde_math_sqrtf)
1509
+ static HEDLEY_INLINE float simde_math_erfinvf(float x)
1510
+ {
1511
+ float tt1, tt2, lnx;
1512
+ float sgn = simde_math_copysignf(1.0f, x);
1513
+
1514
+ x = (1.0f - x) * (1.0f + x);
1515
+ lnx = simde_math_logf(x);
1516
+
1517
+ tt1 = 2.0f / (SIMDE_MATH_PIF * 0.14829094707965850830078125f) +
1518
+ 0.5f * lnx;
1519
+ tt2 = (1.0f / 0.14829094707965850830078125f) * lnx;
1520
+
1521
+ return sgn * simde_math_sqrtf(-tt1 + simde_math_sqrtf(tt1 * tt1 - tt2));
1522
+ }
1523
+ #define simde_math_erfinvf simde_math_erfinvf
1524
+ #endif
1525
+
1526
+ #if !defined(simde_math_erfcinv) && defined(simde_math_erfinv) && \
1527
+ defined(simde_math_log) && defined(simde_math_sqrt)
1528
+ static HEDLEY_INLINE double simde_math_erfcinv(double x)
1529
+ {
1530
+ if (x >= 0.0625 && x < 2.0) {
1531
+ return simde_math_erfinv(1.0 - x);
1532
+ } else if (x < 0.0625 && x >= 1.0e-100) {
1533
+ double p[6] = {0.1550470003116, 1.382719649631, 0.690969348887,
1534
+ -1.128081391617, 0.680544246825, -0.16444156791};
1535
+ double q[3] = {0.155024849822, 1.385228141995, 1.000000000000};
1536
+
1537
+ const double t = 1.0 / simde_math_sqrt(-simde_math_log(x));
1538
+ return (p[0] / t + p[1] +
1539
+ t * (p[2] + t * (p[3] + t * (p[4] + t * p[5])))) /
1540
+ (q[0] + t * (q[1] + t * (q[2])));
1541
+ } else if (x < 1.0e-100 && x >= SIMDE_MATH_DBL_MIN) {
1542
+ double p[4] = {0.00980456202915, 0.363667889171, 0.97302949837,
1543
+ -0.5374947401};
1544
+ double q[3] = {0.00980451277802, 0.363699971544,
1545
+ 1.000000000000};
1546
+
1547
+ const double t = 1.0 / simde_math_sqrt(-simde_math_log(x));
1548
+ return (p[0] / t + p[1] + t * (p[2] + t * p[3])) /
1549
+ (q[0] + t * (q[1] + t * (q[2])));
1550
+ } else if (!simde_math_isnormal(x)) {
1551
+ return SIMDE_MATH_INFINITY;
1552
+ } else {
1553
+ return -SIMDE_MATH_INFINITY;
1554
+ }
1555
+ }
1556
+
1557
+ #define simde_math_erfcinv simde_math_erfcinv
1558
+ #endif
1559
+
1560
+ #if !defined(simde_math_erfcinvf) && defined(simde_math_erfinvf) && \
1561
+ defined(simde_math_logf) && defined(simde_math_sqrtf)
1562
+ static HEDLEY_INLINE float simde_math_erfcinvf(float x)
1563
+ {
1564
+ if (x >= 0.0625f && x < 2.0f) {
1565
+ return simde_math_erfinvf(1.0f - x);
1566
+ } else if (x < 0.0625f && x >= SIMDE_MATH_FLT_MIN) {
1567
+ static const float p[6] = {0.1550470003116f, 1.382719649631f,
1568
+ 0.690969348887f, -1.128081391617f,
1569
+ 0.680544246825f - 0.164441567910f};
1570
+ static const float q[3] = {0.155024849822f, 1.385228141995f,
1571
+ 1.000000000000f};
1572
+
1573
+ const float t = 1.0f / simde_math_sqrtf(-simde_math_logf(x));
1574
+ return (p[0] / t + p[1] +
1575
+ t * (p[2] + t * (p[3] + t * (p[4] + t * p[5])))) /
1576
+ (q[0] + t * (q[1] + t * (q[2])));
1577
+ } else if (x < SIMDE_MATH_FLT_MIN && simde_math_isnormalf(x)) {
1578
+ static const float p[4] = {0.00980456202915f, 0.36366788917100f,
1579
+ 0.97302949837000f,
1580
+ -0.5374947401000f};
1581
+ static const float q[3] = {0.00980451277802f, 0.36369997154400f,
1582
+ 1.00000000000000f};
1583
+
1584
+ const float t = 1.0f / simde_math_sqrtf(-simde_math_logf(x));
1585
+ return (p[0] / t + p[1] + t * (p[2] + t * p[3])) /
1586
+ (q[0] + t * (q[1] + t * (q[2])));
1587
+ } else {
1588
+ return simde_math_isnormalf(x) ? -SIMDE_MATH_INFINITYF
1589
+ : SIMDE_MATH_INFINITYF;
1590
+ }
1591
+ }
1592
+
1593
+ #define simde_math_erfcinvf simde_math_erfcinvf
1594
+ #endif
1595
+
1596
+ HEDLEY_DIAGNOSTIC_POP
1597
+
1598
+ static HEDLEY_INLINE double simde_math_rad2deg(double radians)
1599
+ {
1600
+ return radians * SIMDE_MATH_180_OVER_PI;
1601
+ }
1602
+
1603
+ static HEDLEY_INLINE float simde_math_rad2degf(float radians)
1604
+ {
1605
+ return radians * SIMDE_MATH_180_OVER_PIF;
1606
+ }
1607
+
1608
+ static HEDLEY_INLINE double simde_math_deg2rad(double degrees)
1609
+ {
1610
+ return degrees * SIMDE_MATH_PI_OVER_180;
1611
+ }
1612
+
1613
+ static HEDLEY_INLINE float simde_math_deg2radf(float degrees)
1614
+ {
1615
+ return degrees * (SIMDE_MATH_PI_OVER_180F);
1616
+ }
1617
+
1618
+ /*** Saturated arithmetic ***/
1619
+
1620
+ static HEDLEY_INLINE int8_t simde_math_adds_i8(int8_t a, int8_t b)
1621
+ {
1622
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1623
+ return vqaddb_s8(a, b);
1624
+ #else
1625
+ uint8_t a_ = HEDLEY_STATIC_CAST(uint8_t, a);
1626
+ uint8_t b_ = HEDLEY_STATIC_CAST(uint8_t, b);
1627
+ uint8_t r_ = a_ + b_;
1628
+
1629
+ a_ = (a_ >> ((8 * sizeof(r_)) - 1)) + INT8_MAX;
1630
+ if (HEDLEY_STATIC_CAST(int8_t, ((a_ ^ b_) | ~(b_ ^ r_))) >= 0) {
1631
+ r_ = a_;
1632
+ }
1633
+
1634
+ return HEDLEY_STATIC_CAST(int8_t, r_);
1635
+ #endif
1636
+ }
1637
+
1638
+ static HEDLEY_INLINE int16_t simde_math_adds_i16(int16_t a, int16_t b)
1639
+ {
1640
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1641
+ return vqaddh_s16(a, b);
1642
+ #else
1643
+ uint16_t a_ = HEDLEY_STATIC_CAST(uint16_t, a);
1644
+ uint16_t b_ = HEDLEY_STATIC_CAST(uint16_t, b);
1645
+ uint16_t r_ = a_ + b_;
1646
+
1647
+ a_ = (a_ >> ((8 * sizeof(r_)) - 1)) + INT16_MAX;
1648
+ if (HEDLEY_STATIC_CAST(int16_t, ((a_ ^ b_) | ~(b_ ^ r_))) >= 0) {
1649
+ r_ = a_;
1650
+ }
1651
+
1652
+ return HEDLEY_STATIC_CAST(int16_t, r_);
1653
+ #endif
1654
+ }
1655
+
1656
+ static HEDLEY_INLINE int32_t simde_math_adds_i32(int32_t a, int32_t b)
1657
+ {
1658
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1659
+ return vqadds_s32(a, b);
1660
+ #else
1661
+ uint32_t a_ = HEDLEY_STATIC_CAST(uint32_t, a);
1662
+ uint32_t b_ = HEDLEY_STATIC_CAST(uint32_t, b);
1663
+ uint32_t r_ = a_ + b_;
1664
+
1665
+ a_ = (a_ >> ((8 * sizeof(r_)) - 1)) + INT32_MAX;
1666
+ if (HEDLEY_STATIC_CAST(int32_t, ((a_ ^ b_) | ~(b_ ^ r_))) >= 0) {
1667
+ r_ = a_;
1668
+ }
1669
+
1670
+ return HEDLEY_STATIC_CAST(int32_t, r_);
1671
+ #endif
1672
+ }
1673
+
1674
+ static HEDLEY_INLINE int64_t simde_math_adds_i64(int64_t a, int64_t b)
1675
+ {
1676
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1677
+ return vqaddd_s64(a, b);
1678
+ #else
1679
+ uint64_t a_ = HEDLEY_STATIC_CAST(uint64_t, a);
1680
+ uint64_t b_ = HEDLEY_STATIC_CAST(uint64_t, b);
1681
+ uint64_t r_ = a_ + b_;
1682
+
1683
+ a_ = (a_ >> ((8 * sizeof(r_)) - 1)) + INT64_MAX;
1684
+ if (HEDLEY_STATIC_CAST(int64_t, ((a_ ^ b_) | ~(b_ ^ r_))) >= 0) {
1685
+ r_ = a_;
1686
+ }
1687
+
1688
+ return HEDLEY_STATIC_CAST(int64_t, r_);
1689
+ #endif
1690
+ }
1691
+
1692
+ static HEDLEY_INLINE uint8_t simde_math_adds_u8(uint8_t a, uint8_t b)
1693
+ {
1694
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1695
+ return vqaddb_u8(a, b);
1696
+ #else
1697
+ uint8_t r = a + b;
1698
+ r |= -(r < a);
1699
+ return r;
1700
+ #endif
1701
+ }
1702
+
1703
+ static HEDLEY_INLINE uint16_t simde_math_adds_u16(uint16_t a, uint16_t b)
1704
+ {
1705
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1706
+ return vqaddh_u16(a, b);
1707
+ #else
1708
+ uint16_t r = a + b;
1709
+ r |= -(r < a);
1710
+ return r;
1711
+ #endif
1712
+ }
1713
+
1714
+ static HEDLEY_INLINE uint32_t simde_math_adds_u32(uint32_t a, uint32_t b)
1715
+ {
1716
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1717
+ return vqadds_u32(a, b);
1718
+ #else
1719
+ uint32_t r = a + b;
1720
+ r |= -(r < a);
1721
+ return r;
1722
+ #endif
1723
+ }
1724
+
1725
+ static HEDLEY_INLINE uint64_t simde_math_adds_u64(uint64_t a, uint64_t b)
1726
+ {
1727
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1728
+ return vqaddd_u64(a, b);
1729
+ #else
1730
+ uint64_t r = a + b;
1731
+ r |= -(r < a);
1732
+ return r;
1733
+ #endif
1734
+ }
1735
+
1736
+ static HEDLEY_INLINE int8_t simde_math_subs_i8(int8_t a, int8_t b)
1737
+ {
1738
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1739
+ return vqsubb_s8(a, b);
1740
+ #else
1741
+ uint8_t a_ = HEDLEY_STATIC_CAST(uint8_t, a);
1742
+ uint8_t b_ = HEDLEY_STATIC_CAST(uint8_t, b);
1743
+ uint8_t r_ = a_ - b_;
1744
+
1745
+ a_ = (a_ >> 7) + INT8_MAX;
1746
+
1747
+ if (HEDLEY_STATIC_CAST(int8_t, (a_ ^ b_) & (a_ ^ r_)) < 0) {
1748
+ r_ = a_;
1749
+ }
1750
+
1751
+ return HEDLEY_STATIC_CAST(int8_t, r_);
1752
+ #endif
1753
+ }
1754
+
1755
+ static HEDLEY_INLINE int16_t simde_math_subs_i16(int16_t a, int16_t b)
1756
+ {
1757
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1758
+ return vqsubh_s16(a, b);
1759
+ #else
1760
+ uint16_t a_ = HEDLEY_STATIC_CAST(uint16_t, a);
1761
+ uint16_t b_ = HEDLEY_STATIC_CAST(uint16_t, b);
1762
+ uint16_t r_ = a_ - b_;
1763
+
1764
+ a_ = (a_ >> 15) + INT16_MAX;
1765
+
1766
+ if (HEDLEY_STATIC_CAST(int16_t, (a_ ^ b_) & (a_ ^ r_)) < 0) {
1767
+ r_ = a_;
1768
+ }
1769
+
1770
+ return HEDLEY_STATIC_CAST(int16_t, r_);
1771
+ #endif
1772
+ }
1773
+
1774
+ static HEDLEY_INLINE int32_t simde_math_subs_i32(int32_t a, int32_t b)
1775
+ {
1776
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1777
+ return vqsubs_s32(a, b);
1778
+ #else
1779
+ uint32_t a_ = HEDLEY_STATIC_CAST(uint32_t, a);
1780
+ uint32_t b_ = HEDLEY_STATIC_CAST(uint32_t, b);
1781
+ uint32_t r_ = a_ - b_;
1782
+
1783
+ a_ = (a_ >> 31) + INT32_MAX;
1784
+
1785
+ if (HEDLEY_STATIC_CAST(int32_t, (a_ ^ b_) & (a_ ^ r_)) < 0) {
1786
+ r_ = a_;
1787
+ }
1788
+
1789
+ return HEDLEY_STATIC_CAST(int32_t, r_);
1790
+ #endif
1791
+ }
1792
+
1793
+ static HEDLEY_INLINE int64_t simde_math_subs_i64(int64_t a, int64_t b)
1794
+ {
1795
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1796
+ return vqsubd_s64(a, b);
1797
+ #else
1798
+ uint64_t a_ = HEDLEY_STATIC_CAST(uint64_t, a);
1799
+ uint64_t b_ = HEDLEY_STATIC_CAST(uint64_t, b);
1800
+ uint64_t r_ = a_ - b_;
1801
+
1802
+ a_ = (a_ >> 63) + INT64_MAX;
1803
+
1804
+ if (HEDLEY_STATIC_CAST(int64_t, (a_ ^ b_) & (a_ ^ r_)) < 0) {
1805
+ r_ = a_;
1806
+ }
1807
+
1808
+ return HEDLEY_STATIC_CAST(int64_t, r_);
1809
+ #endif
1810
+ }
1811
+
1812
+ static HEDLEY_INLINE uint8_t simde_math_subs_u8(uint8_t a, uint8_t b)
1813
+ {
1814
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1815
+ return vqsubb_u8(a, b);
1816
+ #else
1817
+ uint8_t res = a - b;
1818
+ res &= -(res <= a);
1819
+ return res;
1820
+ #endif
1821
+ }
1822
+
1823
+ static HEDLEY_INLINE uint16_t simde_math_subs_u16(uint16_t a, uint16_t b)
1824
+ {
1825
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1826
+ return vqsubh_u16(a, b);
1827
+ #else
1828
+ uint16_t res = a - b;
1829
+ res &= -(res <= a);
1830
+ return res;
1831
+ #endif
1832
+ }
1833
+
1834
+ static HEDLEY_INLINE uint32_t simde_math_subs_u32(uint32_t a, uint32_t b)
1835
+ {
1836
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1837
+ return vqsubs_u32(a, b);
1838
+ #else
1839
+ uint32_t res = a - b;
1840
+ res &= -(res <= a);
1841
+ return res;
1842
+ #endif
1843
+ }
1844
+
1845
+ static HEDLEY_INLINE uint64_t simde_math_subs_u64(uint64_t a, uint64_t b)
1846
+ {
1847
+ #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
1848
+ return vqsubd_u64(a, b);
1849
+ #else
1850
+ uint64_t res = a - b;
1851
+ res &= -(res <= a);
1852
+ return res;
1853
+ #endif
1854
+ }
1855
+
1856
+ HEDLEY_DIAGNOSTIC_POP
1857
+
1858
+ #endif /* !defined(SIMDE_MATH_H) */