numkong 7.0.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 (294) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +495 -0
  3. package/binding.gyp +540 -0
  4. package/c/dispatch.h +512 -0
  5. package/c/dispatch_bf16.c +389 -0
  6. package/c/dispatch_bf16c.c +52 -0
  7. package/c/dispatch_e2m3.c +263 -0
  8. package/c/dispatch_e3m2.c +243 -0
  9. package/c/dispatch_e4m3.c +276 -0
  10. package/c/dispatch_e5m2.c +272 -0
  11. package/c/dispatch_f16.c +376 -0
  12. package/c/dispatch_f16c.c +58 -0
  13. package/c/dispatch_f32.c +378 -0
  14. package/c/dispatch_f32c.c +99 -0
  15. package/c/dispatch_f64.c +296 -0
  16. package/c/dispatch_f64c.c +98 -0
  17. package/c/dispatch_i16.c +96 -0
  18. package/c/dispatch_i32.c +89 -0
  19. package/c/dispatch_i4.c +150 -0
  20. package/c/dispatch_i64.c +86 -0
  21. package/c/dispatch_i8.c +289 -0
  22. package/c/dispatch_other.c +330 -0
  23. package/c/dispatch_u1.c +148 -0
  24. package/c/dispatch_u16.c +124 -0
  25. package/c/dispatch_u32.c +118 -0
  26. package/c/dispatch_u4.c +150 -0
  27. package/c/dispatch_u64.c +102 -0
  28. package/c/dispatch_u8.c +303 -0
  29. package/c/numkong.c +950 -0
  30. package/include/README.md +573 -0
  31. package/include/module.modulemap +129 -0
  32. package/include/numkong/attention/sapphireamx.h +1361 -0
  33. package/include/numkong/attention/sme.h +2066 -0
  34. package/include/numkong/attention.h +49 -0
  35. package/include/numkong/capabilities.h +748 -0
  36. package/include/numkong/cast/README.md +262 -0
  37. package/include/numkong/cast/haswell.h +975 -0
  38. package/include/numkong/cast/icelake.h +470 -0
  39. package/include/numkong/cast/neon.h +1192 -0
  40. package/include/numkong/cast/rvv.h +1021 -0
  41. package/include/numkong/cast/sapphire.h +262 -0
  42. package/include/numkong/cast/serial.h +2262 -0
  43. package/include/numkong/cast/skylake.h +856 -0
  44. package/include/numkong/cast/v128relaxed.h +180 -0
  45. package/include/numkong/cast.h +230 -0
  46. package/include/numkong/curved/README.md +223 -0
  47. package/include/numkong/curved/genoa.h +182 -0
  48. package/include/numkong/curved/haswell.h +276 -0
  49. package/include/numkong/curved/neon.h +205 -0
  50. package/include/numkong/curved/neonbfdot.h +212 -0
  51. package/include/numkong/curved/neonhalf.h +212 -0
  52. package/include/numkong/curved/rvv.h +305 -0
  53. package/include/numkong/curved/serial.h +207 -0
  54. package/include/numkong/curved/skylake.h +457 -0
  55. package/include/numkong/curved/smef64.h +506 -0
  56. package/include/numkong/curved.h +517 -0
  57. package/include/numkong/curved.hpp +144 -0
  58. package/include/numkong/dot/README.md +425 -0
  59. package/include/numkong/dot/alder.h +563 -0
  60. package/include/numkong/dot/genoa.h +315 -0
  61. package/include/numkong/dot/haswell.h +1688 -0
  62. package/include/numkong/dot/icelake.h +883 -0
  63. package/include/numkong/dot/neon.h +818 -0
  64. package/include/numkong/dot/neonbfdot.h +244 -0
  65. package/include/numkong/dot/neonfhm.h +360 -0
  66. package/include/numkong/dot/neonhalf.h +198 -0
  67. package/include/numkong/dot/neonsdot.h +508 -0
  68. package/include/numkong/dot/rvv.h +714 -0
  69. package/include/numkong/dot/rvvbb.h +72 -0
  70. package/include/numkong/dot/rvvbf16.h +123 -0
  71. package/include/numkong/dot/rvvhalf.h +129 -0
  72. package/include/numkong/dot/sapphire.h +141 -0
  73. package/include/numkong/dot/serial.h +838 -0
  74. package/include/numkong/dot/sierra.h +405 -0
  75. package/include/numkong/dot/skylake.h +1084 -0
  76. package/include/numkong/dot/sve.h +379 -0
  77. package/include/numkong/dot/svebfdot.h +74 -0
  78. package/include/numkong/dot/svehalf.h +123 -0
  79. package/include/numkong/dot/v128relaxed.h +1258 -0
  80. package/include/numkong/dot.h +1070 -0
  81. package/include/numkong/dot.hpp +94 -0
  82. package/include/numkong/dots/README.md +496 -0
  83. package/include/numkong/dots/alder.h +114 -0
  84. package/include/numkong/dots/genoa.h +94 -0
  85. package/include/numkong/dots/haswell.h +295 -0
  86. package/include/numkong/dots/icelake.h +171 -0
  87. package/include/numkong/dots/neon.h +120 -0
  88. package/include/numkong/dots/neonbfdot.h +58 -0
  89. package/include/numkong/dots/neonfhm.h +94 -0
  90. package/include/numkong/dots/neonhalf.h +57 -0
  91. package/include/numkong/dots/neonsdot.h +108 -0
  92. package/include/numkong/dots/rvv.h +2486 -0
  93. package/include/numkong/dots/sapphireamx.h +3973 -0
  94. package/include/numkong/dots/serial.h +2844 -0
  95. package/include/numkong/dots/sierra.h +97 -0
  96. package/include/numkong/dots/skylake.h +196 -0
  97. package/include/numkong/dots/sme.h +5372 -0
  98. package/include/numkong/dots/smebi32.h +461 -0
  99. package/include/numkong/dots/smef64.h +1318 -0
  100. package/include/numkong/dots/smehalf.h +47 -0
  101. package/include/numkong/dots/v128relaxed.h +294 -0
  102. package/include/numkong/dots.h +2804 -0
  103. package/include/numkong/dots.hpp +639 -0
  104. package/include/numkong/each/README.md +469 -0
  105. package/include/numkong/each/haswell.h +1658 -0
  106. package/include/numkong/each/icelake.h +272 -0
  107. package/include/numkong/each/neon.h +1104 -0
  108. package/include/numkong/each/neonbfdot.h +212 -0
  109. package/include/numkong/each/neonhalf.h +410 -0
  110. package/include/numkong/each/rvv.h +1121 -0
  111. package/include/numkong/each/sapphire.h +477 -0
  112. package/include/numkong/each/serial.h +260 -0
  113. package/include/numkong/each/skylake.h +1562 -0
  114. package/include/numkong/each.h +2146 -0
  115. package/include/numkong/each.hpp +434 -0
  116. package/include/numkong/geospatial/README.md +147 -0
  117. package/include/numkong/geospatial/haswell.h +593 -0
  118. package/include/numkong/geospatial/neon.h +571 -0
  119. package/include/numkong/geospatial/rvv.h +701 -0
  120. package/include/numkong/geospatial/serial.h +309 -0
  121. package/include/numkong/geospatial/skylake.h +577 -0
  122. package/include/numkong/geospatial/v128relaxed.h +613 -0
  123. package/include/numkong/geospatial.h +453 -0
  124. package/include/numkong/geospatial.hpp +235 -0
  125. package/include/numkong/matrix.hpp +336 -0
  126. package/include/numkong/maxsim/README.md +187 -0
  127. package/include/numkong/maxsim/alder.h +511 -0
  128. package/include/numkong/maxsim/genoa.h +115 -0
  129. package/include/numkong/maxsim/haswell.h +553 -0
  130. package/include/numkong/maxsim/icelake.h +480 -0
  131. package/include/numkong/maxsim/neonsdot.h +394 -0
  132. package/include/numkong/maxsim/sapphireamx.h +877 -0
  133. package/include/numkong/maxsim/serial.h +490 -0
  134. package/include/numkong/maxsim/sme.h +929 -0
  135. package/include/numkong/maxsim/v128relaxed.h +280 -0
  136. package/include/numkong/maxsim.h +571 -0
  137. package/include/numkong/maxsim.hpp +133 -0
  138. package/include/numkong/mesh/README.md +227 -0
  139. package/include/numkong/mesh/haswell.h +2235 -0
  140. package/include/numkong/mesh/neon.h +1329 -0
  141. package/include/numkong/mesh/neonbfdot.h +842 -0
  142. package/include/numkong/mesh/neonhalf.h +616 -0
  143. package/include/numkong/mesh/rvv.h +916 -0
  144. package/include/numkong/mesh/serial.h +742 -0
  145. package/include/numkong/mesh/skylake.h +1135 -0
  146. package/include/numkong/mesh/v128relaxed.h +1052 -0
  147. package/include/numkong/mesh.h +652 -0
  148. package/include/numkong/mesh.hpp +762 -0
  149. package/include/numkong/numkong.h +78 -0
  150. package/include/numkong/numkong.hpp +57 -0
  151. package/include/numkong/probability/README.md +173 -0
  152. package/include/numkong/probability/haswell.h +267 -0
  153. package/include/numkong/probability/neon.h +225 -0
  154. package/include/numkong/probability/rvv.h +409 -0
  155. package/include/numkong/probability/serial.h +169 -0
  156. package/include/numkong/probability/skylake.h +324 -0
  157. package/include/numkong/probability.h +383 -0
  158. package/include/numkong/probability.hpp +120 -0
  159. package/include/numkong/random.h +50 -0
  160. package/include/numkong/random.hpp +285 -0
  161. package/include/numkong/reduce/README.md +547 -0
  162. package/include/numkong/reduce/alder.h +632 -0
  163. package/include/numkong/reduce/genoa.h +201 -0
  164. package/include/numkong/reduce/haswell.h +3783 -0
  165. package/include/numkong/reduce/icelake.h +549 -0
  166. package/include/numkong/reduce/neon.h +3841 -0
  167. package/include/numkong/reduce/neonbfdot.h +353 -0
  168. package/include/numkong/reduce/neonfhm.h +665 -0
  169. package/include/numkong/reduce/neonhalf.h +157 -0
  170. package/include/numkong/reduce/neonsdot.h +357 -0
  171. package/include/numkong/reduce/rvv.h +3407 -0
  172. package/include/numkong/reduce/serial.h +757 -0
  173. package/include/numkong/reduce/sierra.h +338 -0
  174. package/include/numkong/reduce/skylake.h +3792 -0
  175. package/include/numkong/reduce/v128relaxed.h +2302 -0
  176. package/include/numkong/reduce.h +1597 -0
  177. package/include/numkong/reduce.hpp +633 -0
  178. package/include/numkong/scalar/README.md +89 -0
  179. package/include/numkong/scalar/haswell.h +113 -0
  180. package/include/numkong/scalar/neon.h +122 -0
  181. package/include/numkong/scalar/neonhalf.h +70 -0
  182. package/include/numkong/scalar/rvv.h +211 -0
  183. package/include/numkong/scalar/sapphire.h +63 -0
  184. package/include/numkong/scalar/serial.h +332 -0
  185. package/include/numkong/scalar/v128relaxed.h +56 -0
  186. package/include/numkong/scalar.h +683 -0
  187. package/include/numkong/set/README.md +179 -0
  188. package/include/numkong/set/haswell.h +334 -0
  189. package/include/numkong/set/icelake.h +485 -0
  190. package/include/numkong/set/neon.h +364 -0
  191. package/include/numkong/set/rvv.h +226 -0
  192. package/include/numkong/set/rvvbb.h +117 -0
  193. package/include/numkong/set/serial.h +174 -0
  194. package/include/numkong/set/sve.h +185 -0
  195. package/include/numkong/set/v128relaxed.h +240 -0
  196. package/include/numkong/set.h +457 -0
  197. package/include/numkong/set.hpp +114 -0
  198. package/include/numkong/sets/README.md +149 -0
  199. package/include/numkong/sets/haswell.h +63 -0
  200. package/include/numkong/sets/icelake.h +66 -0
  201. package/include/numkong/sets/neon.h +61 -0
  202. package/include/numkong/sets/serial.h +43 -0
  203. package/include/numkong/sets/smebi32.h +1099 -0
  204. package/include/numkong/sets/v128relaxed.h +58 -0
  205. package/include/numkong/sets.h +339 -0
  206. package/include/numkong/sparse/README.md +156 -0
  207. package/include/numkong/sparse/icelake.h +463 -0
  208. package/include/numkong/sparse/neon.h +288 -0
  209. package/include/numkong/sparse/serial.h +117 -0
  210. package/include/numkong/sparse/sve2.h +507 -0
  211. package/include/numkong/sparse/turin.h +322 -0
  212. package/include/numkong/sparse.h +363 -0
  213. package/include/numkong/sparse.hpp +113 -0
  214. package/include/numkong/spatial/README.md +435 -0
  215. package/include/numkong/spatial/alder.h +607 -0
  216. package/include/numkong/spatial/genoa.h +290 -0
  217. package/include/numkong/spatial/haswell.h +960 -0
  218. package/include/numkong/spatial/icelake.h +586 -0
  219. package/include/numkong/spatial/neon.h +773 -0
  220. package/include/numkong/spatial/neonbfdot.h +165 -0
  221. package/include/numkong/spatial/neonhalf.h +118 -0
  222. package/include/numkong/spatial/neonsdot.h +261 -0
  223. package/include/numkong/spatial/rvv.h +984 -0
  224. package/include/numkong/spatial/rvvbf16.h +123 -0
  225. package/include/numkong/spatial/rvvhalf.h +117 -0
  226. package/include/numkong/spatial/sapphire.h +343 -0
  227. package/include/numkong/spatial/serial.h +346 -0
  228. package/include/numkong/spatial/sierra.h +323 -0
  229. package/include/numkong/spatial/skylake.h +606 -0
  230. package/include/numkong/spatial/sve.h +224 -0
  231. package/include/numkong/spatial/svebfdot.h +122 -0
  232. package/include/numkong/spatial/svehalf.h +109 -0
  233. package/include/numkong/spatial/v128relaxed.h +717 -0
  234. package/include/numkong/spatial.h +1425 -0
  235. package/include/numkong/spatial.hpp +183 -0
  236. package/include/numkong/spatials/README.md +580 -0
  237. package/include/numkong/spatials/alder.h +94 -0
  238. package/include/numkong/spatials/genoa.h +94 -0
  239. package/include/numkong/spatials/haswell.h +219 -0
  240. package/include/numkong/spatials/icelake.h +113 -0
  241. package/include/numkong/spatials/neon.h +109 -0
  242. package/include/numkong/spatials/neonbfdot.h +60 -0
  243. package/include/numkong/spatials/neonfhm.h +92 -0
  244. package/include/numkong/spatials/neonhalf.h +58 -0
  245. package/include/numkong/spatials/neonsdot.h +109 -0
  246. package/include/numkong/spatials/rvv.h +1960 -0
  247. package/include/numkong/spatials/sapphireamx.h +1149 -0
  248. package/include/numkong/spatials/serial.h +226 -0
  249. package/include/numkong/spatials/sierra.h +96 -0
  250. package/include/numkong/spatials/skylake.h +184 -0
  251. package/include/numkong/spatials/sme.h +1901 -0
  252. package/include/numkong/spatials/smef64.h +465 -0
  253. package/include/numkong/spatials/v128relaxed.h +240 -0
  254. package/include/numkong/spatials.h +3021 -0
  255. package/include/numkong/spatials.hpp +508 -0
  256. package/include/numkong/tensor.hpp +1592 -0
  257. package/include/numkong/trigonometry/README.md +184 -0
  258. package/include/numkong/trigonometry/haswell.h +652 -0
  259. package/include/numkong/trigonometry/neon.h +639 -0
  260. package/include/numkong/trigonometry/rvv.h +699 -0
  261. package/include/numkong/trigonometry/serial.h +703 -0
  262. package/include/numkong/trigonometry/skylake.h +721 -0
  263. package/include/numkong/trigonometry/v128relaxed.h +666 -0
  264. package/include/numkong/trigonometry.h +467 -0
  265. package/include/numkong/trigonometry.hpp +166 -0
  266. package/include/numkong/types.h +1384 -0
  267. package/include/numkong/types.hpp +5603 -0
  268. package/include/numkong/vector.hpp +698 -0
  269. package/javascript/README.md +246 -0
  270. package/javascript/dist/cjs/numkong-wasm.d.ts +166 -0
  271. package/javascript/dist/cjs/numkong-wasm.js +617 -0
  272. package/javascript/dist/cjs/numkong.d.ts +343 -0
  273. package/javascript/dist/cjs/numkong.js +523 -0
  274. package/javascript/dist/cjs/package.json +3 -0
  275. package/javascript/dist/cjs/types.d.ts +284 -0
  276. package/javascript/dist/cjs/types.js +653 -0
  277. package/javascript/dist/esm/numkong-wasm.d.ts +166 -0
  278. package/javascript/dist/esm/numkong-wasm.js +595 -0
  279. package/javascript/dist/esm/numkong.d.ts +343 -0
  280. package/javascript/dist/esm/numkong.js +452 -0
  281. package/javascript/dist/esm/package.json +3 -0
  282. package/javascript/dist/esm/types.d.ts +284 -0
  283. package/javascript/dist/esm/types.js +630 -0
  284. package/javascript/dist-package-cjs.json +3 -0
  285. package/javascript/dist-package-esm.json +3 -0
  286. package/javascript/node-gyp-build.d.ts +1 -0
  287. package/javascript/numkong-wasm.ts +756 -0
  288. package/javascript/numkong.c +689 -0
  289. package/javascript/numkong.ts +575 -0
  290. package/javascript/tsconfig-base.json +39 -0
  291. package/javascript/tsconfig-cjs.json +8 -0
  292. package/javascript/tsconfig-esm.json +8 -0
  293. package/javascript/types.ts +674 -0
  294. package/package.json +87 -0
