koffi 2.3.6-beta.6 → 2.3.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 (276) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +2 -2
  3. package/src/cnoke/cnoke.js +3 -7
  4. package/src/cnoke/src/builder.js +9 -6
  5. package/src/cnoke/src/index.js +2 -2
  6. package/src/koffi/build/2.3.7/koffi_darwin_arm64/koffi.node +0 -0
  7. package/src/koffi/build/2.3.7/koffi_darwin_x64/koffi.node +0 -0
  8. package/src/koffi/build/2.3.7/koffi_freebsd_arm64/koffi.node +0 -0
  9. package/src/koffi/build/2.3.7/koffi_freebsd_ia32/koffi.node +0 -0
  10. package/src/koffi/build/2.3.7/koffi_freebsd_x64/koffi.node +0 -0
  11. package/src/koffi/build/2.3.7/koffi_linux_arm32hf/koffi.node +0 -0
  12. package/src/koffi/build/2.3.7/koffi_linux_arm64/koffi.node +0 -0
  13. package/src/koffi/build/2.3.7/koffi_linux_ia32/koffi.node +0 -0
  14. package/src/koffi/build/2.3.7/koffi_linux_riscv64hf64/koffi.node +0 -0
  15. package/src/koffi/build/2.3.7/koffi_linux_x64/koffi.node +0 -0
  16. package/src/koffi/build/2.3.7/koffi_openbsd_ia32/koffi.node +0 -0
  17. package/src/koffi/build/2.3.7/koffi_openbsd_x64/koffi.node +0 -0
  18. package/src/koffi/build/2.3.7/koffi_win32_arm64/koffi.node +0 -0
  19. package/src/koffi/build/2.3.7/koffi_win32_ia32/koffi.node +0 -0
  20. package/src/koffi/build/2.3.7/koffi_win32_x64/koffi.node +0 -0
  21. package/src/koffi/src/ffi.cc +2 -2
  22. package/src/koffi/src/index.d.ts +2 -2
  23. package/src/koffi/src/index.js +1 -0
  24. package/src/koffi/build/2.3.6-beta.6/koffi_darwin_arm64/koffi.node +0 -0
  25. package/src/koffi/build/2.3.6-beta.6/koffi_darwin_x64/koffi.node +0 -0
  26. package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_arm64/koffi.node +0 -0
  27. package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_ia32/koffi.node +0 -0
  28. package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_x64/koffi.node +0 -0
  29. package/src/koffi/build/2.3.6-beta.6/koffi_linux_arm32hf/koffi.node +0 -0
  30. package/src/koffi/build/2.3.6-beta.6/koffi_linux_arm64/koffi.node +0 -0
  31. package/src/koffi/build/2.3.6-beta.6/koffi_linux_ia32/koffi.node +0 -0
  32. package/src/koffi/build/2.3.6-beta.6/koffi_linux_riscv64hf64/koffi.node +0 -0
  33. package/src/koffi/build/2.3.6-beta.6/koffi_linux_x64/koffi.node +0 -0
  34. package/src/koffi/build/2.3.6-beta.6/koffi_openbsd_ia32/koffi.node +0 -0
  35. package/src/koffi/build/2.3.6-beta.6/koffi_openbsd_x64/koffi.node +0 -0
  36. package/src/koffi/build/2.3.6-beta.6/koffi_win32_arm64/koffi.node +0 -0
  37. package/src/koffi/build/2.3.6-beta.6/koffi_win32_arm64/koffi.pdb +0 -0
  38. package/src/koffi/build/2.3.6-beta.6/koffi_win32_ia32/koffi.node +0 -0
  39. package/src/koffi/build/2.3.6-beta.6/koffi_win32_ia32/koffi.pdb +0 -0
  40. package/src/koffi/build/2.3.6-beta.6/koffi_win32_x64/koffi.node +0 -0
  41. package/src/koffi/build/2.3.6-beta.6/koffi_win32_x64/koffi.pdb +0 -0
  42. package/vendor/brotli/BUILD +0 -144
  43. package/vendor/brotli/CMakeLists.txt +0 -421
  44. package/vendor/brotli/CONTRIBUTING.md +0 -27
  45. package/vendor/brotli/LICENSE +0 -19
  46. package/vendor/brotli/MANIFEST.in +0 -17
  47. package/vendor/brotli/Makefile +0 -55
  48. package/vendor/brotli/Makefile.am +0 -38
  49. package/vendor/brotli/README +0 -15
  50. package/vendor/brotli/README.md +0 -104
  51. package/vendor/brotli/WORKSPACE +0 -21
  52. package/vendor/brotli/bootstrap +0 -35
  53. package/vendor/brotli/c/common/constants.c +0 -15
  54. package/vendor/brotli/c/common/constants.h +0 -200
  55. package/vendor/brotli/c/common/context.c +0 -156
  56. package/vendor/brotli/c/common/context.h +0 -113
  57. package/vendor/brotli/c/common/dictionary.c +0 -5914
  58. package/vendor/brotli/c/common/dictionary.h +0 -64
  59. package/vendor/brotli/c/common/platform.c +0 -22
  60. package/vendor/brotli/c/common/platform.h +0 -596
  61. package/vendor/brotli/c/common/transform.c +0 -291
  62. package/vendor/brotli/c/common/transform.h +0 -85
  63. package/vendor/brotli/c/common/version.h +0 -26
  64. package/vendor/brotli/c/dec/bit_reader.c +0 -76
  65. package/vendor/brotli/c/dec/bit_reader.h +0 -351
  66. package/vendor/brotli/c/dec/decode.c +0 -2608
  67. package/vendor/brotli/c/dec/huffman.c +0 -339
  68. package/vendor/brotli/c/dec/huffman.h +0 -121
  69. package/vendor/brotli/c/dec/prefix.h +0 -732
  70. package/vendor/brotli/c/dec/state.c +0 -159
  71. package/vendor/brotli/c/dec/state.h +0 -365
  72. package/vendor/brotli/c/enc/backward_references.c +0 -145
  73. package/vendor/brotli/c/enc/backward_references.h +0 -39
  74. package/vendor/brotli/c/enc/backward_references_hq.c +0 -843
  75. package/vendor/brotli/c/enc/backward_references_hq.h +0 -95
  76. package/vendor/brotli/c/enc/backward_references_inc.h +0 -163
  77. package/vendor/brotli/c/enc/bit_cost.c +0 -35
  78. package/vendor/brotli/c/enc/bit_cost.h +0 -63
  79. package/vendor/brotli/c/enc/bit_cost_inc.h +0 -127
  80. package/vendor/brotli/c/enc/block_encoder_inc.h +0 -34
  81. package/vendor/brotli/c/enc/block_splitter.c +0 -194
  82. package/vendor/brotli/c/enc/block_splitter.h +0 -51
  83. package/vendor/brotli/c/enc/block_splitter_inc.h +0 -440
  84. package/vendor/brotli/c/enc/brotli_bit_stream.c +0 -1314
  85. package/vendor/brotli/c/enc/brotli_bit_stream.h +0 -84
  86. package/vendor/brotli/c/enc/cluster.c +0 -56
  87. package/vendor/brotli/c/enc/cluster.h +0 -48
  88. package/vendor/brotli/c/enc/cluster_inc.h +0 -320
  89. package/vendor/brotli/c/enc/command.c +0 -28
  90. package/vendor/brotli/c/enc/command.h +0 -190
  91. package/vendor/brotli/c/enc/compress_fragment.c +0 -790
  92. package/vendor/brotli/c/enc/compress_fragment.h +0 -61
  93. package/vendor/brotli/c/enc/compress_fragment_two_pass.c +0 -645
  94. package/vendor/brotli/c/enc/compress_fragment_two_pass.h +0 -54
  95. package/vendor/brotli/c/enc/dictionary_hash.c +0 -1846
  96. package/vendor/brotli/c/enc/dictionary_hash.h +0 -25
  97. package/vendor/brotli/c/enc/encode.c +0 -1927
  98. package/vendor/brotli/c/enc/encoder_dict.c +0 -33
  99. package/vendor/brotli/c/enc/encoder_dict.h +0 -43
  100. package/vendor/brotli/c/enc/entropy_encode.c +0 -503
  101. package/vendor/brotli/c/enc/entropy_encode.h +0 -122
  102. package/vendor/brotli/c/enc/entropy_encode_static.h +0 -539
  103. package/vendor/brotli/c/enc/fast_log.c +0 -105
  104. package/vendor/brotli/c/enc/fast_log.h +0 -66
  105. package/vendor/brotli/c/enc/find_match_length.h +0 -79
  106. package/vendor/brotli/c/enc/hash.h +0 -488
  107. package/vendor/brotli/c/enc/hash_composite_inc.h +0 -125
  108. package/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +0 -293
  109. package/vendor/brotli/c/enc/hash_longest_match64_inc.h +0 -267
  110. package/vendor/brotli/c/enc/hash_longest_match_inc.h +0 -262
  111. package/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +0 -266
  112. package/vendor/brotli/c/enc/hash_rolling_inc.h +0 -212
  113. package/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +0 -329
  114. package/vendor/brotli/c/enc/histogram.c +0 -100
  115. package/vendor/brotli/c/enc/histogram.h +0 -63
  116. package/vendor/brotli/c/enc/histogram_inc.h +0 -51
  117. package/vendor/brotli/c/enc/literal_cost.c +0 -175
  118. package/vendor/brotli/c/enc/literal_cost.h +0 -30
  119. package/vendor/brotli/c/enc/memory.c +0 -170
  120. package/vendor/brotli/c/enc/memory.h +0 -114
  121. package/vendor/brotli/c/enc/metablock.c +0 -663
  122. package/vendor/brotli/c/enc/metablock.h +0 -105
  123. package/vendor/brotli/c/enc/metablock_inc.h +0 -183
  124. package/vendor/brotli/c/enc/params.h +0 -46
  125. package/vendor/brotli/c/enc/prefix.h +0 -53
  126. package/vendor/brotli/c/enc/quality.h +0 -165
  127. package/vendor/brotli/c/enc/ringbuffer.h +0 -167
  128. package/vendor/brotli/c/enc/static_dict.c +0 -486
  129. package/vendor/brotli/c/enc/static_dict.h +0 -40
  130. package/vendor/brotli/c/enc/static_dict_lut.h +0 -5864
  131. package/vendor/brotli/c/enc/utf8_util.c +0 -85
  132. package/vendor/brotli/c/enc/utf8_util.h +0 -32
  133. package/vendor/brotli/c/enc/write_bits.h +0 -87
  134. package/vendor/brotli/c/include/brotli/decode.h +0 -344
  135. package/vendor/brotli/c/include/brotli/encode.h +0 -448
  136. package/vendor/brotli/c/include/brotli/port.h +0 -288
  137. package/vendor/brotli/c/include/brotli/types.h +0 -83
  138. package/vendor/brotli/c/tools/brotli.c +0 -1116
  139. package/vendor/brotli/c/tools/brotli.md +0 -107
  140. package/vendor/brotli/compiler_config_setting.bzl +0 -28
  141. package/vendor/brotli/configure +0 -8
  142. package/vendor/brotli/configure-cmake +0 -318
  143. package/vendor/brotli/configure.ac +0 -14
  144. package/vendor/brotli/docs/brotli.1 +0 -132
  145. package/vendor/brotli/docs/constants.h.3 +0 -47
  146. package/vendor/brotli/docs/decode.h.3 +0 -415
  147. package/vendor/brotli/docs/encode.h.3 +0 -586
  148. package/vendor/brotli/docs/types.h.3 +0 -117
  149. package/vendor/brotli/premake5.lua +0 -78
  150. package/vendor/brotli/python/Makefile +0 -57
  151. package/vendor/brotli/python/README.md +0 -54
  152. package/vendor/brotli/python/_brotli.cc +0 -753
  153. package/vendor/brotli/python/bro.py +0 -160
  154. package/vendor/brotli/python/brotli.py +0 -56
  155. package/vendor/brotli/python/tests/__init__.py +0 -0
  156. package/vendor/brotli/python/tests/_test_utils.py +0 -112
  157. package/vendor/brotli/python/tests/bro_test.py +0 -102
  158. package/vendor/brotli/python/tests/compress_test.py +0 -41
  159. package/vendor/brotli/python/tests/compressor_test.py +0 -94
  160. package/vendor/brotli/python/tests/decompress_test.py +0 -42
  161. package/vendor/brotli/python/tests/decompressor_test.py +0 -59
  162. package/vendor/brotli/scripts/libbrotlicommon.pc.in +0 -11
  163. package/vendor/brotli/scripts/libbrotlidec.pc.in +0 -12
  164. package/vendor/brotli/scripts/libbrotlienc.pc.in +0 -12
  165. package/vendor/brotli/scripts/sources.lst +0 -104
  166. package/vendor/brotli/setup.cfg +0 -5
  167. package/vendor/brotli/setup.py +0 -293
  168. package/vendor/brotli/tests/Makefile +0 -17
  169. package/vendor/brotli/tests/compatibility_test.sh +0 -25
  170. package/vendor/brotli/tests/roundtrip_test.sh +0 -36
  171. package/vendor/brotli/tests/run-compatibility-test.cmake +0 -31
  172. package/vendor/brotli/tests/run-roundtrip-test.cmake +0 -36
  173. package/vendor/brotli/tests/testdata/empty +0 -0
  174. package/vendor/brotli/tests/testdata/empty.compressed +0 -1
  175. package/vendor/brotli/tests/testdata/ukkonooa +0 -1
  176. package/vendor/brotli/tests/testdata/ukkonooa.compressed +0 -0
  177. package/vendor/dragonbox/CMakeLists.txt +0 -123
  178. package/vendor/dragonbox/LICENSE-Apache2-LLVM +0 -218
  179. package/vendor/dragonbox/LICENSE-Boost +0 -23
  180. package/vendor/dragonbox/README.md +0 -277
  181. package/vendor/dragonbox/cmake/dragonboxConfig.cmake +0 -1
  182. package/vendor/dragonbox/include/dragonbox/dragonbox.h +0 -2674
  183. package/vendor/dragonbox/include/dragonbox/dragonbox_to_chars.h +0 -108
  184. package/vendor/dragonbox/other_files/Dragonbox.pdf +0 -0
  185. package/vendor/dragonbox/other_files/Dragonbox_old.pdf +0 -0
  186. package/vendor/dragonbox/other_files/milo_benchmark.png +0 -0
  187. package/vendor/dragonbox/other_files/unknown_win64_vc2019.html +0 -540
  188. package/vendor/dragonbox/other_files/unknown_win64_vc2019_randomdigit_time.png +0 -0
  189. package/vendor/dragonbox/source/dragonbox_to_chars.cpp +0 -303
  190. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/CMakeLists.txt +0 -24
  191. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.cpp +0 -238
  192. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.h +0 -95
  193. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/grisu_exact.h +0 -2666
  194. package/vendor/dragonbox/subproject/3rdparty/ryu/CMakeLists.txt +0 -16
  195. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/common.h +0 -114
  196. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s.c +0 -509
  197. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_full_table.h +0 -367
  198. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_intrinsics.h +0 -357
  199. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/digit_table.h +0 -35
  200. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s.c +0 -345
  201. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_full_table.h +0 -55
  202. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_intrinsics.h +0 -128
  203. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/ryu.h +0 -46
  204. package/vendor/dragonbox/subproject/3rdparty/schubfach/CMakeLists.txt +0 -22
  205. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.cc +0 -699
  206. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.h +0 -31
  207. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.cc +0 -1354
  208. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.h +0 -31
  209. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/example_shaded_plots.m +0 -68
  210. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/license.txt +0 -25
  211. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution.m +0 -92
  212. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution_prctile.m +0 -121
  213. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_histogram_shaded.m +0 -99
  214. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_shaded.m +0 -93
  215. package/vendor/dragonbox/subproject/benchmark/CMakeLists.txt +0 -65
  216. package/vendor/dragonbox/subproject/benchmark/include/benchmark.h +0 -40
  217. package/vendor/dragonbox/subproject/benchmark/matlab/plot_benchmarks.m +0 -22
  218. package/vendor/dragonbox/subproject/benchmark/matlab/plot_digit_benchmark.m +0 -78
  219. package/vendor/dragonbox/subproject/benchmark/matlab/plot_uniform_benchmark.m +0 -95
  220. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_clang.png +0 -0
  221. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_msvc.png +0 -0
  222. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_clang.png +0 -0
  223. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_msvc.png +0 -0
  224. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_clang.png +0 -0
  225. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_msvc.png +0 -0
  226. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_clang.png +0 -0
  227. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_msvc.png +0 -0
  228. package/vendor/dragonbox/subproject/benchmark/source/benchmark.cpp +0 -238
  229. package/vendor/dragonbox/subproject/benchmark/source/dragonbox.cpp +0 -30
  230. package/vendor/dragonbox/subproject/benchmark/source/grisu_exact.cpp +0 -36
  231. package/vendor/dragonbox/subproject/benchmark/source/ryu.cpp +0 -27
  232. package/vendor/dragonbox/subproject/benchmark/source/schubfach.cpp +0 -31
  233. package/vendor/dragonbox/subproject/common/CMakeLists.txt +0 -42
  234. package/vendor/dragonbox/subproject/common/include/best_rational_approx.h +0 -97
  235. package/vendor/dragonbox/subproject/common/include/big_uint.h +0 -218
  236. package/vendor/dragonbox/subproject/common/include/continued_fractions.h +0 -174
  237. package/vendor/dragonbox/subproject/common/include/good_rational_approx.h +0 -267
  238. package/vendor/dragonbox/subproject/common/include/random_float.h +0 -182
  239. package/vendor/dragonbox/subproject/common/include/rational_continued_fractions.h +0 -57
  240. package/vendor/dragonbox/subproject/common/source/big_uint.cpp +0 -602
  241. package/vendor/dragonbox/subproject/meta/CMakeLists.txt +0 -41
  242. package/vendor/dragonbox/subproject/meta/results/binary32_generated_cache.txt +0 -82
  243. package/vendor/dragonbox/subproject/meta/results/binary64_compressed_cache_error_table.txt +0 -10
  244. package/vendor/dragonbox/subproject/meta/results/binary64_generated_cache.txt +0 -623
  245. package/vendor/dragonbox/subproject/meta/source/generate_cache.cpp +0 -126
  246. package/vendor/dragonbox/subproject/meta/source/live_test.cpp +0 -81
  247. package/vendor/dragonbox/subproject/meta/source/perf_test.cpp +0 -104
  248. package/vendor/dragonbox/subproject/meta/source/sandbox.cpp +0 -20
  249. package/vendor/dragonbox/subproject/test/CMakeLists.txt +0 -70
  250. package/vendor/dragonbox/subproject/test/results/binary32.csv +0 -255
  251. package/vendor/dragonbox/subproject/test/results/binary64.csv +0 -2047
  252. package/vendor/dragonbox/subproject/test/results/plot_required_bits.m +0 -18
  253. package/vendor/dragonbox/subproject/test/source/test_all_shorter_interval_cases.cpp +0 -88
  254. package/vendor/dragonbox/subproject/test/source/uniform_random_test.cpp +0 -95
  255. package/vendor/dragonbox/subproject/test/source/verify_cache_precision.cpp +0 -338
  256. package/vendor/dragonbox/subproject/test/source/verify_compressed_cache.cpp +0 -154
  257. package/vendor/dragonbox/subproject/test/source/verify_fast_multiplication.cpp +0 -168
  258. package/vendor/dragonbox/subproject/test/source/verify_log_computation.cpp +0 -251
  259. package/vendor/dragonbox/subproject/test/source/verify_magic_division.cpp +0 -113
  260. package/vendor/miniz/ChangeLog.md +0 -239
  261. package/vendor/miniz/LICENSE +0 -22
  262. package/vendor/miniz/examples/example1.c +0 -105
  263. package/vendor/miniz/examples/example2.c +0 -164
  264. package/vendor/miniz/examples/example3.c +0 -269
  265. package/vendor/miniz/examples/example4.c +0 -102
  266. package/vendor/miniz/examples/example5.c +0 -327
  267. package/vendor/miniz/examples/example6.c +0 -166
  268. package/vendor/miniz/miniz.c +0 -7835
  269. package/vendor/miniz/miniz.h +0 -1422
  270. package/vendor/miniz/readme.md +0 -46
  271. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_arm64/koffi.exp +0 -0
  272. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_arm64/koffi.lib +0 -0
  273. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_ia32/koffi.exp +0 -0
  274. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_ia32/koffi.lib +0 -0
  275. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_x64/koffi.exp +0 -0
  276. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_x64/koffi.lib +0 -0
