usearch 2.21.4 → 2.25.0

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 (602) hide show
  1. package/README.md +24 -24
  2. package/binding.gyp +15 -37
  3. package/c/CMakeLists.txt +4 -5
  4. package/c/README.md +7 -7
  5. package/c/lib.cpp +32 -14
  6. package/c/test.c +83 -1
  7. package/c/usearch.h +24 -3
  8. package/cpp/CMakeLists.txt +4 -0
  9. package/cpp/README.md +5 -5
  10. package/cpp/bench.cpp +97 -116
  11. package/cpp/test.cpp +117 -20
  12. package/include/usearch/index.hpp +224 -48
  13. package/include/usearch/index_dense.hpp +105 -40
  14. package/include/usearch/index_plugins.hpp +1387 -204
  15. package/javascript/dist/cjs/usearch.d.ts +8 -3
  16. package/javascript/dist/cjs/usearch.js +12 -4
  17. package/javascript/dist/esm/usearch.d.ts +8 -3
  18. package/javascript/dist/esm/usearch.js +12 -4
  19. package/javascript/lib.cpp +17 -0
  20. package/javascript/usearch.ts +14 -6
  21. package/numkong/.clang-tidy +30 -0
  22. package/{simsimd → numkong}/.cmake-format.py +18 -0
  23. package/numkong/.editorconfig +12 -0
  24. package/numkong/.git-blame-ignore-revs +123 -0
  25. package/numkong/.mailmap +15 -0
  26. package/numkong/.spi.yml +11 -0
  27. package/numkong/.swift-format +14 -0
  28. package/numkong/CITATION.cff +81 -0
  29. package/numkong/CONTRIBUTING.md +500 -0
  30. package/numkong/Cargo.toml +54 -0
  31. package/numkong/MANIFEST.in +8 -0
  32. package/numkong/Package.swift +84 -0
  33. package/numkong/README.md +569 -0
  34. package/numkong/bench/README.md +217 -0
  35. package/numkong/bench/bench-browser.html +323 -0
  36. package/numkong/bench/bench.cpp +344 -0
  37. package/numkong/bench/bench.hpp +816 -0
  38. package/numkong/bench/bench.js +148 -0
  39. package/numkong/bench/bench.mjs +616 -0
  40. package/numkong/bench/bench_attention.cpp +113 -0
  41. package/numkong/bench/bench_cast.cpp +264 -0
  42. package/numkong/bench/bench_cross_amx.cpp +62 -0
  43. package/numkong/bench/bench_cross_arm.cpp +245 -0
  44. package/numkong/bench/bench_cross_blas.cpp +309 -0
  45. package/numkong/bench/bench_cross_loongarch.cpp +106 -0
  46. package/numkong/bench/bench_cross_power.cpp +84 -0
  47. package/numkong/bench/bench_cross_rvv.cpp +121 -0
  48. package/numkong/bench/bench_cross_serial.cpp +151 -0
  49. package/numkong/bench/bench_cross_sme.cpp +163 -0
  50. package/numkong/bench/bench_cross_wasm.cpp +142 -0
  51. package/numkong/bench/bench_cross_x86.cpp +455 -0
  52. package/numkong/bench/bench_curved.cpp +210 -0
  53. package/numkong/bench/bench_dot.cpp +315 -0
  54. package/numkong/bench/bench_each.cpp +503 -0
  55. package/numkong/bench/bench_geospatial.cpp +112 -0
  56. package/numkong/bench/bench_maxsim.cpp +154 -0
  57. package/numkong/bench/bench_mesh.cpp +148 -0
  58. package/numkong/bench/bench_probability.cpp +60 -0
  59. package/numkong/bench/bench_reduce.cpp +371 -0
  60. package/numkong/bench/bench_set.cpp +73 -0
  61. package/numkong/bench/bench_sparse.cpp +198 -0
  62. package/numkong/bench/bench_spatial.cpp +347 -0
  63. package/numkong/bench/bench_trigonometry.cpp +137 -0
  64. package/numkong/bench/swift/Bench.swift +506 -0
  65. package/numkong/binding.gyp +169 -0
  66. package/numkong/build.rs +484 -0
  67. package/numkong/c/dispatch.h +512 -0
  68. package/numkong/c/dispatch_bf16.c +447 -0
  69. package/numkong/c/dispatch_bf16c.c +52 -0
  70. package/numkong/c/dispatch_e2m3.c +296 -0
  71. package/numkong/c/dispatch_e3m2.c +284 -0
  72. package/numkong/c/dispatch_e4m3.c +318 -0
  73. package/numkong/c/dispatch_e5m2.c +316 -0
  74. package/numkong/c/dispatch_f16.c +452 -0
  75. package/numkong/c/dispatch_f16c.c +58 -0
  76. package/numkong/c/dispatch_f32.c +434 -0
  77. package/numkong/c/dispatch_f32c.c +99 -0
  78. package/numkong/c/dispatch_f64.c +348 -0
  79. package/numkong/c/dispatch_f64c.c +98 -0
  80. package/numkong/c/dispatch_i16.c +96 -0
  81. package/numkong/c/dispatch_i32.c +89 -0
  82. package/numkong/c/dispatch_i4.c +153 -0
  83. package/numkong/c/dispatch_i64.c +86 -0
  84. package/numkong/c/dispatch_i8.c +348 -0
  85. package/numkong/c/dispatch_other.c +348 -0
  86. package/numkong/c/dispatch_u1.c +193 -0
  87. package/numkong/c/dispatch_u16.c +124 -0
  88. package/numkong/c/dispatch_u32.c +118 -0
  89. package/numkong/c/dispatch_u4.c +153 -0
  90. package/numkong/c/dispatch_u64.c +102 -0
  91. package/numkong/c/dispatch_u8.c +364 -0
  92. package/numkong/c/numkong.c +940 -0
  93. package/numkong/cmake/nk_arm_isa_probes.cmake +61 -0
  94. package/numkong/cmake/nk_isa_probe.cmake +90 -0
  95. package/numkong/cmake/nk_loongarch_isa_probes.cmake +15 -0
  96. package/numkong/cmake/nk_math_lib.cmake +46 -0
  97. package/numkong/cmake/nk_power_isa_probes.cmake +15 -0
  98. package/numkong/cmake/nk_riscv_isa_probes.cmake +19 -0
  99. package/numkong/cmake/nk_x86_isa_probes.cmake +35 -0
  100. package/numkong/cmake/toolchain-aarch64-gnu.cmake +86 -0
  101. package/numkong/cmake/toolchain-android-arm64.cmake +25 -0
  102. package/numkong/cmake/toolchain-android-armv7.cmake +25 -0
  103. package/numkong/cmake/toolchain-loongarch64-gnu.cmake +68 -0
  104. package/numkong/cmake/toolchain-ppc64le-gnu.cmake +74 -0
  105. package/numkong/cmake/toolchain-riscv64-gnu.cmake +107 -0
  106. package/numkong/cmake/toolchain-riscv64-llvm.cmake +114 -0
  107. package/numkong/cmake/toolchain-wasi.cmake +77 -0
  108. package/numkong/cmake/toolchain-wasm.cmake +70 -0
  109. package/numkong/cmake/toolchain-wasm64.cmake +62 -0
  110. package/numkong/cmake/toolchain-x86_64-llvm.cmake +47 -0
  111. package/numkong/include/README.md +643 -0
  112. package/numkong/include/module.modulemap +129 -0
  113. package/numkong/include/numkong/attention/sapphireamx.h +1363 -0
  114. package/numkong/include/numkong/attention/sme.h +2075 -0
  115. package/numkong/include/numkong/attention.h +49 -0
  116. package/numkong/include/numkong/capabilities.h +930 -0
  117. package/numkong/include/numkong/cast/README.md +262 -0
  118. package/numkong/include/numkong/cast/diamond.h +64 -0
  119. package/numkong/include/numkong/cast/haswell.h +823 -0
  120. package/numkong/include/numkong/cast/icelake.h +475 -0
  121. package/numkong/include/numkong/cast/loongsonasx.h +252 -0
  122. package/numkong/include/numkong/cast/neon.h +1174 -0
  123. package/numkong/include/numkong/cast/powervsx.h +449 -0
  124. package/numkong/include/numkong/cast/rvv.h +970 -0
  125. package/numkong/include/numkong/cast/sapphire.h +262 -0
  126. package/numkong/include/numkong/cast/serial.h +2336 -0
  127. package/numkong/include/numkong/cast/skylake.h +915 -0
  128. package/numkong/include/numkong/cast/v128relaxed.h +537 -0
  129. package/numkong/include/numkong/cast.h +254 -0
  130. package/numkong/include/numkong/cast.hpp +44 -0
  131. package/numkong/include/numkong/curved/README.md +223 -0
  132. package/numkong/include/numkong/curved/genoa.h +182 -0
  133. package/numkong/include/numkong/curved/haswell.h +276 -0
  134. package/numkong/include/numkong/curved/neon.h +329 -0
  135. package/numkong/include/numkong/curved/neonbfdot.h +211 -0
  136. package/numkong/include/numkong/curved/rvv.h +305 -0
  137. package/numkong/include/numkong/curved/serial.h +207 -0
  138. package/numkong/include/numkong/curved/skylake.h +457 -0
  139. package/numkong/include/numkong/curved/smef64.h +530 -0
  140. package/numkong/include/numkong/curved.h +513 -0
  141. package/numkong/include/numkong/curved.hpp +144 -0
  142. package/numkong/include/numkong/dot/README.md +442 -0
  143. package/numkong/include/numkong/dot/alder.h +563 -0
  144. package/numkong/include/numkong/dot/diamond.h +158 -0
  145. package/numkong/include/numkong/dot/genoa.h +289 -0
  146. package/numkong/include/numkong/dot/haswell.h +1723 -0
  147. package/numkong/include/numkong/dot/icelake.h +997 -0
  148. package/numkong/include/numkong/dot/loongsonasx.h +671 -0
  149. package/numkong/include/numkong/dot/neon.h +869 -0
  150. package/numkong/include/numkong/dot/neonbfdot.h +243 -0
  151. package/numkong/include/numkong/dot/neonfhm.h +358 -0
  152. package/numkong/include/numkong/dot/neonfp8.h +323 -0
  153. package/numkong/include/numkong/dot/neonsdot.h +622 -0
  154. package/numkong/include/numkong/dot/powervsx.h +752 -0
  155. package/numkong/include/numkong/dot/rvv.h +722 -0
  156. package/numkong/include/numkong/dot/rvvbb.h +72 -0
  157. package/numkong/include/numkong/dot/rvvbf16.h +123 -0
  158. package/numkong/include/numkong/dot/rvvhalf.h +129 -0
  159. package/numkong/include/numkong/dot/sapphire.h +141 -0
  160. package/numkong/include/numkong/dot/serial.h +874 -0
  161. package/numkong/include/numkong/dot/sierra.h +405 -0
  162. package/numkong/include/numkong/dot/skylake.h +1116 -0
  163. package/numkong/include/numkong/dot/sve.h +420 -0
  164. package/numkong/include/numkong/dot/svebfdot.h +75 -0
  165. package/numkong/include/numkong/dot/svehalf.h +168 -0
  166. package/numkong/include/numkong/dot/svesdot.h +90 -0
  167. package/numkong/include/numkong/dot/v128relaxed.h +1293 -0
  168. package/numkong/include/numkong/dot.h +1136 -0
  169. package/numkong/include/numkong/dot.hpp +94 -0
  170. package/numkong/include/numkong/dots/README.md +496 -0
  171. package/numkong/include/numkong/dots/alder.h +117 -0
  172. package/numkong/include/numkong/dots/diamond.h +86 -0
  173. package/numkong/include/numkong/dots/genoa.h +100 -0
  174. package/numkong/include/numkong/dots/graniteamx.h +733 -0
  175. package/numkong/include/numkong/dots/haswell.h +310 -0
  176. package/numkong/include/numkong/dots/icelake.h +180 -0
  177. package/numkong/include/numkong/dots/loongsonasx.h +176 -0
  178. package/numkong/include/numkong/dots/neon.h +123 -0
  179. package/numkong/include/numkong/dots/neonbfdot.h +59 -0
  180. package/numkong/include/numkong/dots/neonfhm.h +96 -0
  181. package/numkong/include/numkong/dots/neonfp8.h +99 -0
  182. package/numkong/include/numkong/dots/neonsdot.h +144 -0
  183. package/numkong/include/numkong/dots/powervsx.h +194 -0
  184. package/numkong/include/numkong/dots/rvv.h +2593 -0
  185. package/numkong/include/numkong/dots/sapphireamx.h +4017 -0
  186. package/numkong/include/numkong/dots/serial.h +2867 -0
  187. package/numkong/include/numkong/dots/sierra.h +100 -0
  188. package/numkong/include/numkong/dots/skylake.h +207 -0
  189. package/numkong/include/numkong/dots/sme.h +5041 -0
  190. package/numkong/include/numkong/dots/smebi32.h +477 -0
  191. package/numkong/include/numkong/dots/smef64.h +1328 -0
  192. package/numkong/include/numkong/dots/smehalf.h +47 -0
  193. package/numkong/include/numkong/dots/v128relaxed.h +317 -0
  194. package/numkong/include/numkong/dots.h +3110 -0
  195. package/numkong/include/numkong/dots.hpp +641 -0
  196. package/numkong/include/numkong/each/README.md +465 -0
  197. package/numkong/include/numkong/each/haswell.h +1658 -0
  198. package/numkong/include/numkong/each/icelake.h +272 -0
  199. package/numkong/include/numkong/each/neon.h +1138 -0
  200. package/numkong/include/numkong/each/neonbfdot.h +211 -0
  201. package/numkong/include/numkong/each/neonhalf.h +318 -0
  202. package/numkong/include/numkong/each/rvv.h +1121 -0
  203. package/numkong/include/numkong/each/sapphire.h +343 -0
  204. package/numkong/include/numkong/each/serial.h +282 -0
  205. package/numkong/include/numkong/each/skylake.h +1562 -0
  206. package/numkong/include/numkong/each/v128relaxed.h +562 -0
  207. package/numkong/include/numkong/each.h +2232 -0
  208. package/numkong/include/numkong/each.hpp +434 -0
  209. package/numkong/include/numkong/geospatial/README.md +147 -0
  210. package/numkong/include/numkong/geospatial/haswell.h +633 -0
  211. package/numkong/include/numkong/geospatial/neon.h +615 -0
  212. package/numkong/include/numkong/geospatial/rvv.h +701 -0
  213. package/numkong/include/numkong/geospatial/serial.h +309 -0
  214. package/numkong/include/numkong/geospatial/skylake.h +613 -0
  215. package/numkong/include/numkong/geospatial/v128relaxed.h +652 -0
  216. package/numkong/include/numkong/geospatial.h +453 -0
  217. package/numkong/include/numkong/geospatial.hpp +235 -0
  218. package/numkong/include/numkong/matrix.hpp +336 -0
  219. package/numkong/include/numkong/maxsim/README.md +187 -0
  220. package/numkong/include/numkong/maxsim/alder.h +511 -0
  221. package/numkong/include/numkong/maxsim/genoa.h +115 -0
  222. package/numkong/include/numkong/maxsim/haswell.h +553 -0
  223. package/numkong/include/numkong/maxsim/icelake.h +480 -0
  224. package/numkong/include/numkong/maxsim/neonsdot.h +394 -0
  225. package/numkong/include/numkong/maxsim/sapphireamx.h +877 -0
  226. package/numkong/include/numkong/maxsim/serial.h +490 -0
  227. package/numkong/include/numkong/maxsim/sme.h +993 -0
  228. package/numkong/include/numkong/maxsim/v128relaxed.h +280 -0
  229. package/numkong/include/numkong/maxsim.h +571 -0
  230. package/numkong/include/numkong/maxsim.hpp +133 -0
  231. package/numkong/include/numkong/mesh/README.md +219 -0
  232. package/numkong/include/numkong/mesh/haswell.h +2013 -0
  233. package/numkong/include/numkong/mesh/neon.h +1821 -0
  234. package/numkong/include/numkong/mesh/neonbfdot.h +771 -0
  235. package/numkong/include/numkong/mesh/rvv.h +936 -0
  236. package/numkong/include/numkong/mesh/serial.h +721 -0
  237. package/numkong/include/numkong/mesh/skylake.h +2344 -0
  238. package/numkong/include/numkong/mesh/v128relaxed.h +1081 -0
  239. package/numkong/include/numkong/mesh.h +666 -0
  240. package/numkong/include/numkong/mesh.hpp +701 -0
  241. package/numkong/include/numkong/numkong.h +78 -0
  242. package/numkong/include/numkong/numkong.hpp +58 -0
  243. package/numkong/include/numkong/probability/README.md +177 -0
  244. package/numkong/include/numkong/probability/haswell.h +267 -0
  245. package/numkong/include/numkong/probability/neon.h +255 -0
  246. package/numkong/include/numkong/probability/rvv.h +414 -0
  247. package/numkong/include/numkong/probability/serial.h +181 -0
  248. package/numkong/include/numkong/probability/skylake.h +324 -0
  249. package/numkong/include/numkong/probability.h +380 -0
  250. package/numkong/include/numkong/probability.hpp +120 -0
  251. package/numkong/include/numkong/random.h +50 -0
  252. package/numkong/include/numkong/random.hpp +285 -0
  253. package/numkong/include/numkong/reduce/README.md +552 -0
  254. package/numkong/include/numkong/reduce/alder.h +636 -0
  255. package/numkong/include/numkong/reduce/genoa.h +201 -0
  256. package/numkong/include/numkong/reduce/haswell.h +3785 -0
  257. package/numkong/include/numkong/reduce/icelake.h +549 -0
  258. package/numkong/include/numkong/reduce/neon.h +3980 -0
  259. package/numkong/include/numkong/reduce/neonbfdot.h +142 -0
  260. package/numkong/include/numkong/reduce/neonfhm.h +293 -0
  261. package/numkong/include/numkong/reduce/neonsdot.h +357 -0
  262. package/numkong/include/numkong/reduce/rvv.h +3533 -0
  263. package/numkong/include/numkong/reduce/serial.h +753 -0
  264. package/numkong/include/numkong/reduce/sierra.h +338 -0
  265. package/numkong/include/numkong/reduce/skylake.h +3794 -0
  266. package/numkong/include/numkong/reduce/sve.h +52 -0
  267. package/numkong/include/numkong/reduce/v128relaxed.h +2302 -0
  268. package/numkong/include/numkong/reduce.h +1582 -0
  269. package/numkong/include/numkong/reduce.hpp +778 -0
  270. package/numkong/include/numkong/scalar/README.md +89 -0
  271. package/numkong/include/numkong/scalar/haswell.h +122 -0
  272. package/numkong/include/numkong/scalar/loongsonasx.h +74 -0
  273. package/numkong/include/numkong/scalar/neon.h +122 -0
  274. package/numkong/include/numkong/scalar/neonhalf.h +70 -0
  275. package/numkong/include/numkong/scalar/powervsx.h +96 -0
  276. package/numkong/include/numkong/scalar/rvv.h +211 -0
  277. package/numkong/include/numkong/scalar/sapphire.h +74 -0
  278. package/numkong/include/numkong/scalar/serial.h +332 -0
  279. package/numkong/include/numkong/scalar/v128relaxed.h +56 -0
  280. package/numkong/include/numkong/scalar.h +696 -0
  281. package/numkong/include/numkong/set/README.md +179 -0
  282. package/numkong/include/numkong/set/haswell.h +334 -0
  283. package/numkong/include/numkong/set/icelake.h +485 -0
  284. package/numkong/include/numkong/set/loongsonasx.h +181 -0
  285. package/numkong/include/numkong/set/neon.h +363 -0
  286. package/numkong/include/numkong/set/powervsx.h +326 -0
  287. package/numkong/include/numkong/set/rvv.h +226 -0
  288. package/numkong/include/numkong/set/rvvbb.h +117 -0
  289. package/numkong/include/numkong/set/serial.h +174 -0
  290. package/numkong/include/numkong/set/sve.h +187 -0
  291. package/numkong/include/numkong/set/v128relaxed.h +240 -0
  292. package/numkong/include/numkong/set.h +471 -0
  293. package/numkong/include/numkong/set.hpp +114 -0
  294. package/numkong/include/numkong/sets/README.md +149 -0
  295. package/numkong/include/numkong/sets/haswell.h +63 -0
  296. package/numkong/include/numkong/sets/icelake.h +66 -0
  297. package/numkong/include/numkong/sets/loongsonasx.h +52 -0
  298. package/numkong/include/numkong/sets/neon.h +61 -0
  299. package/numkong/include/numkong/sets/powervsx.h +65 -0
  300. package/numkong/include/numkong/sets/serial.h +43 -0
  301. package/numkong/include/numkong/sets/smebi32.h +1135 -0
  302. package/numkong/include/numkong/sets/v128relaxed.h +58 -0
  303. package/numkong/include/numkong/sets.h +382 -0
  304. package/numkong/include/numkong/sparse/README.md +156 -0
  305. package/numkong/include/numkong/sparse/icelake.h +463 -0
  306. package/numkong/include/numkong/sparse/neon.h +288 -0
  307. package/numkong/include/numkong/sparse/serial.h +117 -0
  308. package/numkong/include/numkong/sparse/sve2.h +504 -0
  309. package/numkong/include/numkong/sparse/turin.h +322 -0
  310. package/numkong/include/numkong/sparse.h +363 -0
  311. package/numkong/include/numkong/sparse.hpp +113 -0
  312. package/numkong/include/numkong/spatial/README.md +439 -0
  313. package/numkong/include/numkong/spatial/alder.h +604 -0
  314. package/numkong/include/numkong/spatial/diamond.h +240 -0
  315. package/numkong/include/numkong/spatial/genoa.h +222 -0
  316. package/numkong/include/numkong/spatial/haswell.h +979 -0
  317. package/numkong/include/numkong/spatial/icelake.h +1067 -0
  318. package/numkong/include/numkong/spatial/loongsonasx.h +483 -0
  319. package/numkong/include/numkong/spatial/neon.h +846 -0
  320. package/numkong/include/numkong/spatial/neonbfdot.h +164 -0
  321. package/numkong/include/numkong/spatial/neonfp8.h +258 -0
  322. package/numkong/include/numkong/spatial/neonsdot.h +429 -0
  323. package/numkong/include/numkong/spatial/powervsx.h +738 -0
  324. package/numkong/include/numkong/spatial/rvv.h +991 -0
  325. package/numkong/include/numkong/spatial/rvvbf16.h +128 -0
  326. package/numkong/include/numkong/spatial/rvvhalf.h +120 -0
  327. package/numkong/include/numkong/spatial/serial.h +347 -0
  328. package/numkong/include/numkong/spatial/sierra.h +516 -0
  329. package/numkong/include/numkong/spatial/skylake.h +605 -0
  330. package/numkong/include/numkong/spatial/sve.h +246 -0
  331. package/numkong/include/numkong/spatial/svebfdot.h +125 -0
  332. package/numkong/include/numkong/spatial/svehalf.h +136 -0
  333. package/numkong/include/numkong/spatial/svesdot.h +143 -0
  334. package/numkong/include/numkong/spatial/v128relaxed.h +969 -0
  335. package/numkong/include/numkong/spatial.h +1681 -0
  336. package/numkong/include/numkong/spatial.hpp +183 -0
  337. package/numkong/include/numkong/spatials/README.md +580 -0
  338. package/numkong/include/numkong/spatials/alder.h +94 -0
  339. package/numkong/include/numkong/spatials/diamond.h +82 -0
  340. package/numkong/include/numkong/spatials/genoa.h +94 -0
  341. package/numkong/include/numkong/spatials/graniteamx.h +173 -0
  342. package/numkong/include/numkong/spatials/haswell.h +219 -0
  343. package/numkong/include/numkong/spatials/icelake.h +113 -0
  344. package/numkong/include/numkong/spatials/loongsonasx.h +153 -0
  345. package/numkong/include/numkong/spatials/neon.h +109 -0
  346. package/numkong/include/numkong/spatials/neonbfdot.h +60 -0
  347. package/numkong/include/numkong/spatials/neonfhm.h +92 -0
  348. package/numkong/include/numkong/spatials/neonfp8.h +111 -0
  349. package/numkong/include/numkong/spatials/neonsdot.h +143 -0
  350. package/numkong/include/numkong/spatials/powervsx.h +153 -0
  351. package/numkong/include/numkong/spatials/rvv.h +1976 -0
  352. package/numkong/include/numkong/spatials/sapphireamx.h +1149 -0
  353. package/numkong/include/numkong/spatials/serial.h +248 -0
  354. package/numkong/include/numkong/spatials/sierra.h +96 -0
  355. package/numkong/include/numkong/spatials/skylake.h +184 -0
  356. package/numkong/include/numkong/spatials/sme.h +1927 -0
  357. package/numkong/include/numkong/spatials/smef64.h +483 -0
  358. package/numkong/include/numkong/spatials/v128relaxed.h +240 -0
  359. package/numkong/include/numkong/spatials.h +3374 -0
  360. package/numkong/include/numkong/spatials.hpp +509 -0
  361. package/numkong/include/numkong/tensor.hpp +1981 -0
  362. package/numkong/include/numkong/trigonometry/README.md +184 -0
  363. package/numkong/include/numkong/trigonometry/haswell.h +653 -0
  364. package/numkong/include/numkong/trigonometry/neon.h +638 -0
  365. package/numkong/include/numkong/trigonometry/rvv.h +700 -0
  366. package/numkong/include/numkong/trigonometry/serial.h +703 -0
  367. package/numkong/include/numkong/trigonometry/skylake.h +725 -0
  368. package/numkong/include/numkong/trigonometry/v128relaxed.h +667 -0
  369. package/numkong/include/numkong/trigonometry.h +467 -0
  370. package/numkong/include/numkong/trigonometry.hpp +166 -0
  371. package/numkong/include/numkong/types.h +1695 -0
  372. package/numkong/include/numkong/types.hpp +6027 -0
  373. package/numkong/include/numkong/vector.hpp +766 -0
  374. package/numkong/javascript/@numkong-darwin-arm64/package.json +26 -0
  375. package/numkong/javascript/@numkong-darwin-x64/package.json +26 -0
  376. package/numkong/javascript/@numkong-linux-arm64/package.json +25 -0
  377. package/numkong/javascript/@numkong-linux-x64/package.json +25 -0
  378. package/numkong/javascript/@numkong-win32-arm64/package.json +25 -0
  379. package/numkong/javascript/@numkong-win32-x64/package.json +25 -0
  380. package/numkong/javascript/README.md +254 -0
  381. package/numkong/javascript/node-gyp-build.d.ts +4 -0
  382. package/numkong/javascript/numkong-browser.ts +40 -0
  383. package/numkong/javascript/numkong-wasm.ts +750 -0
  384. package/numkong/javascript/numkong.c +712 -0
  385. package/numkong/javascript/numkong.ts +613 -0
  386. package/{simsimd → numkong}/javascript/tsconfig-base.json +6 -3
  387. package/numkong/javascript/tsconfig-cjs.json +13 -0
  388. package/{simsimd → numkong}/javascript/tsconfig-esm.json +1 -1
  389. package/numkong/javascript/types.ts +784 -0
  390. package/numkong/numkong.gypi +104 -0
  391. package/numkong/package.json +108 -0
  392. package/numkong/probes/arm_neon.c +8 -0
  393. package/numkong/probes/arm_neon_bfdot.c +9 -0
  394. package/numkong/probes/arm_neon_fhm.c +9 -0
  395. package/numkong/probes/arm_neon_half.c +8 -0
  396. package/numkong/probes/arm_neon_sdot.c +9 -0
  397. package/numkong/probes/arm_neonfp8.c +9 -0
  398. package/numkong/probes/arm_sme.c +16 -0
  399. package/numkong/probes/arm_sme2.c +16 -0
  400. package/numkong/probes/arm_sme2p1.c +16 -0
  401. package/numkong/probes/arm_sme_bf16.c +16 -0
  402. package/numkong/probes/arm_sme_bi32.c +16 -0
  403. package/numkong/probes/arm_sme_f64.c +16 -0
  404. package/numkong/probes/arm_sme_fa64.c +14 -0
  405. package/numkong/probes/arm_sme_half.c +16 -0
  406. package/numkong/probes/arm_sme_lut2.c +15 -0
  407. package/numkong/probes/arm_sve.c +18 -0
  408. package/numkong/probes/arm_sve2.c +20 -0
  409. package/numkong/probes/arm_sve2p1.c +18 -0
  410. package/numkong/probes/arm_sve_bfdot.c +20 -0
  411. package/numkong/probes/arm_sve_half.c +18 -0
  412. package/numkong/probes/arm_sve_sdot.c +21 -0
  413. package/numkong/probes/loongarch_lasx.c +12 -0
  414. package/numkong/probes/power_vsx.c +12 -0
  415. package/numkong/probes/probe.js +127 -0
  416. package/numkong/probes/riscv_rvv.c +14 -0
  417. package/numkong/probes/riscv_rvv_bb.c +15 -0
  418. package/numkong/probes/riscv_rvv_bf16.c +17 -0
  419. package/numkong/probes/riscv_rvv_half.c +14 -0
  420. package/numkong/probes/wasm_v128relaxed.c +11 -0
  421. package/numkong/probes/x86_alder.c +17 -0
  422. package/numkong/probes/x86_diamond.c +17 -0
  423. package/numkong/probes/x86_genoa.c +17 -0
  424. package/numkong/probes/x86_graniteamx.c +19 -0
  425. package/numkong/probes/x86_haswell.c +11 -0
  426. package/numkong/probes/x86_icelake.c +17 -0
  427. package/numkong/probes/x86_sapphire.c +16 -0
  428. package/numkong/probes/x86_sapphireamx.c +18 -0
  429. package/numkong/probes/x86_sierra.c +17 -0
  430. package/numkong/probes/x86_skylake.c +15 -0
  431. package/numkong/probes/x86_turin.c +17 -0
  432. package/numkong/rust/README.md +698 -0
  433. package/numkong/rust/capabilities.rs +96 -0
  434. package/numkong/rust/cast.rs +314 -0
  435. package/numkong/rust/curved.rs +391 -0
  436. package/numkong/rust/each.rs +2721 -0
  437. package/numkong/rust/geospatial.rs +343 -0
  438. package/numkong/rust/matrix.rs +5424 -0
  439. package/numkong/rust/maxsim.rs +540 -0
  440. package/numkong/rust/mesh.rs +837 -0
  441. package/numkong/rust/numkong.rs +409 -0
  442. package/numkong/rust/probability.rs +272 -0
  443. package/numkong/rust/reduce.rs +1249 -0
  444. package/numkong/rust/set.rs +194 -0
  445. package/numkong/rust/sparse.rs +513 -0
  446. package/numkong/rust/spatial.rs +1815 -0
  447. package/numkong/rust/tensor.rs +7565 -0
  448. package/numkong/rust/types.rs +3666 -0
  449. package/numkong/rust/vector.rs +1899 -0
  450. package/numkong/rustfmt.toml +2 -0
  451. package/numkong/swift/Matrix.swift +1388 -0
  452. package/numkong/swift/MaxSim.swift +151 -0
  453. package/numkong/swift/NumKong.swift +283 -0
  454. package/numkong/swift/Numerics.swift +329 -0
  455. package/numkong/swift/README.md +433 -0
  456. package/numkong/swift/Scalar.swift +741 -0
  457. package/numkong/swift/Tensor.swift +209 -0
  458. package/numkong/test/README.md +315 -0
  459. package/numkong/test/playwright.config.ts +16 -0
  460. package/numkong/test/swift/Test.swift +534 -0
  461. package/numkong/test/test-browser-bundle-runner.mjs +36 -0
  462. package/numkong/test/test-browser-bundle.html +188 -0
  463. package/numkong/test/test-browser-runner.mjs +43 -0
  464. package/numkong/test/test-browser.html +305 -0
  465. package/numkong/test/test-dtypes.mjs +453 -0
  466. package/numkong/test/test-wasm.mjs +267 -0
  467. package/numkong/test/test.cpp +442 -0
  468. package/numkong/test/test.hpp +580 -0
  469. package/numkong/test/test.mjs +363 -0
  470. package/numkong/test/test_base.py +1041 -0
  471. package/numkong/test/test_cast.cpp +242 -0
  472. package/numkong/test/test_cross.hpp +551 -0
  473. package/numkong/test/test_cross.py +467 -0
  474. package/numkong/test/test_cross_amx.cpp +50 -0
  475. package/numkong/test/test_cross_arm.cpp +225 -0
  476. package/numkong/test/test_cross_blas.cpp +354 -0
  477. package/numkong/test/test_cross_loongarch.cpp +90 -0
  478. package/numkong/test/test_cross_power.cpp +73 -0
  479. package/numkong/test/test_cross_rvv.cpp +109 -0
  480. package/numkong/test/test_cross_serial.cpp +181 -0
  481. package/numkong/test/test_cross_sme.cpp +148 -0
  482. package/numkong/test/test_cross_wasm.cpp +141 -0
  483. package/numkong/test/test_cross_x86.cpp +442 -0
  484. package/numkong/test/test_curved.cpp +182 -0
  485. package/numkong/test/test_curved.py +207 -0
  486. package/numkong/test/test_dot.cpp +353 -0
  487. package/numkong/test/test_dot.py +296 -0
  488. package/numkong/test/test_each.cpp +437 -0
  489. package/numkong/test/test_each.py +756 -0
  490. package/numkong/test/test_geospatial.cpp +155 -0
  491. package/numkong/test/test_geospatial.py +241 -0
  492. package/numkong/test/test_maxsim.cpp +138 -0
  493. package/numkong/test/test_maxsim.py +209 -0
  494. package/numkong/test/test_mesh.cpp +203 -0
  495. package/numkong/test/test_mesh.py +394 -0
  496. package/numkong/test/test_probability.cpp +136 -0
  497. package/numkong/test/test_probability.py +166 -0
  498. package/numkong/test/test_reduce.cpp +563 -0
  499. package/numkong/test/test_reduce.py +781 -0
  500. package/numkong/test/test_set.cpp +151 -0
  501. package/numkong/test/test_set.py +120 -0
  502. package/numkong/test/test_similarities.py +579 -0
  503. package/numkong/test/test_sparse.cpp +121 -0
  504. package/numkong/test/test_sparse.py +118 -0
  505. package/numkong/test/test_spatial.cpp +518 -0
  506. package/numkong/test/test_spatial.py +269 -0
  507. package/numkong/test/test_tensor.cpp +884 -0
  508. package/numkong/test/test_tensor.py +1417 -0
  509. package/numkong/test/test_trigonometry.cpp +156 -0
  510. package/numkong/test/test_trigonometry.py +180 -0
  511. package/package.json +7 -8
  512. package/prebuilds/darwin-arm64+x64/usearch.node +0 -0
  513. package/prebuilds/linux-arm64/usearch.node +0 -0
  514. package/prebuilds/linux-x64/usearch.node +0 -0
  515. package/fp16/CMakeLists.txt +0 -176
  516. package/fp16/LICENSE +0 -11
  517. package/fp16/README.md +0 -20
  518. package/fp16/bench/alt-element.cc +0 -89
  519. package/fp16/bench/from-alt-array.cc +0 -175
  520. package/fp16/bench/from-ieee-array.cc +0 -399
  521. package/fp16/bench/ieee-element.cc +0 -272
  522. package/fp16/bench/to-alt-array.cc +0 -91
  523. package/fp16/bench/to-ieee-array.cc +0 -303
  524. package/fp16/cmake/DownloadGoogleBenchmark.cmake +0 -15
  525. package/fp16/cmake/DownloadGoogleTest.cmake +0 -15
  526. package/fp16/cmake/DownloadPSimd.cmake +0 -15
  527. package/fp16/configure.py +0 -65
  528. package/fp16/confu.yaml +0 -8
  529. package/fp16/include/fp16/__init__.py +0 -0
  530. package/fp16/include/fp16/avx.py +0 -50
  531. package/fp16/include/fp16/avx2.py +0 -53
  532. package/fp16/include/fp16/bitcasts.h +0 -92
  533. package/fp16/include/fp16/fp16.h +0 -451
  534. package/fp16/include/fp16/psimd.h +0 -131
  535. package/fp16/include/fp16.h +0 -11
  536. package/fp16/jni/Android.mk +0 -6
  537. package/fp16/jni/Application.mk +0 -4
  538. package/fp16/test/alt-from-fp32-value.cc +0 -498
  539. package/fp16/test/alt-to-fp32-bits.cc +0 -263
  540. package/fp16/test/alt-to-fp32-psimd.cc +0 -145
  541. package/fp16/test/alt-to-fp32-value.cc +0 -348
  542. package/fp16/test/alt-to-fp32x2-psimd.cc +0 -245
  543. package/fp16/test/bitcasts.cc +0 -56
  544. package/fp16/test/ieee-from-fp32-value.cc +0 -523
  545. package/fp16/test/ieee-to-fp32-bits.cc +0 -333
  546. package/fp16/test/ieee-to-fp32-psimd.cc +0 -312
  547. package/fp16/test/ieee-to-fp32-value.cc +0 -420
  548. package/fp16/test/ieee-to-fp32x2-psimd.cc +0 -541
  549. package/fp16/test/peachpy/alt-xmm-to-fp32-xmm-avx.cc +0 -96
  550. package/fp16/test/peachpy/alt-xmm-to-fp32-ymm-avx2.cc +0 -96
  551. package/fp16/test/peachpy/stubs.py +0 -38
  552. package/fp16/test/tables.cc +0 -530
  553. package/fp16/test/tables.h +0 -13
  554. package/fp16/third-party/THHalf.h +0 -92
  555. package/fp16/third-party/eigen-half.h +0 -170
  556. package/fp16/third-party/float16-compressor.h +0 -80
  557. package/fp16/third-party/half.hpp +0 -2916
  558. package/fp16/third-party/npy-halffloat.h +0 -328
  559. package/simsimd/.git-blame-ignore-revs +0 -2
  560. package/simsimd/CONTRIBUTING.md +0 -321
  561. package/simsimd/Cargo.toml +0 -49
  562. package/simsimd/MANIFEST.in +0 -4
  563. package/simsimd/Package.swift +0 -28
  564. package/simsimd/README.md +0 -1493
  565. package/simsimd/binding.gyp +0 -35
  566. package/simsimd/build.rs +0 -70
  567. package/simsimd/c/lib.c +0 -374
  568. package/simsimd/include/module.modulemap +0 -4
  569. package/simsimd/include/simsimd/binary.h +0 -486
  570. package/simsimd/include/simsimd/curved.h +0 -1541
  571. package/simsimd/include/simsimd/dot.h +0 -1853
  572. package/simsimd/include/simsimd/elementwise.h +0 -2465
  573. package/simsimd/include/simsimd/geospatial.h +0 -43
  574. package/simsimd/include/simsimd/mesh.h +0 -69
  575. package/simsimd/include/simsimd/probability.h +0 -606
  576. package/simsimd/include/simsimd/simsimd.h +0 -2567
  577. package/simsimd/include/simsimd/sparse.h +0 -1384
  578. package/simsimd/include/simsimd/spatial.h +0 -2335
  579. package/simsimd/include/simsimd/types.h +0 -666
  580. package/simsimd/javascript/fallback.ts +0 -233
  581. package/simsimd/javascript/lib.c +0 -125
  582. package/simsimd/javascript/node-gyp-build.d.ts +0 -1
  583. package/simsimd/javascript/simsimd.ts +0 -179
  584. package/simsimd/javascript/tsconfig-cjs.json +0 -8
  585. package/simsimd/package-lock.json +0 -1761
  586. package/simsimd/package.json +0 -61
  587. package/simsimd/rust/lib.rs +0 -1821
  588. package/simsimd/scripts/bench.cxx +0 -1170
  589. package/simsimd/scripts/bench.ipynb +0 -187
  590. package/simsimd/scripts/bench.js +0 -127
  591. package/simsimd/scripts/bench.rs +0 -876
  592. package/simsimd/scripts/bench_vectors.py +0 -734
  593. package/simsimd/scripts/bench_vectors_live.py +0 -213
  594. package/simsimd/scripts/test.c +0 -187
  595. package/simsimd/scripts/test.mjs +0 -220
  596. package/simsimd/scripts/test.py +0 -1505
  597. package/simsimd/swift/SimSIMD.swift +0 -149
  598. package/simsimd/swift/Test.swift +0 -128
  599. /package/{simsimd → numkong}/CODE_OF_CONDUCT.md +0 -0
  600. /package/{simsimd → numkong}/LICENSE +0 -0
  601. /package/{simsimd → numkong}/javascript/dist-package-cjs.json +0 -0
  602. /package/{simsimd → numkong}/javascript/dist-package-esm.json +0 -0
