usearch 2.9.1 → 2.10.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 (169) hide show
  1. package/README.md +50 -52
  2. package/javascript/{types → dist/cjs}/usearch.d.ts +90 -115
  3. package/javascript/dist/cjs/usearch.js +531 -0
  4. package/javascript/dist/esm/usearch.d.ts +212 -0
  5. package/javascript/{usearch.js → dist/esm/usearch.js} +202 -153
  6. package/package.json +25 -23
  7. package/prebuilds/darwin-arm64+x64/usearch.node +0 -0
  8. package/prebuilds/linux-arm64/usearch.node +0 -0
  9. package/prebuilds/linux-x64/usearch.node +0 -0
  10. package/prebuilds/win32-ia32/usearch.node +0 -0
  11. package/prebuilds/win32-x64/usearch.node +0 -0
  12. package/.clang-format +0 -10
  13. package/.clang-tidy +0 -60
  14. package/.cmake-format.py +0 -19
  15. package/.dockerignore +0 -93
  16. package/.gitattributes +0 -9
  17. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -90
  18. package/.github/ISSUE_TEMPLATE/config.yml +0 -5
  19. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -64
  20. package/.github/workflows/Dockerfile.libs +0 -36
  21. package/.github/workflows/prerelease.yml +0 -331
  22. package/.github/workflows/release.yml +0 -722
  23. package/.github/workflows/update_version.sh +0 -15
  24. package/.gitmodules +0 -9
  25. package/.releaserc +0 -90
  26. package/CITATION.cff +0 -11
  27. package/CMakeLists.txt +0 -324
  28. package/CODE_OF_CONDUCT.md +0 -128
  29. package/CONTRIBUTING.md +0 -353
  30. package/Cargo.toml +0 -19
  31. package/Dockerfile +0 -16
  32. package/VERSION +0 -1
  33. package/assets/unum.png +0 -0
  34. package/assets/usearch-approaches-transparent.png +0 -0
  35. package/assets/usearch-approaches-white.png +0 -0
  36. package/assets/usearch-neighbor-types.png +0 -0
  37. package/binding.gyp +0 -87
  38. package/build.gradle +0 -204
  39. package/build.rs +0 -18
  40. package/c/CMakeLists.txt +0 -25
  41. package/c/README.md +0 -34
  42. package/c/lib.cpp +0 -358
  43. package/c/test.c +0 -374
  44. package/c/usearch.h +0 -311
  45. package/cmake/clipp.cmake +0 -7
  46. package/cmake/config.cmake.in +0 -15
  47. package/cmake/emscripten.cmake +0 -8
  48. package/cmake/jemalloc.cmake +0 -62
  49. package/cmake/pkg-config.pc.in +0 -4
  50. package/cmake/usearchConfigVersion.cmake.in +0 -20
  51. package/conanfile.py +0 -26
  52. package/cpp/CMakeLists.txt +0 -14
  53. package/cpp/README.md +0 -161
  54. package/cpp/bench.cpp +0 -618
  55. package/cpp/test.cpp +0 -323
  56. package/fp16/CMakeLists.txt +0 -176
  57. package/fp16/LICENSE +0 -11
  58. package/fp16/README.md +0 -20
  59. package/fp16/bench/alt-element.cc +0 -89
  60. package/fp16/bench/from-alt-array.cc +0 -175
  61. package/fp16/bench/from-ieee-array.cc +0 -399
  62. package/fp16/bench/ieee-element.cc +0 -272
  63. package/fp16/bench/to-alt-array.cc +0 -91
  64. package/fp16/bench/to-ieee-array.cc +0 -303
  65. package/fp16/cmake/DownloadGoogleBenchmark.cmake +0 -15
  66. package/fp16/cmake/DownloadGoogleTest.cmake +0 -15
  67. package/fp16/cmake/DownloadPSimd.cmake +0 -15
  68. package/fp16/configure.py +0 -65
  69. package/fp16/confu.yaml +0 -8
  70. package/fp16/include/fp16/__init__.py +0 -0
  71. package/fp16/include/fp16/avx.py +0 -50
  72. package/fp16/include/fp16/avx2.py +0 -53
  73. package/fp16/include/fp16/bitcasts.h +0 -92
  74. package/fp16/include/fp16/fp16.h +0 -451
  75. package/fp16/include/fp16/psimd.h +0 -131
  76. package/fp16/include/fp16.h +0 -11
  77. package/fp16/jni/Android.mk +0 -6
  78. package/fp16/jni/Application.mk +0 -4
  79. package/fp16/test/alt-from-fp32-value.cc +0 -498
  80. package/fp16/test/alt-to-fp32-bits.cc +0 -263
  81. package/fp16/test/alt-to-fp32-psimd.cc +0 -145
  82. package/fp16/test/alt-to-fp32-value.cc +0 -348
  83. package/fp16/test/alt-to-fp32x2-psimd.cc +0 -245
  84. package/fp16/test/bitcasts.cc +0 -56
  85. package/fp16/test/ieee-from-fp32-value.cc +0 -523
  86. package/fp16/test/ieee-to-fp32-bits.cc +0 -333
  87. package/fp16/test/ieee-to-fp32-psimd.cc +0 -312
  88. package/fp16/test/ieee-to-fp32-value.cc +0 -420
  89. package/fp16/test/ieee-to-fp32x2-psimd.cc +0 -541
  90. package/fp16/test/peachpy/alt-xmm-to-fp32-xmm-avx.cc +0 -96
  91. package/fp16/test/peachpy/alt-xmm-to-fp32-ymm-avx2.cc +0 -96
  92. package/fp16/test/peachpy/stubs.py +0 -38
  93. package/fp16/test/tables.cc +0 -530
  94. package/fp16/test/tables.h +0 -13
  95. package/fp16/third-party/THHalf.h +0 -92
  96. package/fp16/third-party/eigen-half.h +0 -170
  97. package/fp16/third-party/float16-compressor.h +0 -80
  98. package/fp16/third-party/half.hpp +0 -2916
  99. package/fp16/third-party/npy-halffloat.h +0 -328
  100. package/include/usearch/index.hpp +0 -3836
  101. package/include/usearch/index_dense.hpp +0 -2004
  102. package/include/usearch/index_plugins.hpp +0 -2203
  103. package/javascript/lib.cpp +0 -341
  104. package/javascript/types/usearch.d.ts.map +0 -1
  105. package/javascript/usearch.test.js +0 -74
  106. package/package-ci.json +0 -10
  107. package/pyproject.toml +0 -51
  108. package/setup.py +0 -201
  109. package/simsimd/.releaserc +0 -86
  110. package/simsimd/Cargo.lock +0 -708
  111. package/simsimd/Cargo.toml +0 -36
  112. package/simsimd/LICENSE +0 -201
  113. package/simsimd/README.md +0 -275
  114. package/simsimd/binding.gyp +0 -36
  115. package/simsimd/build.rs +0 -20
  116. package/simsimd/include/simsimd/binary.h +0 -201
  117. package/simsimd/include/simsimd/probability.h +0 -548
  118. package/simsimd/include/simsimd/simsimd.h +0 -456
  119. package/simsimd/include/simsimd/spatial.h +0 -1175
  120. package/simsimd/include/simsimd/types.h +0 -207
  121. package/simsimd/javascript/bench.js +0 -127
  122. package/simsimd/javascript/fallback.ts +0 -193
  123. package/simsimd/javascript/lib.c +0 -102
  124. package/simsimd/javascript/node-gyp-build.d.ts +0 -1
  125. package/simsimd/javascript/simsimd.ts +0 -124
  126. package/simsimd/javascript/test.mjs +0 -153
  127. package/simsimd/javascript/tsconfig-base.json +0 -25
  128. package/simsimd/javascript/tsconfig-cjs.json +0 -8
  129. package/simsimd/javascript/tsconfig-esm.json +0 -8
  130. package/simsimd/package-lock.json +0 -1688
  131. package/simsimd/package.json +0 -61
  132. package/simsimd/rust/benches/cosine.rs +0 -27
  133. package/simsimd/rust/benches/native.rs +0 -27
  134. package/simsimd/rust/benches/sqeuclidean.rs +0 -27
  135. package/simsimd/rust/lib.c +0 -68
  136. package/simsimd/rust/lib.rs +0 -232
  137. package/sqlite/README.md +0 -178
  138. package/sqlite/lib.cpp +0 -325
  139. package/stringzilla/CONTRIBUTING.md +0 -429
  140. package/stringzilla/Cargo.lock +0 -25
  141. package/stringzilla/Cargo.toml +0 -26
  142. package/stringzilla/LICENSE +0 -201
  143. package/stringzilla/README.md +0 -1281
  144. package/stringzilla/VERSION +0 -1
  145. package/stringzilla/assets/cover-strinzilla.jpeg +0 -0
  146. package/stringzilla/assets/meme-stringzilla-v2.jpeg +0 -0
  147. package/stringzilla/assets/meme-stringzilla-v3.jpeg +0 -0
  148. package/stringzilla/binding.gyp +0 -16
  149. package/stringzilla/build.rs +0 -14
  150. package/stringzilla/c/lib.c +0 -304
  151. package/stringzilla/cli/README.md +0 -48
  152. package/stringzilla/cli/split.py +0 -72
  153. package/stringzilla/cli/wc.py +0 -37
  154. package/stringzilla/include/stringzilla/experimental.h +0 -724
  155. package/stringzilla/include/stringzilla/module.modulemap +0 -9
  156. package/stringzilla/include/stringzilla/stringzilla.h +0 -5240
  157. package/stringzilla/include/stringzilla/stringzilla.hpp +0 -3830
  158. package/stringzilla/javascript/lib.c +0 -125
  159. package/stringzilla/javascript/stringzilla.js +0 -22
  160. package/stringzilla/package-ci.json +0 -10
  161. package/stringzilla/package.json +0 -32
  162. package/stringzilla/rust/lib.rs +0 -362
  163. package/stringzilla/swift/StringProtocol+StringZilla.swift +0 -280
  164. package/stringzilla/swift/Test.swift +0 -60
  165. package/tsconfig.json +0 -21
  166. package/wasmer.toml +0 -12
  167. package/winlibinstaller.bat +0 -42
  168. /package/{simsimd/javascript/dist-package-cjs.json → javascript/dist/cjs/package.json} +0 -0
  169. /package/{simsimd/javascript/dist-package-esm.json → javascript/dist/esm/package.json} +0 -0