@@ -1,267 +0,0 @@
1
- // Copyright 2022 Junekey Jeon
2
- //
3
- // The contents of this file may be used under the terms of
4
- // the Apache License v2.0 with LLVM Exceptions.
5
- //
6
- // (See accompanying file LICENSE-Apache or copy at
7
- // https://llvm.org/foundation/relicensing/LICENSE.txt)
8
- //
9
- // Alternatively, the contents of this file may be used under the terms of
10
- // the Boost Software License, Version 1.0.
11
- // (See accompanying file LICENSE-Boost or copy at
12
- // https://www.boost.org/LICENSE_1_0.txt)
13
- //
14
- // Unless required by applicable law or agreed to in writing, this software
15
- // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- // KIND, either express or implied.
17
-
18
- #ifndef JKJ_HEADER_GOOD_RATIONAL_APPROX
19
- #define JKJ_HEADER_GOOD_RATIONAL_APPROX
20
-
21
- #include "continued_fractions.h"
22
- #include <cassert>
23
- #include <cstdlib>
24
- #include <vector>
25
-
26
- namespace jkj {
27
- // Find all denominators of rational approximations from below of denominators no more than
28
- // denominator_upper_bound for the given number x whose error in the strong sense is at most
29
- // error_threshold. The returned list might contain several different denominators of the same
30
- // rational number.
31
- template <class ContinuedFractionsImpl, class UInt, class PositiveNumberX,
32
- class PositiveNumberEpsilon>
33
- std::vector<typename ContinuedFractionsImpl::uint_type>
34
- find_all_good_rational_approx_from_below_denoms(PositiveNumberX const& x,
35
- UInt const& denominator_upper_bound,
36
- PositiveNumberEpsilon const& error_threshold) {
37
- assert(denominator_upper_bound > 0);
38
-
39
- using uint_type = typename ContinuedFractionsImpl::uint_type;
40
- std::vector<uint_type> results;
41
-
42
- if (error_threshold >= PositiveNumberEpsilon(1)) {
43
- for (UInt i = 1; i <= denominator_upper_bound; ++i) {
44
- results.push_back(i);
45
- }
46
- return results;
47
- }
48
-
49
- // Initialize a continued fractions calculator.
50
- ContinuedFractionsImpl cf{x};
51
-
52
- // We will find the first even semiconvergent whose error is at most the threshold.
53
- // If such semiconvergent has the denominator strictly bigger than the
54
- // denominator_upper_bound, then there is no n such that nx - floor(nx) <= epsilon.
55
- unsigned_rational<uint_type> previous_convergent; // even
56
- unsigned_rational<uint_type> current_convergent; // odd
57
- uint_type semiconvergent_coeff = 0;
58
- unsigned_rational<uint_type> semiconvergent;
59
-
60
- auto perfect_approx_possible = [&] {
61
- // If there is no more convergent, we already obtained the perfect approximation.
62
- // This means that x = p/q is rational with q <= denominator_upper_bound.
63
- // In this case, just return q, 2q, 3q, ... up to denominator_upper_bound.
64
-
65
- auto denominator = cf.current_denominator();
66
- while (denominator <= denominator_upper_bound) {
67
- results.push_back(denominator);
68
- denominator += cf.current_denominator();
69
- }
70
- };
71
-
72
- auto update_semiconvergent = [&] {
73
- semiconvergent.numerator =
74
- previous_convergent.numerator + semiconvergent_coeff * current_convergent.numerator;
75
- semiconvergent.denominator = previous_convergent.denominator +
76
- semiconvergent_coeff * current_convergent.denominator;
77
- };
78
-
79
- auto gcd = [&](auto a, auto b) {
80
- decltype(a) t;
81
- while (b != 0) {
82
- t = b;
83
- b = a % b;
84
- a = static_cast<decltype(a)&&>(t);
85
- }
86
- return a;
87
- };
88
-
89
- auto subroutine_for_each_semiconvergent = [&] {
90
- auto push_all_multiples = [&](auto const& candidate) {
91
- auto error = candidate.denominator * x - candidate.numerator;
92
- auto error_multiple = error;
93
- auto denominator_multiple = candidate.denominator;
94
- while (error_multiple < error_threshold &&
95
- denominator_multiple <= denominator_upper_bound) {
96
- results.push_back(denominator_multiple);
97
- error_multiple += error;
98
- denominator_multiple += candidate.denominator;
99
- }
100
- };
101
- push_all_multiples(semiconvergent);
102
-
103
- auto b_max = uint_type(denominator_upper_bound) / semiconvergent.denominator;
104
-
105
- for (decltype(b_max) b = 2; b <= b_max; ++b) {
106
- unsigned_rational<uint_type> candidate{b * semiconvergent.numerator,
107
- b * semiconvergent.denominator};
108
-
109
- auto a_max = (uint_type(denominator_upper_bound) - candidate.denominator) /
110
- current_convergent.denominator;
111
- for (decltype(a_max) a = 1; a <= a_max && a < b; ++a) {
112
- candidate.numerator += current_convergent.numerator;
113
- candidate.denominator += current_convergent.denominator;
114
-
115
- // If a and b are not coprime, skip.
116
- if (gcd(a, b) != 1) {
117
- continue;
118
- }
119
-
120
- push_all_multiples(candidate);
121
- }
122
- }
123
- };
124
-
125
- while (true) {
126
- // Currently, cf.current_index() is odd.
127
- // Obtain the next convergent.
128
- if (!cf.update()) {
129
- perfect_approx_possible();
130
-
131
- // The last convergent is of odd index, and we are looking for semiconvergents after
132
- // the last even convergent. These semiconvergents should have the same error
133
- // with the last even convergent, and since the last even convergent has been
134
- // confirmed to have error worse than the threshold, there is nothing left to do.
135
- return results;
136
- }
137
-
138
- // Now, cf.current_index() is even.
139
- if (cf.current_denominator() * x - cf.current_numerator() < error_threshold) {
140
- // In this case, we should look at semiconvergents.
141
- if (cf.current_index() == 0) {
142
- // In this case, the semiconvergent we are looking for is the 0th convergent.
143
- break;
144
- }
145
- else {
146
- while (true) {
147
- ++semiconvergent_coeff;
148
- update_semiconvergent();
149
-
150
- if (semiconvergent.denominator > denominator_upper_bound) {
151
- // This means there is no semiconvergent satisfying the condition.
152
- return results;
153
- }
154
-
155
- if (semiconvergent_coeff == cf.current_coefficient()) {
156
- // Found the first semiconvergent, which is the next convergent.
157
- break;
158
- }
159
-
160
- if (semiconvergent.denominator * x - semiconvergent.numerator <
161
- error_threshold) {
162
- // Found the first semiconvergent.
163
- // Iterate until reaching the next convergent.
164
- while (true) {
165
- subroutine_for_each_semiconvergent();
166
- ++semiconvergent_coeff;
167
- update_semiconvergent();
168
-
169
- if (semiconvergent.denominator > denominator_upper_bound) {
170
- return results;
171
- }
172
-
173
- if (semiconvergent_coeff == cf.current_coefficient()) {
174
- break;
175
- }
176
- }
177
- break;
178
- }
179
- }
180
- }
181
- break;
182
- }
183
-
184
- if (cf.current_denominator() > denominator_upper_bound) {
185
- // In this case, we haven't found any convergent that has better error than the
186
- // threshold, which means there is no n satisfying nx - floor(nx) <= epsilon.
187
- return results;
188
- }
189
-
190
- // Currently, cf.current_index() is even.
191
- // Obtain the next convergent.
192
- if (!cf.update()) {
193
- // In this case, there is no n satisfying nx - floor(nx) <= epsilon
194
- // other than those making x an integer.
195
- perfect_approx_possible();
196
- return results;
197
- }
198
-
199
- // Now, cf.current_index() is odd.
200
- if (cf.current_denominator() > denominator_upper_bound) {
201
- // In this case, we haven't found any convergent that has better error than the
202
- // threshold, which means there is no n satisfying nx - floor(nx) <= epsilon.
203
- return results;
204
- }
205
-
206
- previous_convergent = cf.previous_convergent();
207
- current_convergent = cf.current_convergent();
208
- }
209
-
210
- // We have found the first even semiconvergent with a good enough error.
211
- assert(cf.current_index() % 2 == 0);
212
-
213
- // Now, iterate over all subsequent convergents.
214
- while (true) {
215
- if (!cf.update()) {
216
- perfect_approx_possible();
217
- break;
218
- }
219
-
220
- // Now, cf.current_index() is odd.
221
- previous_convergent = cf.previous_convergent();
222
- current_convergent = cf.current_convergent();
223
- semiconvergent_coeff = 0;
224
- update_semiconvergent();
225
- subroutine_for_each_semiconvergent();
226
-
227
- if (cf.current_denominator() > denominator_upper_bound) {
228
- break;
229
- }
230
-
231
- // Obtain the next even convergent.
232
- if (!cf.update()) {
233
- perfect_approx_possible();
234
-
235
- // The last convergent is of odd index, and we are looking for semiconvergents
236
- // after the last even convergent.
237
- while (true) {
238
- ++semiconvergent_coeff;
239
- update_semiconvergent();
240
-
241
- if (semiconvergent.denominator > denominator_upper_bound) {
242
- break;
243
- }
244
-
245
- subroutine_for_each_semiconvergent();
246
- }
247
- return results;
248
- }
249
-
250
- // Iterate over all semiconvergents.
251
- for (semiconvergent_coeff = 1; semiconvergent_coeff < cf.current_coefficient();
252
- ++semiconvergent_coeff) {
253
- update_semiconvergent();
254
-
255
- if (semiconvergent.denominator > denominator_upper_bound) {
256
- return results;
257
- }
258
-
259
- subroutine_for_each_semiconvergent();
260
- }
261
- }
262
-
263
- return results;
264
- }
265
- }
266
-
267
- #endif
@@ -1,182 +0,0 @@
1
- // Copyright 2020-2021 Junekey Jeon
2
- //
3
- // The contents of this file may be used under the terms of
4
- // the Apache License v2.0 with LLVM Exceptions.
5
- //
6
- // (See accompanying file LICENSE-Apache or copy at
7
- // https://llvm.org/foundation/relicensing/LICENSE.txt)
8
- //
9
- // Alternatively, the contents of this file may be used under the terms of
10
- // the Boost Software License, Version 1.0.
11
- // (See accompanying file LICENSE-Boost or copy at
12
- // https://www.boost.org/LICENSE_1_0.txt)
13
- //
14
- // Unless required by applicable law or agreed to in writing, this software
15
- // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- // KIND, either express or implied.
17
-
18
- #ifndef JKJ_HEADER_RANDOM_FLOAT
19
- #define JKJ_HEADER_RANDOM_FLOAT
20
-
21
- #include "dragonbox/dragonbox.h"
22
- #include <algorithm>
23
- #include <cstring>
24
- #include <random>
25
- #include <stdexcept>
26
- #include <string>
27
- #include <vector>
28
-
29
- // For correct seeding
30
- class repeating_seed_seq {
31
- public:
32
- using result_type = std::uint32_t;
33
-
34
- repeating_seed_seq() : stored_values{0} {}
35
- template <class InputIterator>
36
- repeating_seed_seq(InputIterator first, InputIterator last) : stored_values(first, last) {}
37
- template <class T>
38
- repeating_seed_seq(std::initializer_list<T> list) : stored_values(list) {}
39
-
40
- repeating_seed_seq(std::random_device&& rd, std::size_t count) {
41
- stored_values.resize(count);
42
- for (auto& elem : stored_values)
43
- elem = rd();
44
- }
45
-
46
- template <class RandomAccessIterator>
47
- void generate(RandomAccessIterator first, RandomAccessIterator last) {
48
- auto count = last - first;
49
- auto q = count / stored_values.size();
50
- for (std::size_t i = 0; i < q; ++i) {
51
- std::copy_n(stored_values.cbegin(), stored_values.size(), first);
52
- first += stored_values.size();
53
- }
54
- count -= q * stored_values.size();
55
- std::copy_n(stored_values.cbegin(), count, first);
56
- }
57
-
58
- std::size_t size() const noexcept { return stored_values.size(); }
59
-
60
- template <class OutputIterator>
61
- void param(OutputIterator first) const {
62
- std::copy(stored_values.begin(), stored_values.end(), first);
63
- }
64
-
65
- private:
66
- std::vector<std::uint32_t> stored_values;
67
- };
68
-
69
- inline std::mt19937_64 generate_correctly_seeded_mt19937_64() {
70
- repeating_seed_seq seed_seq{std::random_device{}, std::mt19937_64::state_size *
71
- std::mt19937_64::word_size /
72
- (sizeof(std::uint32_t) * 8)};
73
- return std::mt19937_64{seed_seq};
74
- }
75
-
76
- template <class Float, class RandGen>
77
- Float uniformly_randomly_generate_finite_float(RandGen& rg) {
78
- using ieee754_traits = jkj::dragonbox::default_float_traits<Float>;
79
- using ieee754_format_info = typename ieee754_traits::format;
80
- using carrier_uint = typename ieee754_traits::carrier_uint;
81
- using uniform_distribution = std::uniform_int_distribution<carrier_uint>;
82
-
83
- // Generate sign bit
84
- auto sign_bit = uniform_distribution{0, 1}(rg);
85
-
86
- // Generate exponent bits
87
- auto exponent_bits =
88
- uniform_distribution{0, (carrier_uint(1) << ieee754_format_info::exponent_bits) - 2}(rg);
89
-
90
- // Generate significand bits
91
- auto significand_bits =
92
- uniform_distribution{0, (carrier_uint(1) << ieee754_format_info::significand_bits) - 1}(rg);
93
-
94
- auto bit_representation = (sign_bit << (ieee754_traits::carrier_bits - 1)) |
95
- (exponent_bits << (ieee754_format_info::significand_bits)) |
96
- significand_bits;
97
-
98
- return ieee754_traits::carrier_to_float(bit_representation);
99
- }
100
-
101
- template <class Float, class RandGen>
102
- Float uniformly_randomly_generate_general_float(RandGen& rg) {
103
- using ieee754_traits = jkj::dragonbox::default_float_traits<Float>;
104
- using carrier_uint = typename ieee754_traits::carrier_uint;
105
- using uniform_distribution = std::uniform_int_distribution<carrier_uint>;
106
-
107
- // Generate sign bit
108
- auto bit_representation = uniform_distribution{0, std::numeric_limits<carrier_uint>::max()}(rg);
109
- return ieee754_traits::carrier_to_float(bit_representation);
110
- }
111
-
112
- // This function tries to uniformly randomly generate a float number with the
113
- // given number of decimal digits, and the end-result is not perfectly bias-free.
114
- // However, I don't think there is an easy way to do it correctly.
115
- template <class Float, class RandGen>
116
- Float randomly_generate_float_with_given_digits(unsigned int digits, RandGen& rg) {
117
- using ieee754_traits = jkj::dragonbox::default_float_traits<Float>;
118
- using carrier_uint = typename ieee754_traits::carrier_uint;
119
- using signed_int_t = std::make_signed_t<carrier_uint>;
120
-
121
- assert(digits >= 1);
122
- assert(digits <= ieee754_traits::format::decimal_digits);
123
-
124
- // Generate sign uniformly randomly
125
- signed_int_t sign = std::uniform_int_distribution<signed_int_t>{0, 1}(rg) == 0 ? 1 : -1;
126
-
127
-
128
- // Try to generate significand uniformly randomly
129
- Float result;
130
- signed_int_t from = 0, to = 9;
131
- if (digits > 1) {
132
- from = 1;
133
- for (unsigned int e = 1; e < digits - 1; ++e) {
134
- from *= 10;
135
- }
136
- to = from * 10 - 1;
137
- }
138
-
139
- while (true) {
140
- auto significand = std::uniform_int_distribution<signed_int_t>{from, to}(rg);
141
- if (digits > 1) {
142
- significand *= 10;
143
- significand += std::uniform_int_distribution<signed_int_t>{1, 9}(rg);
144
- }
145
-
146
- // Generate exponent uniformly randomly
147
- auto exp = std::uniform_int_distribution<int>{
148
- std::numeric_limits<Float>::min_exponent10 - (int(digits) - 1),
149
- std::numeric_limits<Float>::max_exponent10 - (int(digits) - 1)}(rg);
150
-
151
- // Cook up
152
- auto str = std::to_string(sign * significand) + 'e' + std::to_string(exp);
153
-
154
- if constexpr (std::is_same_v<Float, float>) {
155
- result = std::strtof(str.c_str(), nullptr);
156
- }
157
- else {
158
- result = std::strtod(str.c_str(), nullptr);
159
- }
160
-
161
- if (!std::isfinite(result)) {
162
- continue;
163
- }
164
-
165
- // Discard if a shorter representation exists
166
- // We don't need to care about sign and correct rounding here
167
- if (from != 0) {
168
- auto roundtrip = jkj::dragonbox::to_decimal(
169
- result, jkj::dragonbox::policy::sign::ignore,
170
- jkj::dragonbox::policy::decimal_to_binary_rounding::nearest_to_even,
171
- jkj::dragonbox::policy::binary_to_decimal_rounding::do_not_care);
172
- if (roundtrip.significand <= carrier_uint(from * 10)) {
173
- continue;
174
- }
175
- }
176
- break;
177
- }
178
-
179
- return result;
180
- }
181
-
182
- #endif
@@ -1,57 +0,0 @@
1
- // Copyright 2022 Junekey Jeon
2
- //
3
- // The contents of this file may be used under the terms of
4
- // the Apache License v2.0 with LLVM Exceptions.
5
- //
6
- // (See accompanying file LICENSE-Apache or copy at
7
- // https://llvm.org/foundation/relicensing/LICENSE.txt)
8
- //
9
- // Alternatively, the contents of this file may be used under the terms of
10
- // the Boost Software License, Version 1.0.
11
- // (See accompanying file LICENSE-Boost or copy at
12
- // https://www.boost.org/LICENSE_1_0.txt)
13
- //
14
- // Unless required by applicable law or agreed to in writing, this software
15
- // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- // KIND, either express or implied.
17
-
18
- #ifndef JKJ_HEADER_RATIONAL_CONTINUED_FRACTIONS
19
- #define JKJ_HEADER_RATIONAL_CONTINUED_FRACTIONS
20
-
21
- #include "continued_fractions.h"
22
- #include <cassert>
23
- #include <cstdlib>
24
-
25
- namespace jkj {
26
- template <class UInt>
27
- class rational_continued_fractions
28
- : public continued_fractions<rational_continued_fractions<UInt>, UInt> {
29
- using crtp_base = continued_fractions<rational_continued_fractions<UInt>, UInt>;
30
- friend crtp_base;
31
-
32
- UInt prev_error_;
33
- UInt curr_error_;
34
-
35
- UInt compute_next_coefficient() {
36
- using std::div;
37
- auto div_result = div(prev_error_, curr_error_);
38
- prev_error_ = static_cast<UInt&&>(curr_error_);
39
- curr_error_ = static_cast<UInt&&>(div_result.rem);
40
-
41
- if (curr_error_ == 0) {
42
- crtp_base::set_terminate_flag();
43
- }
44
-
45
- return static_cast<UInt&&>(div_result.quot);
46
- }
47
-
48
- public:
49
- rational_continued_fractions(unsigned_rational<UInt> r)
50
- : prev_error_{static_cast<UInt&&>(r.numerator)}, curr_error_{static_cast<UInt&&>(
51
- r.denominator)} {
52
- assert(curr_error_ != 0);
53
- }
54
- };
55
- }
56
-
57
- #endif