@@ -1,328 +0,0 @@
1
- /*
2
- * This implementation is extracted from numpy:
3
- * Repo: github.com/numpy/numpy
4
- * File: numpy/core/src/npymath/halffloat.c
5
- * Commit ID: 25c23f1d956104a072a95355ffaa7a38b53710b7
6
- * Functions are made "static inline" for performance, and
7
- * non-conversion functions are removed, and generation of
8
- * exceptions is disabled.
9
- */
10
-
11
- #include <cstdint>
12
- typedef uint16_t npy_uint16;
13
- typedef uint32_t npy_uint32;
14
- typedef uint64_t npy_uint64;
15
-
16
- /*
17
- * This chooses between 'ties to even' and 'ties away from zero'.
18
- */
19
- #define NPY_HALF_ROUND_TIES_TO_EVEN 1
20
- /*
21
- * If these are 1, the conversions try to trigger underflow,
22
- * overflow, and invalid exceptions in the FP system when needed.
23
- */
24
- #define NPY_HALF_GENERATE_OVERFLOW 0
25
- #define NPY_HALF_GENERATE_UNDERFLOW 0
26
- #define NPY_HALF_GENERATE_INVALID 0
27
-
28
- /*
29
- ********************************************************************
30
- * BIT-LEVEL CONVERSIONS *
31
- ********************************************************************
32
- */
33
-
34
- static inline npy_uint16 npy_floatbits_to_halfbits(npy_uint32 f)
35
- {
36
- npy_uint32 f_exp, f_sig;
37
- npy_uint16 h_sgn, h_exp, h_sig;
38
-
39
- h_sgn = (npy_uint16) ((f&0x80000000u) >> 16);
40
- f_exp = (f&0x7f800000u);
41
-
42
- /* Exponent overflow/NaN converts to signed inf/NaN */
43
- if (f_exp >= 0x47800000u) {
44
- if (f_exp == 0x7f800000u) {
45
- /* Inf or NaN */
46
- f_sig = (f&0x007fffffu);
47
- if (f_sig != 0) {
48
- /* NaN - propagate the flag in the significand... */
49
- npy_uint16 ret = (npy_uint16) (0x7c00u + (f_sig >> 13));
50
- /* ...but make sure it stays a NaN */
51
- if (ret == 0x7c00u) {
52
- ret++;
53
- }
54
- return h_sgn + ret;
55
- } else {
56
- /* signed inf */
57
- return (npy_uint16) (h_sgn + 0x7c00u);
58
- }
59
- } else {
60
- /* overflow to signed inf */
61
- #if NPY_HALF_GENERATE_OVERFLOW
62
- npy_set_floatstatus_overflow();
63
- #endif
64
- return (npy_uint16) (h_sgn + 0x7c00u);
65
- }
66
- }
67
-
68
- /* Exponent underflow converts to a subnormal half or signed zero */
69
- if (f_exp <= 0x38000000u) {
70
- /*
71
- * Signed zeros, subnormal floats, and floats with small
72
- * exponents all convert to signed zero halfs.
73
- */
74
- if (f_exp < 0x33000000u) {
75
- #if NPY_HALF_GENERATE_UNDERFLOW
76
- /* If f != 0, it underflowed to 0 */
77
- if ((f&0x7fffffff) != 0) {
78
- npy_set_floatstatus_underflow();
79
- }
80
- #endif
81
- return h_sgn;
82
- }
83
- /* Make the subnormal significand */
84
- f_exp >>= 23;
85
- f_sig = (0x00800000u + (f&0x007fffffu));
86
- #if NPY_HALF_GENERATE_UNDERFLOW
87
- /* If it's not exactly represented, it underflowed */
88
- if ((f_sig&(((npy_uint32)1 << (126 - f_exp)) - 1)) != 0) {
89
- npy_set_floatstatus_underflow();
90
- }
91
- #endif
92
- f_sig >>= (113 - f_exp);
93
- /* Handle rounding by adding 1 to the bit beyond half precision */
94
- #if NPY_HALF_ROUND_TIES_TO_EVEN
95
- /*
96
- * If the last bit in the half significand is 0 (already even), and
97
- * the remaining bit pattern is 1000...0, then we do not add one
98
- * to the bit after the half significand. In all other cases, we do.
99
- */
100
- if ((f_sig&0x00003fffu) != 0x00001000u) {
101
- f_sig += 0x00001000u;
102
- }
103
- #else
104
- f_sig += 0x00001000u;
105
- #endif
106
- h_sig = (npy_uint16) (f_sig >> 13);
107
- /*
108
- * If the rounding causes a bit to spill into h_exp, it will
109
- * increment h_exp from zero to one and h_sig will be zero.
110
- * This is the correct result.
111
- */
112
- return (npy_uint16) (h_sgn + h_sig);
113
- }
114
-
115
- /* Regular case with no overflow or underflow */
116
- h_exp = (npy_uint16) ((f_exp - 0x38000000u) >> 13);
117
- /* Handle rounding by adding 1 to the bit beyond half precision */
118
- f_sig = (f&0x007fffffu);
119
- #if NPY_HALF_ROUND_TIES_TO_EVEN
120
- /*
121
- * If the last bit in the half significand is 0 (already even), and
122
- * the remaining bit pattern is 1000...0, then we do not add one
123
- * to the bit after the half significand. In all other cases, we do.
124
- */
125
- if ((f_sig&0x00003fffu) != 0x00001000u) {
126
- f_sig += 0x00001000u;
127
- }
128
- #else
129
- f_sig += 0x00001000u;
130
- #endif
131
- h_sig = (npy_uint16) (f_sig >> 13);
132
- /*
133
- * If the rounding causes a bit to spill into h_exp, it will
134
- * increment h_exp by one and h_sig will be zero. This is the
135
- * correct result. h_exp may increment to 15, at greatest, in
136
- * which case the result overflows to a signed inf.
137
- */
138
- #if NPY_HALF_GENERATE_OVERFLOW
139
- h_sig += h_exp;
140
- if (h_sig == 0x7c00u) {
141
- npy_set_floatstatus_overflow();
142
- }
143
- return h_sgn + h_sig;
144
- #else
145
- return h_sgn + h_exp + h_sig;
146
- #endif
147
- }
148
-
149
- static inline npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d)
150
- {
151
- npy_uint64 d_exp, d_sig;
152
- npy_uint16 h_sgn, h_exp, h_sig;
153
-
154
- h_sgn = (d&0x8000000000000000ULL) >> 48;
155
- d_exp = (d&0x7ff0000000000000ULL);
156
-
157
- /* Exponent overflow/NaN converts to signed inf/NaN */
158
- if (d_exp >= 0x40f0000000000000ULL) {
159
- if (d_exp == 0x7ff0000000000000ULL) {
160
- /* Inf or NaN */
161
- d_sig = (d&0x000fffffffffffffULL);
162
- if (d_sig != 0) {
163
- /* NaN - propagate the flag in the significand... */
164
- npy_uint16 ret = (npy_uint16) (0x7c00u + (d_sig >> 42));
165
- /* ...but make sure it stays a NaN */
166
- if (ret == 0x7c00u) {
167
- ret++;
168
- }
169
- return h_sgn + ret;
170
- } else {
171
- /* signed inf */
172
- return h_sgn + 0x7c00u;
173
- }
174
- } else {
175
- /* overflow to signed inf */
176
- #if NPY_HALF_GENERATE_OVERFLOW
177
- npy_set_floatstatus_overflow();
178
- #endif
179
- return h_sgn + 0x7c00u;
180
- }
181
- }
182
-
183
- /* Exponent underflow converts to subnormal half or signed zero */
184
- if (d_exp <= 0x3f00000000000000ULL) {
185
- /*
186
- * Signed zeros, subnormal floats, and floats with small
187
- * exponents all convert to signed zero halfs.
188
- */
189
- if (d_exp < 0x3e60000000000000ULL) {
190
- #if NPY_HALF_GENERATE_UNDERFLOW
191
- /* If d != 0, it underflowed to 0 */
192
- if ((d&0x7fffffffffffffffULL) != 0) {
193
- npy_set_floatstatus_underflow();
194
- }
195
- #endif
196
- return h_sgn;
197
- }
198
- /* Make the subnormal significand */
199
- d_exp >>= 52;
200
- d_sig = (0x0010000000000000ULL + (d&0x000fffffffffffffULL));
201
- #if NPY_HALF_GENERATE_UNDERFLOW
202
- /* If it's not exactly represented, it underflowed */
203
- if ((d_sig&(((npy_uint64)1 << (1051 - d_exp)) - 1)) != 0) {
204
- npy_set_floatstatus_underflow();
205
- }
206
- #endif
207
- d_sig >>= (1009 - d_exp);
208
- /* Handle rounding by adding 1 to the bit beyond half precision */
209
- #if NPY_HALF_ROUND_TIES_TO_EVEN
210
- /*
211
- * If the last bit in the half significand is 0 (already even), and
212
- * the remaining bit pattern is 1000...0, then we do not add one
213
- * to the bit after the half significand. In all other cases, we do.
214
- */
215
- if ((d_sig&0x000007ffffffffffULL) != 0x0000020000000000ULL) {
216
- d_sig += 0x0000020000000000ULL;
217
- }
218
- #else
219
- d_sig += 0x0000020000000000ULL;
220
- #endif
221
- h_sig = (npy_uint16) (d_sig >> 42);
222
- /*
223
- * If the rounding causes a bit to spill into h_exp, it will
224
- * increment h_exp from zero to one and h_sig will be zero.
225
- * This is the correct result.
226
- */
227
- return h_sgn + h_sig;
228
- }
229
-
230
- /* Regular case with no overflow or underflow */
231
- h_exp = (npy_uint16) ((d_exp - 0x3f00000000000000ULL) >> 42);
232
- /* Handle rounding by adding 1 to the bit beyond half precision */
233
- d_sig = (d&0x000fffffffffffffULL);
234
- #if NPY_HALF_ROUND_TIES_TO_EVEN
235
- /*
236
- * If the last bit in the half significand is 0 (already even), and
237
- * the remaining bit pattern is 1000...0, then we do not add one
238
- * to the bit after the half significand. In all other cases, we do.
239
- */
240
- if ((d_sig&0x000007ffffffffffULL) != 0x0000020000000000ULL) {
241
- d_sig += 0x0000020000000000ULL;
242
- }
243
- #else
244
- d_sig += 0x0000020000000000ULL;
245
- #endif
246
- h_sig = (npy_uint16) (d_sig >> 42);
247
-
248
- /*
249
- * If the rounding causes a bit to spill into h_exp, it will
250
- * increment h_exp by one and h_sig will be zero. This is the
251
- * correct result. h_exp may increment to 15, at greatest, in
252
- * which case the result overflows to a signed inf.
253
- */
254
- #if NPY_HALF_GENERATE_OVERFLOW
255
- h_sig += h_exp;
256
- if (h_sig == 0x7c00u) {
257
- npy_set_floatstatus_overflow();
258
- }
259
- return h_sgn + h_sig;
260
- #else
261
- return h_sgn + h_exp + h_sig;
262
- #endif
263
- }
264
-
265
- static inline npy_uint32 npy_halfbits_to_floatbits(npy_uint16 h)
266
- {
267
- npy_uint16 h_exp, h_sig;
268
- npy_uint32 f_sgn, f_exp, f_sig;
269
-
270
- h_exp = (h&0x7c00u);
271
- f_sgn = ((npy_uint32)h&0x8000u) << 16;
272
- switch (h_exp) {
273
- case 0x0000u: /* 0 or subnormal */
274
- h_sig = (h&0x03ffu);
275
- /* Signed zero */
276
- if (h_sig == 0) {
277
- return f_sgn;
278
- }
279
- /* Subnormal */
280
- h_sig <<= 1;
281
- while ((h_sig&0x0400u) == 0) {
282
- h_sig <<= 1;
283
- h_exp++;
284
- }
285
- f_exp = ((npy_uint32)(127 - 15 - h_exp)) << 23;
286
- f_sig = ((npy_uint32)(h_sig&0x03ffu)) << 13;
287
- return f_sgn + f_exp + f_sig;
288
- case 0x7c00u: /* inf or NaN */
289
- /* All-ones exponent and a copy of the significand */
290
- return f_sgn + 0x7f800000u + (((npy_uint32)(h&0x03ffu)) << 13);
291
- default: /* normalized */
292
- /* Just need to adjust the exponent and shift */
293
- return f_sgn + (((npy_uint32)(h&0x7fffu) + 0x1c000u) << 13);
294
- }
295
- }
296
-
297
- static inline npy_uint64 npy_halfbits_to_doublebits(npy_uint16 h)
298
- {
299
- npy_uint16 h_exp, h_sig;
300
- npy_uint64 d_sgn, d_exp, d_sig;
301
-
302
- h_exp = (h&0x7c00u);
303
- d_sgn = ((npy_uint64)h&0x8000u) << 48;
304
- switch (h_exp) {
305
- case 0x0000u: /* 0 or subnormal */
306
- h_sig = (h&0x03ffu);
307
- /* Signed zero */
308
- if (h_sig == 0) {
309
- return d_sgn;
310
- }
311
- /* Subnormal */
312
- h_sig <<= 1;
313
- while ((h_sig&0x0400u) == 0) {
314
- h_sig <<= 1;
315
- h_exp++;
316
- }
317
- d_exp = ((npy_uint64)(1023 - 15 - h_exp)) << 52;
318
- d_sig = ((npy_uint64)(h_sig&0x03ffu)) << 42;
319
- return d_sgn + d_exp + d_sig;
320
- case 0x7c00u: /* inf or NaN */
321
- /* All-ones exponent and a copy of the significand */
322
- return d_sgn + 0x7ff0000000000000ULL +
323
- (((npy_uint64)(h&0x03ffu)) << 42);
324
- default: /* normalized */
325
- /* Just need to adjust the exponent and shift */
326
- return d_sgn + (((npy_uint64)(h&0x7fffu) + 0xfc000u) << 42);
327
- }
328
- }
@@ -1,2 +0,0 @@
1
- a4022a988287e527757ecc9bc16a4f2e7dc4770e
2
- 750c59f5116a2000507a0cec09db009fd7d31232
@@ -1,321 +0,0 @@
1
- # Contributing
2
-
3
- To keep the quality of the code high, we have a set of [guidelines](https://github.com/unum-cloud).
4
-
5
- - [What's the procedure?](https://github.com/unum-cloud/awesome/blob/main/Workflow.md#organizing-software-development)
6
- - [How to organize branches?](https://github.com/unum-cloud/awesome/blob/main/Workflow.md#branches)
7
- - [How to style commits?](https://github.com/unum-cloud/awesome/blob/main/Workflow.md#commits)
8
-
9
- ## Navigating the Codebase
10
-
11
- Primary kernels are implemented in header files under `include/simsimd/`:
12
-
13
- - `dot.h` - dot products for real and complex vectors.
14
- - `spatial.h` - spatial distances: L2, cosine distance.
15
- - `binary.h` - binary distances: Hamming, Jaccard, etc.
16
- - `probability.h` - probability metrics: KL-divergence, Jensen-Shannon, etc.
17
- - `sparse.h` - sparse distances: weighted and normal set intersections.
18
- - `curved.h` - bilinear forms for real and complex vectors, and Mahalanobis distance.
19
-
20
- Bindings to other languages are in the respective directories:
21
-
22
- - `python/lib.c` - Python bindings.
23
- - `javascript/lib.c` - JavaScript bindings.
24
- - `rust/lib.rs` - Rust bindings.
25
- - `swift/SimSIMD.swift` - Swift bindings.
26
-
27
- All tests, benchmarks, and examples are placed in the `scripts/` directory, if compatible with the toolchain of the implementation language.
28
-
29
- ## C and C++
30
-
31
- To rerun experiments utilize the following command:
32
-
33
- ```sh
34
- sudo apt install libopenblas-dev # BLAS installation is optional, but recommended for benchmarks
35
- cmake -D CMAKE_BUILD_TYPE=Release -D SIMSIMD_BUILD_TESTS=1 -D SIMSIMD_BUILD_BENCHMARKS=1 -D SIMSIMD_BUILD_BENCHMARKS_WITH_CBLAS=1 -B build_release
36
- cmake --build build_release --config Release
37
- build_release/simsimd_bench
38
- build_release/simsimd_bench --benchmark_filter=js
39
- build_release/simsimd_test_run_time
40
- build_release/simsimd_test_compile_time # no need to run this one, it's just a compile-time test
41
- ```
42
-
43
- To utilize `f16` instructions, use GCC 12 or newer, or Clang 16 or newer.
44
- To install them on Ubuntu 22.04, use:
45
-
46
- ```sh
47
- sudo apt install gcc-12 g++-12
48
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100
49
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100
50
- ```
51
-
52
- To compile with the default Apple Clang on macOS, use:
53
-
54
- ```sh
55
- brew install openblas
56
- cmake -D CMAKE_BUILD_TYPE=Release \
57
- -D SIMSIMD_BUILD_TESTS=1 \
58
- -D SIMSIMD_BUILD_BENCHMARKS=1 \
59
- -D SIMSIMD_BUILD_BENCHMARKS_WITH_CBLAS=1 \
60
- -D CMAKE_PREFIX_PATH="$(brew --prefix openblas)" \
61
- -D CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES="$(brew --prefix openblas)/include" \
62
- -B build_release
63
- cmake --build build_release --config Release
64
- ```
65
-
66
- On macOS it's recommended to use Homebrew and install Clang, as opposed to "Apple Clang".
67
- Replacing the default compiler across the entire system is not recommended on macOS, as it may break the system, but you can pass it as an environment variable:
68
-
69
- ```sh
70
- brew install llvm openblas
71
- unset DEVELOPER_DIR
72
- cmake -D CMAKE_BUILD_TYPE=Release \
73
- -D SIMSIMD_BUILD_TESTS=1 \
74
- -D SIMSIMD_BUILD_BENCHMARKS=1 \
75
- -D SIMSIMD_BUILD_BENCHMARKS_WITH_CBLAS=1 \
76
- -D CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES="$(brew --prefix openblas)/include" \
77
- -D CMAKE_C_LINK_FLAGS="-L$(xcrun --sdk macosx --show-sdk-path)/usr/lib" \
78
- -D CMAKE_EXE_LINKER_FLAGS="-L$(xcrun --sdk macosx --show-sdk-path)/usr/lib" \
79
- -D CMAKE_C_COMPILER="$(brew --prefix llvm)/bin/clang" \
80
- -D CMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++" \
81
- -D CMAKE_OSX_SYSROOT="$(xcrun --sdk macosx --show-sdk-path)" \
82
- -D CMAKE_OSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion) \
83
- -B build_release
84
- cmake --build build_release --config Release
85
- ```
86
-
87
- When benchmarking, make sure to disable multi-threading in the BLAS library, as it may interfere with the results:
88
-
89
- ```sh
90
- export OPENBLAS_NUM_THREADS=1 # for OpenBLAS
91
- export MKL_NUM_THREADS=1 # for Intel MKL
92
- export VECLIB_MAXIMUM_THREADS=1 # for Apple Accelerate
93
- export BLIS_NUM_THREADS=1 # for BLIS
94
- ```
95
-
96
- ## Python
97
-
98
- Python bindings are implemented using pure CPython, so you wouldn't need to install SWIG, PyBind11, or any other third-party library.
99
- Still, you need a virtual environment.
100
- If you already have one:
101
-
102
- ```sh
103
- pip install -e . # build locally from source
104
- pip install pytest pytest-repeat tabulate # testing dependencies
105
- pytest scripts/test.py -s -x -Wd # to run tests
106
-
107
- # to check supported SIMD instructions:
108
- python -c "import simsimd; print(simsimd.get_capabilities())"
109
- ```
110
-
111
- Alternatively, use `uv` to create the virtual environment.
112
-
113
- ```sh
114
- uv venv --python 3.13t # or your preferred version
115
- source .venv/bin/activate # activate the environment
116
- uv pip install -e . # build locally from source
117
-
118
- # to run GIL-related tests in a free-threaded environment:
119
- uv pip install pytest pytest-repeat tabulate numpy scipy
120
- PYTHON_GIL=0 python -m pytest scripts/test.py -s -x -Wd -k gil
121
- ```
122
-
123
- Here, `-s` will output the logs.
124
- The `-x` will stop on the first failure.
125
- The `-Wd` will silence overflows and runtime warnings.
126
-
127
- When building on macOS, same as with C/C++, use non-Apple Clang version:
128
-
129
- ```sh
130
- brew install llvm
131
- CC=$(brew --prefix llvm)/bin/clang CXX=$(brew --prefix llvm)/bin/clang++ pip install -e .
132
- ```
133
-
134
- Benchmarking:
135
-
136
- ```sh
137
- pip install numpy scipy scikit-learn # for comparison baselines
138
- python scripts/bench_vectors.py # to run default benchmarks
139
- python scripts/bench_vectors.py --n 1000 --ndim 1536 # batch size and dimensions
140
- ```
141
-
142
- You can also benchmark against other libraries, filter the numeric types, and distance metrics:
143
-
144
- ```sh
145
- $ python scripts/bench_vectors.py --help
146
- > usage: bench.py [-h] [--ndim NDIM] [-n COUNT]
147
- > [--metric {all,dot,spatial,binary,probability,sparse}]
148
- > [--dtype {all,bin8,int8,uint16,uint32,float16,float32,float64,bfloat16,complex32,complex64,complex128}]
149
- > [--scipy] [--scikit] [--torch] [--tf] [--jax]
150
- >
151
- > Benchmark SimSIMD vs. other libraries
152
- >
153
- > optional arguments:
154
- > -h, --help show this help message and exit
155
- > --ndim NDIM Number of dimensions in vectors (default: 1536) For binary vectors (e.g., Hamming, Jaccard), this is the number of bits. In
156
- > case of SimSIMD, the inputs will be treated at the bit-level. Other packages will be matching/comparing 8-bit integers. The
157
- > volume of exchanged data will be identical, but the results will differ.
158
- > -n COUNT, --count COUNT
159
- > Number of vectors per batch (default: 1) By default, when set to 1 the benchmark will generate many vectors of size (ndim, )
160
- > and call the functions on pairs of single vectors: both directly, and through `cdist`. Alternatively, for larger batch sizes
161
- > the benchmark will generate two matrices of size (n, ndim) and compute: - batch mode: (n) distances between vectors in
162
- > identical rows of the two matrices, - all-pairs mode: (n^2) distances between all pairs of vectors in the two matrices via
163
- > `cdist`.
164
- > --metric {all,dot,spatial,binary,probability,sparse}
165
- > Distance metric to use, profiles everything by default
166
- > --dtype {all,bin8,int8,uint16,uint32,float16,float32,float64,bfloat16,complex32,complex64,complex128}
167
- > Defines numeric types to benchmark, profiles everything by default
168
- > --scipy Profile SciPy, must be installed
169
- > --scikit Profile scikit-learn, must be installed
170
- > --torch Profile PyTorch, must be installed
171
- > --tf Profile TensorFlow, must be installed
172
- > --jax Profile JAX, must be installed
173
- ```
174
-
175
-
176
- Before merging your changes you may want to test your changes against the entire matrix of Python versions USearch supports.
177
- For that you need the `cibuildwheel`, which is tricky to use on macOS and Windows, as it would target just the local environment.
178
- Still, if you have Docker running on any desktop OS, you can use it to build and test the Python bindings for all Python versions for Linux:
179
-
180
- ```sh
181
- pip install cibuildwheel
182
- cibuildwheel
183
- cibuildwheel --platform linux # works on any OS and builds all Linux backends
184
- cibuildwheel --platform linux --archs x86_64 # 64-bit x86, the most common on desktop and servers
185
- cibuildwheel --platform linux --archs aarch64 # 64-bit Arm for mobile devices, Apple M-series, and AWS Graviton
186
- cibuildwheel --platform linux --archs i686 # 32-bit Linux
187
- cibuildwheel --platform macos # works only on macOS
188
- cibuildwheel --platform windows # works only on Windows
189
- ```
190
-
191
- You may need root privileges for multi-architecture builds:
192
-
193
- ```sh
194
- sudo $(which cibuildwheel) --platform linux
195
- ```
196
-
197
- On Windows and macOS, to avoid frequent path resolution issues, you may want to use:
198
-
199
- ```sh
200
- python -m cibuildwheel --platform windows
201
- ```
202
-
203
- ## Rust
204
-
205
- ```sh
206
- cargo test -p simsimd
207
- cargo test -p simsimd -- --nocapture # To see the output
208
- cargo bench
209
- open target/criterion/report/index.html
210
- ```
211
-
212
- To automatically detect the Minimum Supported Rust Version (MSRV):
213
-
214
- ```sh
215
- cargo +stable install cargo-msrv
216
- cargo msrv find --ignore-lockfile
217
- ```
218
-
219
- ## JavaScript
220
-
221
- ### NodeJS
222
-
223
- If you don't have the environment configured, here are the [installation options](https://github.com/nvm-sh/nvm?tab=readme-ov-file#install--update-script) with different tools:
224
-
225
- ```sh
226
- wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash # Linux
227
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash # macOS
228
- ```
229
-
230
- Install dependencies:
231
-
232
- ```sh
233
- nvm install 20
234
- npm install -g typescript # Install the TypeScript compiler globally
235
- npm install --save-dev @types/node # Install the Node.js type definitions as a dev dependency
236
- ```
237
-
238
- Testing and benchmarking:
239
-
240
- ```sh
241
- npm run build-js # Build the JavaScript code using TypeScript configurations
242
- npm test # Run the test suite
243
- npm run bench # Run the benchmark script
244
- ```
245
-
246
- ### Deno
247
-
248
- If you don't have the environment configured, here are [installation options](https://docs.deno.com/runtime/getting_started/installation/) with different tools:
249
-
250
- ```sh
251
- wget -qO- https://deno.land/x/install/install.sh | sh # Linux
252
- curl -fsSL https://deno.land/install.sh | sh # macOS
253
- irm https://deno.land/install.ps1 | iex # Windows
254
- ```
255
-
256
- Testing:
257
-
258
- ```sh
259
- deno test -A
260
- ```
261
-
262
- ### Bun
263
-
264
- If you don't have the environment configured, here are the [installation options](https://bun.sh/docs/installation) with different tools:
265
-
266
- ```sh
267
- wget -qO- https://bun.sh/install | bash # for Linux
268
- curl -fsSL https://bun.sh/install | bash # for macOS and WSL
269
- ```
270
-
271
- Testing:
272
-
273
- ```sh
274
- bun install
275
- bun test ./scripts/test.mjs
276
- ```
277
-
278
- ... wouldn't work for now.
279
-
280
- ## Swift
281
-
282
- ```sh
283
- swift build && swift test -v
284
- ```
285
-
286
- Running Swift on Linux requires a couple of extra steps, as the Swift compiler is not available in the default repositories.
287
- Please get the most recent Swift tarball from the [official website](https://www.swift.org/install/).
288
- At the time of writing, for 64-bit Arm CPU running Ubuntu 22.04, the following commands would work:
289
-
290
- ```bash
291
- wget https://download.swift.org/swift-5.9.2-release/ubuntu2204-aarch64/swift-5.9.2-RELEASE/swift-5.9.2-RELEASE-ubuntu22.04-aarch64.tar.gz
292
- tar xzf swift-5.9.2-RELEASE-ubuntu22.04-aarch64.tar.gz
293
- sudo mv swift-5.9.2-RELEASE-ubuntu22.04-aarch64 /usr/share/swift
294
- echo "export PATH=/usr/share/swift/usr/bin:$PATH" >> ~/.bashrc
295
- source ~/.bashrc
296
- ```
297
-
298
- You can check the available images on [`swift.org/download` page](https://www.swift.org/download/#releases).
299
- For x86 CPUs, the following commands would work:
300
-
301
- ```bash
302
- wget https://download.swift.org/swift-5.9.2-release/ubuntu2204/swift-5.9.2-RELEASE/swift-5.9.2-RELEASE-ubuntu22.04.tar.gz
303
- tar xzf swift-5.9.2-RELEASE-ubuntu22.04.tar.gz
304
- sudo mv swift-5.9.2-RELEASE-ubuntu22.04 /usr/share/swift
305
- echo "export PATH=/usr/share/swift/usr/bin:$PATH" >> ~/.bashrc
306
- source ~/.bashrc
307
- ```
308
-
309
- Alternatively, on Linux, the official Swift Docker image can be used for builds and tests:
310
-
311
- ```bash
312
- sudo docker run --rm -v "$PWD:/workspace" -w /workspace swift:5.9 /bin/bash -cl "swift build -c release --static-swift-stdlib && swift test -c release --enable-test-discovery"
313
- ```
314
-
315
- ## GoLang
316
-
317
- ```sh
318
- cd golang
319
- go test # To test
320
- go test -run=^$ -bench=. -benchmem # To benchmark
321
- ```
@@ -1,49 +0,0 @@
1
- [package]
2
- name = "simsimd"
3
- description = "Portable mixed-precision BLAS-like vector math library for x86 and ARM"
4
- version = "6.5.5"
5
- edition = "2021"
6
- license = "Apache-2.0"
7
- authors = ["Ash Vardanian <1983160+ashvardanian@users.noreply.github.com>"]
8
- repository = "https://github.com/ashvardanian/SimSIMD"
9
- documentation = "https://docs.rs/simsimd"
10
- homepage = "https://ashvardanian.com/posts/simsimd-faster-scipy"
11
- keywords = ["simd", "search", "linear-algebra", "vector"]
12
- categories = [
13
- "mathematics",
14
- "hardware-support",
15
- "no-std",
16
- "wasm",
17
- "external-ffi-bindings",
18
- ]
19
- rust-version = "1.64" # Introduced Core C FFI in stable Rust
20
- include = ["rust/**", "c/**", "include/**", "build.rs"]
21
-
22
-
23
- [lib]
24
- name = "simsimd"
25
- path = "rust/lib.rs"
26
-
27
- [build-dependencies]
28
- cc = "1.2.36"
29
-
30
-
31
- [[bench]]
32
- name = "bench"
33
- harness = false
34
- path = "scripts/bench.rs"
35
-
36
- [profile.bench]
37
- opt-level = 3 # Corresponds to -O3
38
- lto = true # Enables Link Time Optimization for further optimizations
39
- codegen-units = 1 # May increase compilation time but optimizes further
40
- rpath = false # On some systems, setting this to false can help with optimizations
41
-
42
- [features]
43
- default = []
44
- std = []
45
-
46
- [dev-dependencies]
47
- criterion = { version = "0.7.0" }
48
- rand = { version = "0.9.1" }
49
- half = { version = "2.6.0" }