@@ -0,0 +1,617 @@
1
+ "use strict";
2
+ /**
3
+ * @brief WASM wrapper for NumKong providing N-API compatible interface
4
+ * @file javascript/numkong-wasm.ts
5
+ * @date February 6, 2026
6
+ *
7
+ * This module wraps the Emscripten-compiled WASM module to provide the same
8
+ * TypeScript API as the native N-API bindings. It handles:
9
+ * - Zero-copy TensorBase interop for cross-module WASM sharing
10
+ * - TypedArray type detection and dispatch
11
+ * - Result extraction from WASM heap
12
+ * - Error handling
13
+ * - Both wasm32 and wasm64 (memory64) modes
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.inner = void 0;
17
+ exports.initWasm = initWasm;
18
+ exports.sqeuclidean = sqeuclidean;
19
+ exports.euclidean = euclidean;
20
+ exports.angular = angular;
21
+ exports.dot = dot;
22
+ exports.hamming = hamming;
23
+ exports.jaccard = jaccard;
24
+ exports.kullbackleibler = kullbackleibler;
25
+ exports.jensenshannon = jensenshannon;
26
+ exports.getCapabilities = getCapabilities;
27
+ exports.hasCapability = hasCapability;
28
+ exports.dotsPackedSize = dotsPackedSize;
29
+ exports.dotsPack = dotsPack;
30
+ exports.dotsPacked = dotsPacked;
31
+ exports.angularsPacked = angularsPacked;
32
+ exports.euclideansPacked = euclideansPacked;
33
+ exports.dotsSymmetric = dotsSymmetric;
34
+ exports.angularsSymmetric = angularsSymmetric;
35
+ exports.euclideansSymmetric = euclideansSymmetric;
36
+ const types_js_1 = require("./types.js");
37
+ let Module = null;
38
+ /**
39
+ * Whether the WASM module uses memory64.
40
+ * In memory64 mode, Emscripten wraps _malloc/_free to accept/return number,
41
+ * but raw C function exports expect BigInt (i64) for pointer parameters.
42
+ * nk_size_t is always i32 (number) in WASM since NK_IS_64BIT_=0.
43
+ */
44
+ let isMemory64 = false;
45
+ // Pre-allocated 8-byte result buffer (covers f64/f32/i32/u32), allocated once in initWasm()
46
+ // Always a number (from Emscripten-wrapped _malloc), converted to WasmPtr for C calls
47
+ let resultPtr = 0;
48
+ // Heap views (created from wasmMemory buffer)
49
+ let HEAP8;
50
+ let HEAP16;
51
+ let HEAP32;
52
+ let HEAPU8;
53
+ let HEAPU16;
54
+ let HEAPU32;
55
+ let HEAPF32;
56
+ let HEAPF64;
57
+ /**
58
+ * Convert a number (e.g. from _malloc or byteOffset) to the pointer type
59
+ * expected by raw C function exports. In wasm64, pointers are i64 (BigInt).
60
+ */
61
+ function toWasmPtr(n) {
62
+ return isMemory64 ? BigInt(n) : n;
63
+ }
64
+ /**
65
+ * Initializes the WASM backend with an Emscripten module instance.
66
+ * @param wasmModule - The Emscripten-compiled WASM module to use.
67
+ */
68
+ function initWasm(wasmModule) {
69
+ Module = wasmModule;
70
+ // Create heap views from the WASM memory buffer
71
+ const buffer = wasmModule.wasmMemory.buffer;
72
+ HEAP8 = new Int8Array(buffer);
73
+ HEAP16 = new Int16Array(buffer);
74
+ HEAP32 = new Int32Array(buffer);
75
+ HEAPU8 = new Uint8Array(buffer);
76
+ HEAPU16 = new Uint16Array(buffer);
77
+ HEAPU32 = new Uint32Array(buffer);
78
+ HEAPF32 = new Float32Array(buffer);
79
+ HEAPF64 = new Float64Array(buffer);
80
+ // Detect memory64 mode by probing whether raw C functions expect BigInt pointers.
81
+ // Emscripten wraps _malloc/_free to always use number, but raw C exports use i64
82
+ // (BigInt) for pointers in memory64 mode. We probe by calling a distance function
83
+ // with BigInt(0) args — if it doesn't throw, we're in memory64 mode.
84
+ try {
85
+ const probe = wasmModule._malloc(8);
86
+ wasmModule._nk_dot_f32(BigInt(probe), BigInt(probe), 0, BigInt(probe));
87
+ isMemory64 = true;
88
+ wasmModule._free(probe);
89
+ }
90
+ catch {
91
+ isMemory64 = false;
92
+ }
93
+ // Pre-allocate an 8-byte result buffer (never freed during module lifetime)
94
+ // _malloc always returns number (Emscripten-wrapped in both modes)
95
+ resultPtr = wasmModule._malloc(8);
96
+ }
97
+ /**
98
+ * Detect dtype from TypedArray constructor
99
+ */
100
+ function detectType(arr) {
101
+ if (arr instanceof Float64Array) {
102
+ return { dtype: types_js_1.DType.F64, bytesPerElement: 8, heapView: 'HEAPF64', resultType: 'f64' };
103
+ }
104
+ else if (arr instanceof Float32Array) {
105
+ return { dtype: types_js_1.DType.F32, bytesPerElement: 4, heapView: 'HEAPF32', resultType: 'f64' };
106
+ }
107
+ else if (arr instanceof Int8Array) {
108
+ return { dtype: types_js_1.DType.I8, bytesPerElement: 1, heapView: 'HEAP8', resultType: 'i32' };
109
+ }
110
+ else if (arr instanceof Uint8Array) {
111
+ return { dtype: types_js_1.DType.U8, bytesPerElement: 1, heapView: 'HEAPU8', resultType: 'u32' };
112
+ }
113
+ // Check for custom typed arrays from types.ts
114
+ const constructorName = arr.constructor.name;
115
+ if (constructorName === 'Float16Array') {
116
+ return { dtype: types_js_1.DType.F16, bytesPerElement: 2, heapView: 'HEAPU16', resultType: 'f32' };
117
+ }
118
+ else if (constructorName === 'BFloat16Array') {
119
+ return { dtype: types_js_1.DType.BF16, bytesPerElement: 2, heapView: 'HEAPU16', resultType: 'f32' };
120
+ }
121
+ else if (constructorName === 'E4M3Array') {
122
+ throw new Error('E4M3 not yet supported in WASM backend');
123
+ }
124
+ else if (constructorName === 'E5M2Array') {
125
+ throw new Error('E5M2 not yet supported in WASM backend');
126
+ }
127
+ else if (constructorName === 'BinaryArray') {
128
+ return { dtype: types_js_1.DType.U1, bytesPerElement: 1, heapView: 'HEAPU8', resultType: 'u32' };
129
+ }
130
+ throw new Error(`Unsupported array type: ${constructorName}`);
131
+ }
132
+ /**
133
+ * Get TypeInfo from a DType enum value.
134
+ */
135
+ function typeInfoFromDtype(dtype) {
136
+ switch (dtype) {
137
+ case types_js_1.DType.F64: return { dtype, bytesPerElement: 8, heapView: 'HEAPF64', resultType: 'f64' };
138
+ case types_js_1.DType.F32: return { dtype, bytesPerElement: 4, heapView: 'HEAPF32', resultType: 'f64' };
139
+ case types_js_1.DType.F16: return { dtype, bytesPerElement: 2, heapView: 'HEAPU16', resultType: 'f32' };
140
+ case types_js_1.DType.BF16: return { dtype, bytesPerElement: 2, heapView: 'HEAPU16', resultType: 'f32' };
141
+ case types_js_1.DType.I8: return { dtype, bytesPerElement: 1, heapView: 'HEAP8', resultType: 'i32' };
142
+ case types_js_1.DType.U8: return { dtype, bytesPerElement: 1, heapView: 'HEAPU8', resultType: 'u32' };
143
+ case types_js_1.DType.U1: return { dtype, bytesPerElement: 1, heapView: 'HEAPU8', resultType: 'u32' };
144
+ default: throw new Error(`Unsupported dtype: ${dtype}`);
145
+ }
146
+ }
147
+ /**
148
+ * Resolve an input that may be a TensorBase or a TypedArray into a uniform
149
+ * ResolvedInput for distance dispatch.
150
+ */
151
+ function resolveInput(a) {
152
+ if (a instanceof types_js_1.TensorBase) {
153
+ return {
154
+ buffer: a.buffer, byteOffset: a.byteOffset,
155
+ length: a.length, byteLength: a.byteLength,
156
+ typeInfo: typeInfoFromDtype(a.dtype),
157
+ };
158
+ }
159
+ const typeInfo = detectType(a);
160
+ return {
161
+ buffer: a.buffer, byteOffset: a.byteOffset,
162
+ length: a.length, byteLength: a.length * typeInfo.bytesPerElement,
163
+ typeInfo,
164
+ };
165
+ }
166
+ /**
167
+ * Allocate WASM memory and copy data into it.
168
+ * Returns a number byte-offset (from Emscripten-wrapped _malloc).
169
+ */
170
+ function allocAndCopyResolved(buffer, byteOffset, byteLength) {
171
+ if (!Module)
172
+ throw new Error('WASM module not initialized');
173
+ const ptr = Module._malloc(byteLength);
174
+ const src = new Uint8Array(buffer, byteOffset, byteLength);
175
+ HEAPU8.set(src, ptr);
176
+ return ptr;
177
+ }
178
+ /**
179
+ * Read result from WASM heap. ptr is a number byte-offset.
180
+ */
181
+ function readResult(ptr, resultType) {
182
+ if (!Module)
183
+ throw new Error('WASM module not initialized');
184
+ switch (resultType) {
185
+ case 'f64':
186
+ return HEAPF64[ptr / 8];
187
+ case 'f32':
188
+ return HEAPF32[ptr / 4];
189
+ case 'i32':
190
+ return HEAP32[ptr / 4];
191
+ case 'u32':
192
+ return HEAPU32[ptr / 4];
193
+ }
194
+ }
195
+ /**
196
+ * Generic distance function wrapper.
197
+ * Uses zero-copy when arrays already live on the WASM heap.
198
+ */
199
+ function distance(metric, a, b) {
200
+ if (!Module) {
201
+ throw new Error('WASM module not initialized. Call initWasm() first.');
202
+ }
203
+ const resolvedA = resolveInput(a);
204
+ const resolvedB = resolveInput(b);
205
+ if (resolvedA.length !== resolvedB.length) {
206
+ throw new Error(`Array length mismatch: ${resolvedA.length} !== ${resolvedB.length}`);
207
+ }
208
+ const n = resolvedA.length;
209
+ // Zero-copy: if the buffer IS the WASM memory, byteOffset is the pointer (number)
210
+ const isOnHeapA = resolvedA.buffer === Module.wasmMemory.buffer;
211
+ const isOnHeapB = resolvedB.buffer === Module.wasmMemory.buffer;
212
+ const aOff = isOnHeapA ? resolvedA.byteOffset : allocAndCopyResolved(resolvedA.buffer, resolvedA.byteOffset, resolvedA.byteLength);
213
+ const bOff = isOnHeapB ? resolvedB.byteOffset : allocAndCopyResolved(resolvedB.buffer, resolvedB.byteOffset, resolvedB.byteLength);
214
+ try {
215
+ // Call C function
216
+ const fnName = `_nk_${metric}_${(0, types_js_1.dtypeToString)(resolvedA.typeInfo.dtype)}`;
217
+ const fn = Module[fnName];
218
+ if (!fn || typeof fn !== 'function') {
219
+ throw new Error(`Function ${fnName} not available in WASM module`);
220
+ }
221
+ // In wasm64, raw C exports expect BigInt for pointer args; nk_size_t is always i32 (number)
222
+ fn(toWasmPtr(aOff), toWasmPtr(bOff), n, toWasmPtr(resultPtr));
223
+ // Read result
224
+ return readResult(resultPtr, resolvedA.typeInfo.resultType);
225
+ }
226
+ finally {
227
+ // _free is Emscripten-wrapped: always takes number
228
+ if (!isOnHeapA)
229
+ Module._free(aOff);
230
+ if (!isOnHeapB)
231
+ Module._free(bOff);
232
+ }
233
+ }
234
+ /**
235
+ * Computes the squared Euclidean distance between two vectors.
236
+ * @param a - First vector (TypedArray or TensorBase).
237
+ * @param b - Second vector (must match type and length of a).
238
+ * @returns The squared Euclidean distance between a and b.
239
+ */
240
+ function sqeuclidean(a, b) {
241
+ return distance('sqeuclidean', a, b);
242
+ }
243
+ /**
244
+ * Computes the Euclidean distance between two vectors.
245
+ * @param a - First vector (TypedArray or TensorBase).
246
+ * @param b - Second vector (must match type and length of a).
247
+ * @returns The Euclidean distance between a and b.
248
+ */
249
+ function euclidean(a, b) {
250
+ return distance('euclidean', a, b);
251
+ }
252
+ /**
253
+ * Computes the angular distance between two vectors.
254
+ * @param a - First vector (TypedArray or TensorBase).
255
+ * @param b - Second vector (must match type and length of a).
256
+ * @returns The angular distance between a and b.
257
+ */
258
+ function angular(a, b) {
259
+ return distance('angular', a, b);
260
+ }
261
+ /**
262
+ * Computes the dot product of two vectors.
263
+ * @param a - First vector (TypedArray or TensorBase).
264
+ * @param b - Second vector (must match type and length of a).
265
+ * @returns The dot product of a and b.
266
+ */
267
+ function dot(a, b) {
268
+ return distance('dot', a, b);
269
+ }
270
+ /** Alias for {@link dot}. */
271
+ exports.inner = dot;
272
+ /**
273
+ * Computes the bitwise Hamming distance between two vectors.
274
+ *
275
+ * Following N-API behavior, always treats input as u1 (binary/bit-packed),
276
+ * even if passed as Uint8Array. Each byte represents 8 bits.
277
+ *
278
+ * @param a - First bit-packed vector (Uint8Array or TensorBase).
279
+ * @param b - Second bit-packed vector (must match length of a).
280
+ * @returns The Hamming distance (number of differing bits) between a and b.
281
+ */
282
+ function hamming(a, b) {
283
+ if (!Module) {
284
+ throw new Error('WASM module not initialized');
285
+ }
286
+ // Extract flat fields; for raw TypedArrays treat as u1 (binary/bit-packed)
287
+ const bufferA = a.buffer, offsetA = a.byteOffset, lengthA = a.length;
288
+ const bufferB = b.buffer, offsetB = b.byteOffset, lengthB = b.length;
289
+ const byteLengthA = a instanceof types_js_1.TensorBase ? a.byteLength : lengthA;
290
+ const byteLengthB = b instanceof types_js_1.TensorBase ? b.byteLength : lengthB;
291
+ if (lengthA !== lengthB) {
292
+ throw new Error(`Array length mismatch: ${lengthA} !== ${lengthB}`);
293
+ }
294
+ const isOnHeapA = bufferA === Module.wasmMemory.buffer;
295
+ const isOnHeapB = bufferB === Module.wasmMemory.buffer;
296
+ const aOff = isOnHeapA ? offsetA : allocAndCopyResolved(bufferA, offsetA, byteLengthA);
297
+ const bOff = isOnHeapB ? offsetB : allocAndCopyResolved(bufferB, offsetB, byteLengthB);
298
+ try {
299
+ const fn = Module._nk_hamming_u1;
300
+ if (!fn || typeof fn !== 'function') {
301
+ throw new Error('Function _nk_hamming_u1 not available in WASM module');
302
+ }
303
+ fn(toWasmPtr(aOff), toWasmPtr(bOff), lengthA, toWasmPtr(resultPtr));
304
+ return readResult(resultPtr, 'u32');
305
+ }
306
+ finally {
307
+ if (!isOnHeapA)
308
+ Module._free(aOff);
309
+ if (!isOnHeapB)
310
+ Module._free(bOff);
311
+ }
312
+ }
313
+ /**
314
+ * Computes the bitwise Jaccard distance between two vectors.
315
+ *
316
+ * Following N-API behavior, always treats input as u1 (binary/bit-packed),
317
+ * even if passed as Uint8Array. Each byte represents 8 bits.
318
+ *
319
+ * @param a - First bit-packed vector (Uint8Array or TensorBase).
320
+ * @param b - Second bit-packed vector (must match length of a).
321
+ * @returns The Jaccard distance (1 - Jaccard similarity) between a and b.
322
+ */
323
+ function jaccard(a, b) {
324
+ if (!Module) {
325
+ throw new Error('WASM module not initialized');
326
+ }
327
+ // Extract flat fields; for raw TypedArrays treat as u1 (binary/bit-packed)
328
+ const bufferA = a.buffer, offsetA = a.byteOffset, lengthA = a.length;
329
+ const bufferB = b.buffer, offsetB = b.byteOffset, lengthB = b.length;
330
+ const byteLengthA = a instanceof types_js_1.TensorBase ? a.byteLength : lengthA;
331
+ const byteLengthB = b instanceof types_js_1.TensorBase ? b.byteLength : lengthB;
332
+ if (lengthA !== lengthB) {
333
+ throw new Error(`Array length mismatch: ${lengthA} !== ${lengthB}`);
334
+ }
335
+ const isOnHeapA = bufferA === Module.wasmMemory.buffer;
336
+ const isOnHeapB = bufferB === Module.wasmMemory.buffer;
337
+ const aOff = isOnHeapA ? offsetA : allocAndCopyResolved(bufferA, offsetA, byteLengthA);
338
+ const bOff = isOnHeapB ? offsetB : allocAndCopyResolved(bufferB, offsetB, byteLengthB);
339
+ try {
340
+ const fn = Module._nk_jaccard_u1;
341
+ if (!fn || typeof fn !== 'function') {
342
+ throw new Error('Function _nk_jaccard_u1 not available in WASM module');
343
+ }
344
+ fn(toWasmPtr(aOff), toWasmPtr(bOff), lengthA, toWasmPtr(resultPtr));
345
+ return readResult(resultPtr, 'f32');
346
+ }
347
+ finally {
348
+ if (!isOnHeapA)
349
+ Module._free(aOff);
350
+ if (!isOnHeapB)
351
+ Module._free(bOff);
352
+ }
353
+ }
354
+ /**
355
+ * Computes the Kullback-Leibler divergence between two probability distributions.
356
+ * @param a - First probability distribution (Float32Array, Float64Array, or TensorBase).
357
+ * @param b - Second probability distribution (must match type and length of a).
358
+ * @returns The KL divergence KL(a || b).
359
+ */
360
+ function kullbackleibler(a, b) {
361
+ if (!Module) {
362
+ throw new Error('WASM module not initialized');
363
+ }
364
+ const resolvedA = resolveInput(a);
365
+ const resolvedB = resolveInput(b);
366
+ if (resolvedA.length !== resolvedB.length) {
367
+ throw new Error(`Array length mismatch: ${resolvedA.length} !== ${resolvedB.length}`);
368
+ }
369
+ const n = resolvedA.length;
370
+ const isOnHeapA = resolvedA.buffer === Module.wasmMemory.buffer;
371
+ const isOnHeapB = resolvedB.buffer === Module.wasmMemory.buffer;
372
+ const aOff = isOnHeapA ? resolvedA.byteOffset : allocAndCopyResolved(resolvedA.buffer, resolvedA.byteOffset, resolvedA.byteLength);
373
+ const bOff = isOnHeapB ? resolvedB.byteOffset : allocAndCopyResolved(resolvedB.buffer, resolvedB.byteOffset, resolvedB.byteLength);
374
+ try {
375
+ const fnName = `_nk_kld_${(0, types_js_1.dtypeToString)(resolvedA.typeInfo.dtype)}`;
376
+ const fn = Module[fnName];
377
+ if (!fn || typeof fn !== 'function') {
378
+ throw new Error(`Function ${fnName} not available in WASM module`);
379
+ }
380
+ fn(toWasmPtr(aOff), toWasmPtr(bOff), n, toWasmPtr(resultPtr));
381
+ return readResult(resultPtr, resolvedA.typeInfo.resultType);
382
+ }
383
+ finally {
384
+ if (!isOnHeapA)
385
+ Module._free(aOff);
386
+ if (!isOnHeapB)
387
+ Module._free(bOff);
388
+ }
389
+ }
390
+ /**
391
+ * Computes the Jensen-Shannon distance between two probability distributions.
392
+ * @param a - First probability distribution (Float32Array, Float64Array, or TensorBase).
393
+ * @param b - Second probability distribution (must match type and length of a).
394
+ * @returns The Jensen-Shannon distance between a and b.
395
+ */
396
+ function jensenshannon(a, b) {
397
+ if (!Module) {
398
+ throw new Error('WASM module not initialized');
399
+ }
400
+ const resolvedA = resolveInput(a);
401
+ const resolvedB = resolveInput(b);
402
+ if (resolvedA.length !== resolvedB.length) {
403
+ throw new Error(`Array length mismatch: ${resolvedA.length} !== ${resolvedB.length}`);
404
+ }
405
+ const n = resolvedA.length;
406
+ const isOnHeapA = resolvedA.buffer === Module.wasmMemory.buffer;
407
+ const isOnHeapB = resolvedB.buffer === Module.wasmMemory.buffer;
408
+ const aOff = isOnHeapA ? resolvedA.byteOffset : allocAndCopyResolved(resolvedA.buffer, resolvedA.byteOffset, resolvedA.byteLength);
409
+ const bOff = isOnHeapB ? resolvedB.byteOffset : allocAndCopyResolved(resolvedB.buffer, resolvedB.byteOffset, resolvedB.byteLength);
410
+ try {
411
+ const fnName = `_nk_jsd_${(0, types_js_1.dtypeToString)(resolvedA.typeInfo.dtype)}`;
412
+ const fn = Module[fnName];
413
+ if (!fn || typeof fn !== 'function') {
414
+ throw new Error(`Function ${fnName} not available in WASM module`);
415
+ }
416
+ fn(toWasmPtr(aOff), toWasmPtr(bOff), n, toWasmPtr(resultPtr));
417
+ return readResult(resultPtr, resolvedA.typeInfo.resultType);
418
+ }
419
+ finally {
420
+ if (!isOnHeapA)
421
+ Module._free(aOff);
422
+ if (!isOnHeapB)
423
+ Module._free(bOff);
424
+ }
425
+ }
426
+ /**
427
+ * Returns the runtime-detected SIMD capabilities as a bitmask.
428
+ * @returns Bitmask of capability flags (use with Capability constants).
429
+ */
430
+ function getCapabilities() {
431
+ if (!Module) {
432
+ throw new Error('WASM module not initialized');
433
+ }
434
+ // nk_capabilities returns a 64-bit value
435
+ const caps = Module._nk_capabilities();
436
+ // In wasm64, caps is already bigint; in wasm32, it's a number
437
+ return typeof caps === 'bigint' ? caps : BigInt(caps);
438
+ }
439
+ /**
440
+ * Checks if a specific SIMD capability is available at runtime.
441
+ * @param cap - Capability flag to check (from Capability constants).
442
+ * @returns True if the capability is available.
443
+ */
444
+ function hasCapability(cap) {
445
+ return (getCapabilities() & cap) !== 0n;
446
+ }
447
+ let packedRegistry = null;
448
+ /**
449
+ * WASM-backed PackedMatrix that owns a WASM heap allocation.
450
+ */
451
+ class WasmPackedMatrix extends types_js_1.PackedMatrix {
452
+ constructor(heapPointer, byteLength, width, depth, dtype) {
453
+ // Create a JS ArrayBuffer that is a copy of the WASM heap region for read access
454
+ const buffer = new ArrayBuffer(byteLength);
455
+ new Uint8Array(buffer).set(HEAPU8.subarray(heapPointer, heapPointer + byteLength));
456
+ super(buffer, width, depth, dtype, byteLength);
457
+ this._wasmDisposed = false;
458
+ this._heapPointer = heapPointer;
459
+ // Register with FinalizationRegistry as safety net
460
+ if (!packedRegistry && typeof FinalizationRegistry !== 'undefined') {
461
+ packedRegistry = new FinalizationRegistry((ptr) => {
462
+ if (Module)
463
+ Module._free(ptr);
464
+ });
465
+ }
466
+ if (packedRegistry) {
467
+ packedRegistry.register(this, heapPointer);
468
+ }
469
+ }
470
+ get heapPointer() { return this._heapPointer; }
471
+ dispose() {
472
+ if (!this._wasmDisposed && Module) {
473
+ Module._free(this._heapPointer);
474
+ this._wasmDisposed = true;
475
+ }
476
+ // Call parent dispose to set disposed flag
477
+ super.dispose();
478
+ }
479
+ }
480
+ /**
481
+ * Allocate WASM heap, copy matrix data, return pointer. Caller must free.
482
+ */
483
+ function allocAndCopyMatrix(matrix) {
484
+ const byteLength = matrix.rows * matrix.rowStride;
485
+ return allocAndCopyResolved(matrix.buffer, matrix.byteOffset, byteLength);
486
+ }
487
+ /**
488
+ * Query the packed buffer byte count for a given matrix shape and dtype.
489
+ */
490
+ function dotsPackedSize(width, depth, dtype) {
491
+ if (!Module)
492
+ throw new Error('WASM module not initialized');
493
+ const fnName = `_nk_dots_packed_size_${(0, types_js_1.dtypeToString)(dtype)}`;
494
+ const fn = Module[fnName];
495
+ if (!fn || typeof fn !== 'function') {
496
+ throw new Error(`Function ${fnName} not available in WASM module`);
497
+ }
498
+ return fn(width, depth);
499
+ }
500
+ /**
501
+ * Pack a Matrix for use with packed GEMM-like operations.
502
+ */
503
+ function dotsPack(matrix) {
504
+ if (!Module)
505
+ throw new Error('WASM module not initialized');
506
+ const dtypeStr = (0, types_js_1.dtypeToString)(matrix.dtype);
507
+ const sizeFnName = `_nk_dots_packed_size_${dtypeStr}`;
508
+ const packFnName = `_nk_dots_pack_${dtypeStr}`;
509
+ const sizeFn = Module[sizeFnName];
510
+ const packFn = Module[packFnName];
511
+ if (!sizeFn || !packFn) {
512
+ throw new Error(`Pack functions not available for dtype ${dtypeStr}`);
513
+ }
514
+ const packedByteCount = sizeFn(matrix.rows, matrix.cols);
515
+ const packedPtr = Module._malloc(packedByteCount);
516
+ const matrixPtr = allocAndCopyMatrix(matrix);
517
+ try {
518
+ packFn(toWasmPtr(matrixPtr), matrix.rows, matrix.cols, matrix.rowStride, toWasmPtr(packedPtr));
519
+ }
520
+ finally {
521
+ Module._free(matrixPtr);
522
+ }
523
+ return new WasmPackedMatrix(packedPtr, packedByteCount, matrix.rows, matrix.cols, matrix.dtype);
524
+ }
525
+ function wasmPackedOperation(metricPrefix, family, a, packed, out) {
526
+ if (!Module)
527
+ throw new Error('WASM module not initialized');
528
+ if (a.cols !== packed.depth) {
529
+ throw new Error(`Matrix cols (${a.cols}) must match packed depth (${packed.depth})`);
530
+ }
531
+ const outDtype = (0, types_js_1.outputDtype)(family, a.dtype);
532
+ if (!out) {
533
+ out = new types_js_1.Matrix(a.rows, packed.width, outDtype);
534
+ }
535
+ const dtypeStr = (0, types_js_1.dtypeToString)(a.dtype);
536
+ const fnName = `_nk_${metricPrefix}_${dtypeStr}`;
537
+ const fn = Module[fnName];
538
+ if (!fn || typeof fn !== 'function') {
539
+ throw new Error(`Function ${fnName} not available in WASM module`);
540
+ }
541
+ const outBpe = out.bytesPerElement;
542
+ const resultByteLength = out.rows * out.cols * outBpe;
543
+ const aPtr = allocAndCopyMatrix(a);
544
+ const resultPtr = Module._malloc(resultByteLength);
545
+ // For WasmPackedMatrix, copy the packed data to heap; otherwise use the buffer directly
546
+ let packedPtr;
547
+ let packedAllocated = false;
548
+ if (packed instanceof WasmPackedMatrix) {
549
+ // The heap pointer may have been freed if disposed; re-copy from JS buffer
550
+ packedPtr = allocAndCopyResolved(packed.buffer, 0, packed.byteLength);
551
+ packedAllocated = true;
552
+ }
553
+ else {
554
+ packedPtr = allocAndCopyResolved(packed.buffer, 0, packed.byteLength);
555
+ packedAllocated = true;
556
+ }
557
+ try {
558
+ fn(toWasmPtr(aPtr), toWasmPtr(packedPtr), toWasmPtr(resultPtr), a.rows, packed.width, a.cols, a.rowStride, out.rowStride);
559
+ // Copy result back
560
+ const outArray = new Uint8Array(out.buffer, out.byteOffset, resultByteLength);
561
+ outArray.set(HEAPU8.subarray(resultPtr, resultPtr + resultByteLength));
562
+ }
563
+ finally {
564
+ Module._free(aPtr);
565
+ Module._free(resultPtr);
566
+ if (packedAllocated)
567
+ Module._free(packedPtr);
568
+ }
569
+ return out;
570
+ }
571
+ function wasmSymmetricOperation(metricPrefix, family, vectors, out, rowStart = 0, rowCount) {
572
+ if (!Module)
573
+ throw new Error('WASM module not initialized');
574
+ const count = rowCount ?? vectors.rows - rowStart;
575
+ const outDtype = (0, types_js_1.outputDtype)(family, vectors.dtype);
576
+ if (!out) {
577
+ out = new types_js_1.Matrix(vectors.rows, vectors.rows, outDtype);
578
+ }
579
+ const dtypeStr = (0, types_js_1.dtypeToString)(vectors.dtype);
580
+ const fnName = `_nk_${metricPrefix}_${dtypeStr}`;
581
+ const fn = Module[fnName];
582
+ if (!fn || typeof fn !== 'function') {
583
+ throw new Error(`Function ${fnName} not available in WASM module`);
584
+ }
585
+ const resultByteLength = out.rows * out.cols * out.bytesPerElement;
586
+ const vectorsPtr = allocAndCopyMatrix(vectors);
587
+ const resultPtr = Module._malloc(resultByteLength);
588
+ try {
589
+ fn(toWasmPtr(vectorsPtr), vectors.rows, vectors.cols, vectors.rowStride, toWasmPtr(resultPtr), out.rowStride, rowStart, count);
590
+ // Copy result back
591
+ const outArray = new Uint8Array(out.buffer, out.byteOffset, resultByteLength);
592
+ outArray.set(HEAPU8.subarray(resultPtr, resultPtr + resultByteLength));
593
+ }
594
+ finally {
595
+ Module._free(vectorsPtr);
596
+ Module._free(resultPtr);
597
+ }
598
+ return out;
599
+ }
600
+ function dotsPacked(a, packed, out) {
601
+ return wasmPackedOperation('dots_packed', 'dots', a, packed, out);
602
+ }
603
+ function angularsPacked(a, packed, out) {
604
+ return wasmPackedOperation('angulars_packed', 'angulars', a, packed, out);
605
+ }
606
+ function euclideansPacked(a, packed, out) {
607
+ return wasmPackedOperation('euclideans_packed', 'euclideans', a, packed, out);
608
+ }
609
+ function dotsSymmetric(vectors, out, options) {
610
+ return wasmSymmetricOperation('dots_symmetric', 'dots', vectors, out, options?.rowStart ?? 0, options?.rowCount);
611
+ }
612
+ function angularsSymmetric(vectors, out, options) {
613
+ return wasmSymmetricOperation('angulars_symmetric', 'angulars', vectors, out, options?.rowStart ?? 0, options?.rowCount);
614
+ }
615
+ function euclideansSymmetric(vectors, out, options) {
616
+ return wasmSymmetricOperation('euclideans_symmetric', 'euclideans', vectors, out, options?.rowStart ?? 0, options?.rowCount);
617
+ }