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,97 +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_BEST_RATIONAL_APPROX
19
- #define JKJ_HEADER_BEST_RATIONAL_APPROX
20
-
21
- #include "continued_fractions.h"
22
- #include <cassert>
23
- #include <cstdlib>
24
-
25
- namespace jkj {
26
- template <class UInt>
27
- struct best_rational_approx_output {
28
- unsigned_rational<UInt> below;
29
- unsigned_rational<UInt> above;
30
- };
31
-
32
- // Find the best rational approximations from below and from above of denominators no more than
33
- // denominator_upper_bound for the given number x.
34
- template <class ContinuedFractionsImpl, class UInt, class PositiveNumber>
35
- best_rational_approx_output<typename ContinuedFractionsImpl::uint_type>
36
- find_best_rational_approx(PositiveNumber const& x, UInt const& denominator_upper_bound) {
37
- assert(denominator_upper_bound > 0);
38
-
39
- using uint_type = typename ContinuedFractionsImpl::uint_type;
40
- best_rational_approx_output<uint_type> ret_value;
41
-
42
- // Initialize a continued fractions calculator.
43
- ContinuedFractionsImpl cf{x};
44
-
45
- // First, find the last convergent whose denominator is bounded above by the given upper
46
- // bound.
47
- unsigned_rational<uint_type> previous_convergent;
48
- unsigned_rational<uint_type> current_convergent;
49
- do {
50
- previous_convergent = cf.previous_convergent();
51
- current_convergent = cf.current_convergent();
52
-
53
- // Obtain the next convergent.
54
- if (!cf.update()) {
55
- // If there is no more convergents, we already obtained the perfect approximation.
56
- ret_value.below = cf.current_convergent();
57
- ret_value.above = cf.current_convergent();
58
- return ret_value;
59
- }
60
- } while (cf.current_denominator() <= denominator_upper_bound);
61
-
62
- // If the current convergent is of even index,
63
- // then the current convergent is the best approximation from below,
64
- // and the best approximation from above is the last semiconvergent.
65
- // If the current convergent is of odd index, then the other way around.
66
- // Note that cf.current_index() is one larger than the index of the current convergent,
67
- // so we need to reverse the parity.
68
-
69
- auto compute_bounds = [&](auto& major, auto& minor) {
70
- // The current convergent is the best approximation from below.
71
- major = current_convergent;
72
-
73
- // The best approximation from above is the last semiconvergent.
74
- using std::div;
75
- auto semiconvergent_coeff =
76
- div(denominator_upper_bound - previous_convergent.denominator,
77
- current_convergent.denominator)
78
- .quot;
79
-
80
- minor.numerator =
81
- previous_convergent.numerator + semiconvergent_coeff * current_convergent.numerator;
82
- minor.denominator = previous_convergent.denominator +
83
- semiconvergent_coeff * current_convergent.denominator;
84
- };
85
-
86
- if (cf.current_index() % 2 == 1) {
87
- compute_bounds(ret_value.below, ret_value.above);
88
- }
89
- else {
90
- compute_bounds(ret_value.above, ret_value.below);
91
- }
92
-
93
- return ret_value;
94
- }
95
- }
96
-
97
- #endif
@@ -1,218 +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_BIG_UINT
19
- #define JKJ_HEADER_BIG_UINT
20
-
21
- #include <cstddef>
22
- #include <cstdint>
23
- #include <initializer_list>
24
- #include <iterator>
25
- #include <vector>
26
-
27
- namespace jkj {
28
- class big_uint {
29
- public:
30
- using element_type = std::uint64_t;
31
- static constexpr std::size_t element_number_of_bits = 64;
32
-
33
- private:
34
- // Least significant element first.
35
- std::vector<element_type> elements;
36
-
37
- public:
38
- // elements is empty if and only if it represents 0.
39
- big_uint() = default;
40
- big_uint(element_type n) {
41
- if (n != 0) {
42
- elements.push_back(n);
43
- }
44
- }
45
-
46
- // Remove leading zeros.
47
- explicit big_uint(std::initializer_list<element_type> list)
48
- : big_uint(list.begin(), list.end()) {}
49
-
50
- // Remove leading zeros.
51
- template <class Iter, class = typename std::iterator_traits<Iter>::iterator_category>
52
- big_uint(Iter first, Iter last) : elements(first, last) {
53
- auto effective_size = elements.size();
54
- while (effective_size > 0) {
55
- if (elements[effective_size - 1] != 0) {
56
- break;
57
- }
58
- --effective_size;
59
- }
60
- elements.resize(effective_size);
61
- }
62
-
63
- element_type operator[](std::size_t idx) const { return elements[idx]; }
64
-
65
- bool is_zero() const noexcept { return elements.empty(); }
66
- bool is_even() const noexcept {
67
- if (elements.empty()) {
68
- return true;
69
- }
70
- else {
71
- return elements[0] % 2 == 0;
72
- }
73
- }
74
-
75
- friend std::size_t log2p1(big_uint const& n) noexcept;
76
-
77
- static big_uint power_of_2(std::size_t k);
78
- static big_uint pow(big_uint base, std::size_t k);
79
-
80
- // Repeat multiplying 2 until the number becomes bigger than or equal to the given number.
81
- // Returns the number of multiplications, which is ceil(log2(n/*this)).
82
- // Precondition: *this is not zero and n should be bigger than or equal to the current
83
- // number. Note that this function need not require &n != this.
84
- std::size_t multiply_2_until(big_uint const& n);
85
-
86
- // Repeat multiplying 2 while the number becomes less than or equal to the given number.
87
- // Returns the number of multiplications, which is floor(log2(n/*this)).
88
- // Precondition: *this is not zero and n should be bigger than or equal to the current
89
- // number. Note that this function need not require &n != this.
90
- std::size_t multiply_2_while(big_uint const& n);
91
-
92
- void multiply_2() &;
93
- void multiply_5() &;
94
-
95
- bool operator==(big_uint const& n) const noexcept { return elements == n.elements; }
96
- bool operator!=(big_uint const& n) const noexcept { return elements != n.elements; }
97
- bool operator==(element_type n) const noexcept {
98
- return (elements.size() == 0 && n == 0) || (elements.size() == 1 && elements[0] == n);
99
- }
100
- bool operator!=(element_type n) const noexcept {
101
- return (elements.size() == 0 && n != 0) || (elements.size() == 1 && elements[0] != n) ||
102
- (elements.size() > 1);
103
- }
104
-
105
- private:
106
- int comparison_common(big_uint const& n) const noexcept;
107
-
108
- public:
109
- bool operator<(big_uint const& n) const noexcept { return comparison_common(n) < 0; }
110
- bool operator<=(big_uint const& n) const noexcept { return comparison_common(n) <= 0; }
111
- bool operator>(big_uint const& n) const noexcept { return comparison_common(n) > 0; }
112
- bool operator>=(big_uint const& n) const noexcept { return comparison_common(n) >= 0; }
113
-
114
- bool operator<(element_type n) const noexcept {
115
- return (elements.size() == 0 && n != 0) || (elements.size() == 1 && elements[0] < n);
116
- }
117
- bool operator<=(element_type n) const noexcept {
118
- return (elements.size() == 0 && n == 0) || (elements.size() == 1 && elements[0] <= n);
119
- }
120
- bool operator>(element_type n) const noexcept {
121
- return (elements.size() == 1 && elements[0] > n) || (elements.size() > 1);
122
- }
123
- bool operator>=(element_type n) const noexcept {
124
- return (elements.size() == 0 && n == 0) || (elements.size() == 1 && elements[0] >= n) ||
125
- (elements.size() > 1);
126
- }
127
-
128
- big_uint& operator+=(big_uint const& n) &;
129
- big_uint& operator+=(element_type n) &;
130
- template <class T>
131
- big_uint operator+(T const& n) const {
132
- auto r = *this;
133
- return r += n;
134
- }
135
- friend big_uint operator+(element_type n, big_uint const& m) { return m + n; }
136
- big_uint& operator++() & {
137
- *this += 1;
138
- return *this;
139
- }
140
- big_uint operator++(int) & {
141
- auto temp = *this;
142
- *this += 1;
143
- return temp;
144
- }
145
-
146
- // Precondition: n should be strictly smaller than or equal to the current number
147
- big_uint& operator-=(big_uint const& n) &;
148
- big_uint operator-(big_uint const& n) const {
149
- auto r = *this;
150
- return r -= n;
151
- }
152
-
153
- // Precondition: *this should be nonzero
154
- big_uint& operator--() &;
155
-
156
- big_uint& operator*=(element_type n) &;
157
- big_uint operator*(element_type n) {
158
- auto r = *this;
159
- return r *= n;
160
- }
161
- friend big_uint operator*(big_uint const& x, big_uint const& y);
162
- big_uint& operator*=(big_uint const& y) & {
163
- auto result = *this * y;
164
- *this = result;
165
- return *this;
166
- }
167
-
168
- // Perform long division
169
- // *this becomes the remainder, returns the quotient
170
- // Precondition: n != 0
171
- big_uint long_division(big_uint const& n);
172
-
173
- big_uint operator/(big_uint const& n) const {
174
- auto temp = *this;
175
- return temp.long_division(n);
176
- }
177
- big_uint operator/(element_type n) const {
178
- auto temp = *this;
179
- return temp.long_division(n);
180
- }
181
- big_uint operator%(big_uint const& n) const {
182
- auto temp = *this;
183
- temp.long_division(n);
184
- return temp;
185
- }
186
- big_uint operator%(element_type n) const {
187
- auto temp = *this;
188
- temp.long_division(n);
189
- return temp;
190
- }
191
-
192
- // Convert the number into decimal, and returns the
193
- // array of (at most) 19 digits.
194
- std::vector<std::uint64_t> to_decimal() const;
195
- };
196
-
197
- std::size_t log2p1(big_uint const& n) noexcept;
198
- big_uint operator*(big_uint const& x, big_uint const& y);
199
-
200
- struct big_uint_div_t {
201
- big_uint quot;
202
- big_uint rem;
203
- };
204
- inline big_uint_div_t div(big_uint const& x, big_uint const& y) {
205
- big_uint_div_t ret;
206
- ret.rem = x;
207
- ret.quot = ret.rem.long_division(y);
208
- return ret;
209
- }
210
- inline big_uint_div_t div(big_uint&& x, big_uint const& y) {
211
- big_uint_div_t ret;
212
- ret.rem = static_cast<big_uint&&>(x);
213
- ret.quot = ret.rem.long_division(y);
214
- return ret;
215
- }
216
- }
217
-
218
- #endif
@@ -1,174 +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_CONTINUED_FRACTIONS
19
- #define JKJ_HEADER_CONTINUED_FRACTIONS
20
-
21
- namespace jkj {
22
- // Continued fractions calculator for positive numbers.
23
-
24
- template <class UInt>
25
- struct unsigned_rational {
26
- UInt numerator = 0;
27
- UInt denominator = 0;
28
-
29
- unsigned_rational() = default;
30
- unsigned_rational(UInt const& numerator) : numerator{numerator}, denominator{1} {}
31
- unsigned_rational(UInt&& numerator)
32
- : numerator{static_cast<UInt&&>(numerator)}, denominator{1} {}
33
- unsigned_rational(UInt const& numerator, UInt const& denominator)
34
- : numerator{numerator}, denominator{denominator} {}
35
- unsigned_rational(UInt&& numerator, UInt const& denominator)
36
- : numerator{static_cast<UInt&&>(numerator)}, denominator{denominator} {}
37
- unsigned_rational(UInt const& numerator, UInt&& denominator)
38
- : numerator{numerator}, denominator{static_cast<UInt&&>(denominator)} {}
39
- unsigned_rational(UInt&& numerator, UInt&& denominator)
40
- : numerator{static_cast<UInt&&>(numerator)}, denominator{
41
- static_cast<UInt&&>(denominator)} {}
42
-
43
- friend bool operator<(unsigned_rational const& x, unsigned_rational const& y) {
44
- return x.numerator * y.denominator < y.numerator * x.denominator;
45
- }
46
- friend bool operator<=(unsigned_rational const& x, unsigned_rational const& y) {
47
- return x.numerator * y.denominator <= y.numerator * x.denominator;
48
- }
49
- friend bool operator>(unsigned_rational const& x, unsigned_rational const& y) {
50
- return x.numerator * y.denominator > y.numerator * x.denominator;
51
- }
52
- friend bool operator>=(unsigned_rational const& x, unsigned_rational const& y) {
53
- return x.numerator * y.denominator >= y.numerator * x.denominator;
54
- }
55
- friend bool operator==(unsigned_rational const& x, unsigned_rational const& y) {
56
- return x.numerator * y.denominator == y.numerator * x.denominator;
57
- }
58
- friend bool operator!=(unsigned_rational const& x, unsigned_rational const& y) {
59
- return x.numerator * y.denominator != y.numerator * x.denominator;
60
- }
61
-
62
- // Performs no reduction.
63
- friend unsigned_rational operator+(unsigned_rational const& x, unsigned_rational const& y) {
64
- return {x.numerator * y.denominator + y.numerator * x.denominator,
65
- x.denominator * y.denominator};
66
- }
67
- // Performs no reduction.
68
- unsigned_rational& operator+=(unsigned_rational const& y) & {
69
- numerator *= y.denominator;
70
- numerator += y.numerator * denominator;
71
- denominator *= y.denominator;
72
- return *this;
73
- }
74
- // Performs no reduction.
75
- friend unsigned_rational operator-(unsigned_rational const& x, unsigned_rational const& y) {
76
- return {x.numerator * y.denominator - y.numerator * x.denominator,
77
- x.denominator * y.denominator};
78
- }
79
- // Performs no reduction.
80
- unsigned_rational& operator-=(unsigned_rational const& y) & {
81
- numerator *= y.denominator;
82
- numerator -= y.numerator * denominator;
83
- denominator *= y.denominator;
84
- return *this;
85
- }
86
- // Performs no reduction.
87
- friend unsigned_rational operator*(unsigned_rational const& x, unsigned_rational const& y) {
88
- return {x.numerator * y.numerator, x.denominator * y.denominator};
89
- }
90
- // Performs no reduction.
91
- unsigned_rational& operator*=(unsigned_rational const& y) & {
92
- numerator *= y.numerator;
93
- denominator *= y.denominator;
94
- return *this;
95
- }
96
- // Performs no reduction.
97
- friend unsigned_rational operator/(unsigned_rational const& x, unsigned_rational const& y) {
98
- return {x.numerator * y.denominator, x.denominator * y.numerator};
99
- }
100
- // Performs no reduction.
101
- unsigned_rational& operator/=(unsigned_rational const& y) & {
102
- numerator *= y.denominator;
103
- denominator *= y.numerator;
104
- return *this;
105
- }
106
- };
107
-
108
- template <class Impl, class UInt>
109
- class continued_fractions {
110
- // The (-1)st coefficient is assumed to be 0.
111
- UInt current_coefficient_{0};
112
- unsigned_rational<UInt> current_convergent_{1, 0};
113
- unsigned_rational<UInt> previous_convergent_{0, 1};
114
- int current_index_ = -1;
115
- bool terminated_ = false;
116
-
117
- protected:
118
- void set_terminate_flag() noexcept { terminated_ = true; }
119
-
120
- public:
121
- using uint_type = UInt;
122
-
123
- int current_index() const noexcept { return current_index_; }
124
-
125
- UInt const& current_coefficient() const noexcept { return current_coefficient_; }
126
-
127
- unsigned_rational<UInt> const& current_convergent() const noexcept {
128
- return current_convergent_;
129
- }
130
-
131
- UInt const& current_numerator() const noexcept { return current_convergent().numerator; }
132
-
133
- UInt const& current_denominator() const noexcept {
134
- return current_convergent().denominator;
135
- }
136
-
137
- unsigned_rational<UInt> const& previous_convergent() const noexcept {
138
- return previous_convergent_;
139
- }
140
-
141
- UInt const& previous_numerator() const noexcept { return previous_convergent().numerator; }
142
-
143
- UInt const& previous_denominator() const noexcept {
144
- return previous_convergent().denominator;
145
- }
146
-
147
- bool is_terminated() const noexcept { return terminated_; }
148
-
149
- // Do nothing if the procedure is terminated.
150
- // Returns true if the update is done,
151
- // and returns false if the procedure is already terminated.
152
- bool update() {
153
- if (!is_terminated()) {
154
- unsigned_rational<UInt> new_output;
155
- current_coefficient_ = static_cast<Impl&>(*this).compute_next_coefficient();
156
-
157
- unsigned_rational<UInt> new_convergent{
158
- previous_numerator() + current_coefficient_ * current_numerator(),
159
- previous_denominator() + current_coefficient_ * current_denominator()};
160
- previous_convergent_ = static_cast<unsigned_rational<UInt>&&>(current_convergent_);
161
- current_convergent_ = static_cast<unsigned_rational<UInt>&&>(new_convergent);
162
-
163
- ++current_index_;
164
-
165
- return true;
166
- }
167
- else {
168
- return false;
169
- }
170
- }
171
- };
172
- }
173
-
174
- #endif