@@ -1,124 +0,0 @@
1
- import build from "node-gyp-build";
2
- import * as path from "node:path";
3
- import { existsSync } from "node:fs";
4
- import { getFileName, getRoot } from "bindings";
5
- import * as fallback from "./fallback.js";
6
-
7
- let compiled: any;
8
-
9
- try {
10
- let builddir = getBuildDir(getDirName());
11
- compiled = build(builddir);
12
- } catch (e) {
13
- compiled = fallback;
14
- console.warn(
15
- "It seems like your environment does't support the native simsimd module, so we are providing a JS fallback."
16
- );
17
- }
18
-
19
- /**
20
- * @brief Computes the squared Euclidean distance between two vectors.
21
- * @param {Float32Array|Int8Array} a - The first vector.
22
- * @param {Float32Array|Int8Array} b - The second vector.
23
- * @returns {number} The squared Euclidean distance between vectors a and b.
24
- */
25
- export const sqeuclidean = (
26
- a: Float32Array | Int8Array,
27
- b: Float32Array | Int8Array
28
- ): number => {
29
- return compiled.sqeuclidean(a, b);
30
- };
31
-
32
- /**
33
- * @brief Computes the cosine distance between two vectors.
34
- * @param {Float32Array|Int8Array} a - The first vector.
35
- * @param {Float32Array|Int8Array} b - The second vector.
36
- * @returns {number} The cosine distance between vectors a and b.
37
- */
38
- export const cosine = (
39
- a: Float32Array | Int8Array,
40
- b: Float32Array | Int8Array
41
- ): number => {
42
- return compiled.cosine(a, b);
43
- };
44
-
45
- /**
46
- * @brief Computes the inner distance of two vectors.
47
- * @param {Float32Array} a - The first vector.
48
- * @param {Float32Array} b - The second vector.
49
- * @returns {number} The inner distance of vectors a and b.
50
- */
51
- export const inner = (a: Float32Array, b: Float32Array): number => {
52
- return compiled.inner(a, b);
53
- };
54
-
55
- /**
56
- * @brief Computes the bitwise Hamming distance between two vectors.
57
- * @param {Uint8Array} a - The first vector.
58
- * @param {Uint8Array} b - The second vector.
59
- * @returns {number} The Hamming distance between vectors a and b.
60
- */
61
- export const hamming = (a: Uint8Array, b: Uint8Array): number => {
62
- return compiled.hamming(a, b);
63
- };
64
-
65
- /**
66
- * @brief Computes the bitwise Jaccard similarity coefficient between two vectors.
67
- * @param {Uint8Array} a - The first vector.
68
- * @param {Uint8Array} b - The second vector.
69
- * @returns {number} The Jaccard similarity coefficient between vectors a and b.
70
- */
71
- export const jaccard = (a: Uint8Array, b: Uint8Array): number => {
72
- return compiled.jaccard(a, b);
73
- };
74
-
75
- /**
76
- * @brief Computes the kullbackleibler similarity coefficient between two vectors.
77
- * @param {Float32Array} a - The first vector.
78
- * @param {Float32Array} b - The second vector.
79
- * @returns {number} The Jaccard similarity coefficient between vectors a and b.
80
- */
81
- export const kullbackleibler = (a: Float32Array, b: Float32Array): number => {
82
- return compiled.kullbackleibler(a, b);
83
- };
84
-
85
- /**
86
- * @brief Computes the jensenshannon similarity coefficient between two vectors.
87
- * @param {Float32Array} a - The first vector.
88
- * @param {Float32Array} b - The second vector.
89
- * @returns {number} The Jaccard similarity coefficient between vectors a and b.
90
- */
91
- export const jensenshannon = (a: Float32Array, b: Float32Array): number => {
92
- return compiled.jensenshannon(a, b);
93
- };
94
-
95
- export default {
96
- sqeuclidean,
97
- cosine,
98
- inner,
99
- hamming,
100
- jaccard,
101
- kullbackleibler,
102
- jensenshannon,
103
- };
104
-
105
- // utility functions to help find native builds
106
-
107
- function getBuildDir(dir: string) {
108
- if (existsSync(path.join(dir, "build"))) return dir;
109
- if (existsSync(path.join(dir, "prebuilds"))) return dir;
110
- if (path.basename(dir) === ".next") {
111
- // special case for next.js on custom node (not vercel)
112
- const sideways = path.join(dir, "..", "node_modules", "simsimd");
113
- if (existsSync(sideways)) return getBuildDir(sideways);
114
- }
115
- if (dir === "/") throw new Error("Could not find native build for simsimd");
116
- return getBuildDir(path.join(dir, ".."));
117
- }
118
-
119
- function getDirName() {
120
- try {
121
- if (__dirname) return __dirname;
122
- } catch (e) {}
123
- return getRoot(getFileName());
124
- }
@@ -1,153 +0,0 @@
1
- import test from "node:test";
2
- import assert from "node:assert";
3
-
4
- import * as simsimd from "./dist/esm/simsimd.js";
5
-
6
- import * as fallback from "./dist/esm/fallback.js";
7
-
8
- function assertAlmostEqual(actual, expected, tolerance = 1e-6) {
9
- const lowerBound = expected - tolerance;
10
- const upperBound = expected + tolerance;
11
- assert(
12
- actual >= lowerBound && actual <= upperBound,
13
- `Expected ${actual} to be almost equal to ${expected}`
14
- );
15
- }
16
-
17
- test("Distance from itself", () => {
18
- const f32s = new Float32Array([1.0, 2.0, 3.0]);
19
- assertAlmostEqual(simsimd.sqeuclidean(f32s, f32s), 0.0, 0.01);
20
- assertAlmostEqual(simsimd.cosine(f32s, f32s), 0.0, 0.01);
21
-
22
- const f32sNormalized = new Float32Array([
23
- 1.0 / Math.sqrt(14),
24
- 2.0 / Math.sqrt(14),
25
- 3.0 / Math.sqrt(14),
26
- ]);
27
- assertAlmostEqual(simsimd.inner(f32sNormalized, f32sNormalized), 0.0, 0.01);
28
-
29
- const f32sDistribution = new Float32Array([1.0 / 6, 2.0 / 6, 3.0 / 6]);
30
- assertAlmostEqual(
31
- simsimd.kullbackleibler(f32sDistribution, f32sDistribution),
32
- 0.0,
33
- 0.01
34
- );
35
- assertAlmostEqual(
36
- simsimd.jensenshannon(f32sDistribution, f32sDistribution),
37
- 0.0,
38
- 0.01
39
- );
40
-
41
- const u8s = new Uint8Array([1, 2, 3]);
42
- assertAlmostEqual(simsimd.hamming(u8s, u8s), 0.0, 0.01);
43
- assertAlmostEqual(simsimd.jaccard(u8s, u8s), 0.0, 0.01);
44
- });
45
-
46
- test("Distance from itself JS fallback", () => {
47
- const f32s = new Float32Array([1.0, 2.0, 3.0]);
48
-
49
- assertAlmostEqual(fallback.sqeuclidean(f32s, f32s), 0.0, 0.01);
50
- assertAlmostEqual(fallback.cosine(f32s, f32s), 0.0, 0.01);
51
-
52
- const arrNormalized = new Float32Array([
53
- 1.0 / Math.sqrt(14),
54
- 2.0 / Math.sqrt(14),
55
- 3.0 / Math.sqrt(14),
56
- ]);
57
- assertAlmostEqual(fallback.inner(arrNormalized, arrNormalized), 0.0, 0.01);
58
-
59
- const f32sDistribution = new Float32Array([1.0 / 6, 2.0 / 6, 3.0 / 6]);
60
- assertAlmostEqual(
61
- fallback.kullbackleibler(f32sDistribution, f32sDistribution),
62
- 0.0,
63
- 0.01
64
- );
65
- assertAlmostEqual(
66
- fallback.jensenshannon(f32sDistribution, f32sDistribution),
67
- 0.0,
68
- 0.01
69
- );
70
-
71
- const u8s = new Uint8Array([1, 2, 3]);
72
- assertAlmostEqual(fallback.hamming(u8s, u8s), 0.0, 0.01);
73
- assertAlmostEqual(fallback.jaccard(u8s, u8s), 0.0, 0.01);
74
- });
75
-
76
- const f32Array1 = new Float32Array([1.0, 2.0, 3.0]);
77
- const f32Array2 = new Float32Array([4.0, 5.0, 6.0]);
78
-
79
- test("Squared Euclidean Distance", () => {
80
- const result = simsimd.sqeuclidean(f32Array1, f32Array2);
81
- assertAlmostEqual(result, 27.0, 0.01);
82
- });
83
-
84
- test("Inner Distance", () => {
85
- const result = simsimd.inner(f32Array1, f32Array2);
86
- assertAlmostEqual(result, -31.0, 0.01);
87
- });
88
-
89
- test("Cosine Similarity", () => {
90
- const result = simsimd.cosine(f32Array1, f32Array2);
91
- assertAlmostEqual(result, 0.029, 0.01);
92
- });
93
-
94
- test("Squared Euclidean Distance JS", () => {
95
- const result = fallback.sqeuclidean(f32Array1, f32Array2);
96
- assertAlmostEqual(result, 27.0, 0.01);
97
- });
98
-
99
- test("Inner Distance JS", () => {
100
- const result = fallback.inner(f32Array1, f32Array2);
101
- assertAlmostEqual(result, -31.0, 0.01);
102
- });
103
-
104
- test("Cosine Similarity JS", () => {
105
- const result = fallback.cosine(f32Array1, f32Array2);
106
- assertAlmostEqual(result, 0.029, 0.01);
107
- });
108
-
109
- test("Squared Euclidean Distance C vs JS", () => {
110
- const result = simsimd.sqeuclidean(f32Array1, f32Array2);
111
- const resultjs = fallback.sqeuclidean(f32Array1, f32Array2);
112
- assertAlmostEqual(resultjs, result, 0.01);
113
- });
114
-
115
- test("Inner Distance C vs JS", () => {
116
- const result = simsimd.inner(f32Array1, f32Array2);
117
- const resultjs = fallback.inner(f32Array1, f32Array2);
118
- assertAlmostEqual(resultjs, result, 0.01);
119
- });
120
-
121
- test("Cosine Similarity C vs JS", () => {
122
- const result = simsimd.cosine(f32Array1, f32Array2);
123
- const resultjs = fallback.cosine(f32Array1, f32Array2);
124
- assertAlmostEqual(resultjs, result, 0.01);
125
- });
126
-
127
- test("Hamming C vs JS", () => {
128
- const u8s = new Uint8Array([1, 2, 3]);
129
- const result = simsimd.hamming(u8s, u8s);
130
- const resultjs = fallback.cosine(u8s, u8s);
131
- assertAlmostEqual(resultjs, result, 0.01);
132
- });
133
-
134
- test("Jaccard C vs JS", () => {
135
- const u8s = new Uint8Array([1, 2, 3]);
136
- const result = simsimd.jaccard(u8s, u8s);
137
- const resultjs = fallback.jaccard(u8s, u8s);
138
- assertAlmostEqual(resultjs, result, 0.01);
139
- });
140
-
141
- test("Kullback-Leibler C vs JS", () => {
142
- const f32sDistribution = new Float32Array([1.0 / 6, 2.0 / 6, 3.0 / 6]);
143
- const result = simsimd.kullbackleibler(f32sDistribution, f32sDistribution);
144
- const resultjs = fallback.kullbackleibler(f32sDistribution, f32sDistribution);
145
- assertAlmostEqual(resultjs, result, 0.01);
146
- });
147
-
148
- test("Jensen-Shannon C vs JS", () => {
149
- const f32sDistribution = new Float32Array([1.0 / 6, 2.0 / 6, 3.0 / 6]);
150
- const result = simsimd.jensenshannon(f32sDistribution, f32sDistribution);
151
- const resultjs = fallback.jensenshannon(f32sDistribution, f32sDistribution);
152
- assertAlmostEqual(resultjs, result, 0.01);
153
- });
@@ -1,25 +0,0 @@
1
- {
2
- "compileOnSave": false,
3
- "exclude": ["node_modules", "dist"],
4
- "include": ["node-gyp-build.d.ts", "simsimd.ts", "fallback.ts"],
5
- "compilerOptions": {
6
- "allowJs": true,
7
- "allowSyntheticDefaultImports": true,
8
- "baseUrl": ".",
9
- "declaration": true,
10
- "esModuleInterop": true,
11
- "inlineSourceMap": false,
12
- "lib": ["esnext"],
13
- "listEmittedFiles": false,
14
- "listFiles": false,
15
- "moduleResolution": "node",
16
- "noFallthroughCasesInSwitch": true,
17
- "pretty": true,
18
- "resolveJsonModule": true,
19
- "rootDir": ".",
20
- "skipLibCheck": true,
21
- "strict": true,
22
- "traceResolution": false,
23
- "types": ["node","./node-gyp-build.d.ts"]
24
- }
25
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "./tsconfig-base.json",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "outDir": "dist/cjs",
6
- "target": "es2015"
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "./tsconfig-base.json",
3
- "compilerOptions": {
4
- "module": "esnext",
5
- "outDir": "dist/esm",
6
- "target": "esnext"
7
- }
8
- }