usearch 2.8.7 → 2.8.9

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 (113) hide show
  1. package/CITATION.cff +1 -1
  2. package/CMakeLists.txt +3 -3
  3. package/CONTRIBUTING.md +26 -3
  4. package/Cargo.toml +1 -1
  5. package/Dockerfile +16 -0
  6. package/README.md +41 -38
  7. package/VERSION +1 -0
  8. package/binding.gyp +57 -8
  9. package/conanfile.py +1 -1
  10. package/include/usearch/index.hpp +1 -1
  11. package/include/usearch/index_plugins.hpp +28 -24
  12. package/javascript/README.md +64 -12
  13. package/javascript/lib.cpp +11 -3
  14. package/javascript/usearch.js +4 -2
  15. package/javascript/usearch.test.js +15 -0
  16. package/package.json +1 -2
  17. package/setup.py +76 -15
  18. package/simsimd/README.md +14 -13
  19. package/simsimd/include/simsimd/probability.h +2 -2
  20. package/simsimd/package.json +1 -1
  21. package/wasmer.toml +1 -1
  22. package/. npmignore +0 -14
  23. package/.gitignore +0 -95
  24. package/.vscode/launch.json +0 -181
  25. package/.vscode/settings.json +0 -180
  26. package/.vscode/tasks.json +0 -71
  27. package/Package.swift +0 -41
  28. package/csharp/.editorconfig +0 -361
  29. package/csharp/Cloud.Unum.USearch.sln +0 -34
  30. package/csharp/DEV_SETUP.md +0 -51
  31. package/csharp/Directory.Build.props +0 -29
  32. package/csharp/README.md +0 -74
  33. package/csharp/build_and_test.cmd +0 -31
  34. package/csharp/build_and_test.sh +0 -30
  35. package/csharp/nuget/nuget-package.props +0 -33
  36. package/csharp/pack.sh +0 -56
  37. package/csharp/src/Cloud.Unum.USearch.Tests/Cloud.Unum.USearch.Tests.csproj +0 -39
  38. package/csharp/src/Cloud.Unum.USearch.Tests/USearchIndexTests.cs +0 -1013
  39. package/csharp/src/Cloud.Unum.USearch.Tests/Usings.cs +0 -1
  40. package/docs/_static/custom.css +0 -26
  41. package/docs/_static/custom.js +0 -7
  42. package/docs/benchmarks.md +0 -245
  43. package/docs/benchmarks.rst +0 -5
  44. package/docs/c/index.rst +0 -11
  45. package/docs/c/reference.rst +0 -7
  46. package/docs/conf.dox +0 -2668
  47. package/docs/conf.py +0 -53
  48. package/docs/contributing.rst +0 -5
  49. package/docs/cpp/index.rst +0 -11
  50. package/docs/cpp/reference.rst +0 -17
  51. package/docs/csharp/index.rst +0 -6
  52. package/docs/format.md +0 -86
  53. package/docs/format.rst +0 -5
  54. package/docs/golang/index.rst +0 -6
  55. package/docs/index.rst +0 -33
  56. package/docs/java/index.rst +0 -11
  57. package/docs/java/reference.rst +0 -7
  58. package/docs/javascript/index.rst +0 -11
  59. package/docs/javascript/reference.rst +0 -12
  60. package/docs/python/index.rst +0 -11
  61. package/docs/python/reference.rst +0 -42
  62. package/docs/rust/index.rst +0 -6
  63. package/docs/swift/index.rst +0 -6
  64. package/docs/wolfram/index.rst +0 -6
  65. package/golang/README.md +0 -95
  66. package/golang/go.mod +0 -3
  67. package/golang/lib.go +0 -379
  68. package/golang/lib_test.go +0 -108
  69. package/java/README.md +0 -22
  70. package/java/cloud/unum/usearch/Index.java +0 -337
  71. package/java/cloud/unum/usearch/cloud_unum_usearch_Index.cpp +0 -197
  72. package/java/cloud/unum/usearch/cloud_unum_usearch_Index.h +0 -125
  73. package/java/test/IndexTest.java +0 -30
  74. package/objc/USearchObjective.mm +0 -299
  75. package/objc/include/USearchObjective.h +0 -154
  76. package/python/README.md +0 -292
  77. package/python/lib.cpp +0 -1216
  78. package/python/scripts/bench.ipynb +0 -193
  79. package/python/scripts/bench.py +0 -137
  80. package/python/scripts/bench_exact.py +0 -44
  81. package/python/scripts/cluster.ipynb +0 -160
  82. package/python/scripts/index_faiss.py +0 -100
  83. package/python/scripts/join.py +0 -155
  84. package/python/scripts/test_index.py +0 -247
  85. package/python/scripts/test_jit.py +0 -231
  86. package/python/scripts/test_sparse.py +0 -32
  87. package/python/scripts/test_tooling.py +0 -133
  88. package/python/usearch/__init__.py +0 -0
  89. package/python/usearch/client.py +0 -124
  90. package/python/usearch/eval.py +0 -470
  91. package/python/usearch/index.py +0 -1401
  92. package/python/usearch/io.py +0 -113
  93. package/python/usearch/numba.py +0 -121
  94. package/python/usearch/server.py +0 -137
  95. package/rust/README.md +0 -66
  96. package/rust/lib.cpp +0 -136
  97. package/rust/lib.hpp +0 -69
  98. package/rust/lib.rs +0 -610
  99. package/simsimd/CMakeLists.txt +0 -67
  100. package/simsimd/cpp/bench.cxx +0 -206
  101. package/simsimd/package-ci.json +0 -10
  102. package/simsimd/setup.py +0 -86
  103. package/swift/Index+Sugar.swift +0 -153
  104. package/swift/README.md +0 -48
  105. package/swift/Test.swift +0 -37
  106. package/swift/USearch.swift +0 -8
  107. package/wasm/CMakeLists.txt +0 -7
  108. package/wasm/README.md +0 -13
  109. package/wasm/lib.cpp +0 -5
  110. package/wolfram/CMakeLists.txt +0 -18
  111. package/wolfram/README.md +0 -13
  112. package/wolfram/lib.cpp +0 -160
  113. package/wolfram/test.wls +0 -27
@@ -1,299 +0,0 @@
1
- #import "USearchObjective.h"
2
-
3
- #pragma clang diagnostic push
4
- #pragma clang diagnostic ignored "-Wdocumentation"
5
- #import <usearch/index_dense.hpp>
6
- #pragma clang diagnostic pop
7
-
8
- using namespace unum::usearch;
9
- using namespace unum;
10
-
11
- using distance_t = distance_punned_t;
12
- using add_result_t = typename index_dense_t::add_result_t;
13
- using labeling_result_t = typename index_dense_t::labeling_result_t;
14
- using search_result_t = typename index_dense_t::search_result_t;
15
- using shared_index_dense_t = std::shared_ptr<index_dense_t>;
16
-
17
- static_assert(std::is_same<USearchKey, index_dense_t::vector_key_t>::value, "Type mismatch between Objective-C and C++");
18
-
19
- metric_kind_t to_native_metric(USearchMetric m) {
20
- switch (m) {
21
- case USearchMetricIP:
22
- return metric_kind_t::ip_k;
23
-
24
- case USearchMetricCos:
25
- return metric_kind_t::cos_k;
26
-
27
- case USearchMetricL2sq:
28
- return metric_kind_t::l2sq_k;
29
-
30
- case USearchMetricHamming:
31
- return metric_kind_t::hamming_k;
32
-
33
- case USearchMetricHaversine:
34
- return metric_kind_t::haversine_k;
35
-
36
- case USearchMetricDivergence:
37
- return metric_kind_t::divergence_k;
38
-
39
- case USearchMetricJaccard:
40
- return metric_kind_t::jaccard_k;
41
-
42
- case USearchMetricPearson:
43
- return metric_kind_t::pearson_k;
44
-
45
- case USearchMetricSorensen:
46
- return metric_kind_t::sorensen_k;
47
-
48
- case USearchMetricTanimoto:
49
- return metric_kind_t::tanimoto_k;
50
-
51
- default:
52
- return metric_kind_t::unknown_k;
53
- }
54
- }
55
-
56
- scalar_kind_t to_native_scalar(USearchScalar m) {
57
- switch (m) {
58
- case USearchScalarI8:
59
- return scalar_kind_t::i8_k;
60
-
61
- case USearchScalarF16:
62
- return scalar_kind_t::f16_k;
63
-
64
- case USearchScalarF32:
65
- return scalar_kind_t::f32_k;
66
-
67
- case USearchScalarF64:
68
- return scalar_kind_t::f64_k;
69
-
70
- default:
71
- return scalar_kind_t::unknown_k;
72
- }
73
- }
74
-
75
- @interface USearchIndex ()
76
-
77
- @property (readonly) shared_index_dense_t native;
78
-
79
- - (instancetype)initWithIndex:(shared_index_dense_t)native;
80
-
81
- @end
82
-
83
- @implementation USearchIndex
84
-
85
- - (instancetype)initWithIndex:(shared_index_dense_t)native {
86
- self = [super init];
87
- _native = native;
88
- return self;
89
- }
90
-
91
- - (Boolean)isEmpty {
92
- return _native->size() != 0;
93
- }
94
-
95
- - (UInt32)dimensions {
96
- return static_cast<UInt32>(_native->dimensions());
97
- }
98
-
99
- - (UInt32)connectivity {
100
- return static_cast<UInt32>(_native->connectivity());
101
- }
102
-
103
- - (UInt32)length {
104
- return static_cast<UInt32>(_native->size());
105
- }
106
-
107
- - (UInt32)capacity {
108
- return static_cast<UInt32>(_native->capacity());
109
- }
110
-
111
- - (UInt32)expansionAdd {
112
- return static_cast<UInt32>(_native->expansion_add());
113
- }
114
-
115
- - (UInt32)expansionSearch {
116
- return static_cast<UInt32>(_native->expansion_search());
117
- }
118
-
119
- + (instancetype)make:(USearchMetric)metricKind dimensions:(UInt32)dimensions connectivity:(UInt32)connectivity quantization:(USearchScalar)quantization {
120
- std::size_t dims = static_cast<std::size_t>(dimensions);
121
-
122
- index_config_t config(static_cast<std::size_t>(connectivity));
123
- metric_punned_t metric(dims, to_native_metric(metricKind), to_native_scalar(quantization));
124
- shared_index_dense_t ptr = std::make_shared<index_dense_t>(index_dense_t::make(metric, config));
125
- return [[USearchIndex alloc] initWithIndex:ptr];
126
- }
127
-
128
- - (void)addSingle:(USearchKey)key
129
- vector:(Float32 const *_Nonnull)vector {
130
- add_result_t result = _native->add(key, vector);
131
-
132
- if (!result) {
133
- @throw [NSException exceptionWithName:@"Can't add to index"
134
- reason:[NSString stringWithUTF8String:result.error.release()]
135
- userInfo:nil];
136
- }
137
- }
138
-
139
- - (UInt32)searchSingle:(Float32 const *_Nonnull)vector
140
- count:(UInt32)wanted
141
- keys:(USearchKey *_Nullable)keys
142
- distances:(Float32 *_Nullable)distances {
143
- search_result_t result = _native->search(vector, static_cast<std::size_t>(wanted));
144
-
145
- if (!result) {
146
- @throw [NSException exceptionWithName:@"Can't find in index"
147
- reason:[NSString stringWithUTF8String:result.error.release()]
148
- userInfo:nil];
149
- }
150
-
151
- std::size_t found = result.dump_to(keys, distances);
152
- return static_cast<UInt32>(found);
153
- }
154
-
155
- - (void)addDouble:(USearchKey)key
156
- vector:(Float64 const *_Nonnull)vector {
157
- add_result_t result = _native->add(key, (f64_t const *)vector);
158
-
159
- if (!result) {
160
- @throw [NSException exceptionWithName:@"Can't add to index"
161
- reason:[NSString stringWithUTF8String:result.error.release()]
162
- userInfo:nil];
163
- }
164
- }
165
-
166
- - (UInt32)searchDouble:(Float64 const *_Nonnull)vector
167
- count:(UInt32)wanted
168
- keys:(USearchKey *_Nullable)keys
169
- distances:(Float32 *_Nullable)distances {
170
- search_result_t result = _native->search((f64_t const *)vector, static_cast<std::size_t>(wanted));
171
-
172
- if (!result) {
173
- @throw [NSException exceptionWithName:@"Can't find in index"
174
- reason:[NSString stringWithUTF8String:result.error.release()]
175
- userInfo:nil];
176
- }
177
-
178
- std::size_t found = result.dump_to(keys, distances);
179
- return static_cast<UInt32>(found);
180
- }
181
-
182
- - (void)addHalf:(USearchKey)key
183
- vector:(void const *_Nonnull)vector {
184
- add_result_t result = _native->add(key, (f16_t const *)vector);
185
-
186
- if (!result) {
187
- @throw [NSException exceptionWithName:@"Can't add to index"
188
- reason:[NSString stringWithUTF8String:result.error.release()]
189
- userInfo:nil];
190
- }
191
- }
192
-
193
- - (UInt32)searchHalf:(void const *_Nonnull)vector
194
- count:(UInt32)wanted
195
- keys:(USearchKey *_Nullable)keys
196
- distances:(Float32 *_Nullable)distances {
197
- search_result_t result = _native->search((f16_t const *)vector, static_cast<std::size_t>(wanted));
198
-
199
- if (!result) {
200
- @throw [NSException exceptionWithName:@"Can't find in index"
201
- reason:[NSString stringWithUTF8String:result.error.release()]
202
- userInfo:nil];
203
- }
204
-
205
- std::size_t found = result.dump_to(keys, distances);
206
- return static_cast<UInt32>(found);
207
- }
208
-
209
- - (void)clear {
210
- _native->clear();
211
- }
212
-
213
- - (void)reserve:(UInt32)count {
214
- _native->reserve(static_cast<std::size_t>(count));
215
- }
216
-
217
- - (Boolean)contains:(USearchKey)key {
218
- return _native->contains(key);
219
- }
220
-
221
- - (UInt32)count:(USearchKey)key {
222
- return _native->count(key);
223
- }
224
-
225
- - (void)remove:(USearchKey)key {
226
- labeling_result_t result = _native->remove(key);
227
-
228
- if (!result) {
229
- @throw [NSException exceptionWithName:@"Can't remove an entry"
230
- reason:[NSString stringWithUTF8String:result.error.release()]
231
- userInfo:nil];
232
- }
233
- }
234
-
235
- - (void)rename:(USearchKey)key to:(USearchKey)to {
236
- labeling_result_t result = _native->rename(key, to);
237
-
238
- if (!result) {
239
- @throw [NSException exceptionWithName:@"Can't rename the entry"
240
- reason:[NSString stringWithUTF8String:result.error.release()]
241
- userInfo:nil];
242
- }
243
- }
244
-
245
- - (void)save:(NSString *)path {
246
- char const *path_c = [path UTF8String];
247
-
248
- if (!path_c) {
249
- @throw [NSException exceptionWithName:@"Can't save to disk"
250
- reason:@"The path must be convertible to UTF8"
251
- userInfo:nil];
252
- }
253
-
254
- serialization_result_t result = _native->save(path_c);
255
-
256
- if (!result) {
257
- @throw [NSException exceptionWithName:@"Can't save to disk"
258
- reason:[NSString stringWithUTF8String:result.error.release()]
259
- userInfo:nil];
260
- }
261
- }
262
-
263
- - (void)load:(NSString *)path {
264
- char const *path_c = [path UTF8String];
265
-
266
- if (!path_c) {
267
- @throw [NSException exceptionWithName:@"Can't load from disk"
268
- reason:@"The path must be convertible to UTF8"
269
- userInfo:nil];
270
- }
271
-
272
- serialization_result_t result = _native->load(path_c);
273
-
274
- if (!result) {
275
- @throw [NSException exceptionWithName:@"Can't load from disk"
276
- reason:[NSString stringWithUTF8String:result.error.release()]
277
- userInfo:nil];
278
- }
279
- }
280
-
281
- - (void)view:(NSString *)path {
282
- char const *path_c = [path UTF8String];
283
-
284
- if (!path_c) {
285
- @throw [NSException exceptionWithName:@"Can't view from disk"
286
- reason:@"The path must be convertible to UTF8"
287
- userInfo:nil];
288
- }
289
-
290
- serialization_result_t result = _native->view(path_c);
291
-
292
- if (!result) {
293
- @throw [NSException exceptionWithName:@"Can't view from disk"
294
- reason:[NSString stringWithUTF8String:result.error.release()]
295
- userInfo:nil];
296
- }
297
- }
298
-
299
- @end
@@ -1,154 +0,0 @@
1
- #pragma once
2
-
3
- #import <Foundation/Foundation.h>
4
-
5
- NS_ASSUME_NONNULL_BEGIN
6
-
7
- typedef NS_ENUM(NSUInteger, USearchScalar) {
8
- USearchScalarF32,
9
- USearchScalarF16,
10
- USearchScalarF64,
11
- USearchScalarI8,
12
- USearchScalarB1
13
- };
14
-
15
- typedef NS_ENUM(NSUInteger, USearchMetric) {
16
- USearchMetricUnknown,
17
- USearchMetricIP,
18
- USearchMetricCos,
19
- USearchMetricL2sq,
20
- USearchMetricPearson,
21
- USearchMetricHaversine,
22
- USearchMetricDivergence,
23
- USearchMetricJaccard,
24
- USearchMetricHamming,
25
- USearchMetricTanimoto,
26
- USearchMetricSorensen
27
- };
28
-
29
- typedef UInt64 USearchKey;
30
-
31
- API_AVAILABLE(ios(13.0), macos(10.15), tvos(13.0), watchos(6.0))
32
- @interface USearchIndex : NSObject
33
-
34
- @property (readonly) UInt32 dimensions;
35
- @property (readonly) UInt32 connectivity;
36
- @property (readonly) UInt32 expansionAdd;
37
- @property (readonly) UInt32 expansionSearch;
38
-
39
- @property (readonly) UInt32 length;
40
- @property (readonly) UInt32 capacity;
41
- @property (readonly) Boolean isEmpty;
42
-
43
- - (instancetype)init NS_UNAVAILABLE;
44
-
45
- /**
46
- * @brief Initializes a new index.
47
- * @param metric The distance function to compare the dis-similarity of vectors.
48
- * @param dimensions The number of dimensions planned for this index.
49
- * @param connectivity Number of connections per node in the proximity graph.
50
- * Higher connectivity improves quantization, increases memory usage, and reduces construction speed.
51
- * @param quantization Quantization of internal vector representations. Lower quantization means higher speed.
52
- */
53
- + (instancetype)make:(USearchMetric)metric dimensions:(UInt32)dimensions connectivity:(UInt32)connectivity quantization:(USearchScalar)quantization NS_SWIFT_NAME(make(metric:dimensions:connectivity:quantization:));
54
-
55
- /**
56
- * @brief Pre-allocates space in the index for the given number of vectors.
57
- */
58
- - (void)reserve:(UInt32)count NS_SWIFT_NAME(reserve(_:));
59
-
60
- /**
61
- * @brief Adds a labeled vector to the index.
62
- * @param vector Single-precision vector.
63
- */
64
- - (void)addSingle:(USearchKey)key
65
- vector:(Float32 const *_Nonnull)vector NS_SWIFT_NAME(addSingle(key:vector:));
66
-
67
- /**
68
- * @brief Approximate nearest neighbors search.
69
- * @param vector Single-precision query vector.
70
- * @param count Upper limit on the number of matches to retrieve.
71
- * @param keys Optional output buffer for keys of approximate neighbors.
72
- * @param distances Optional output buffer for (increasing) distances to approximate neighbors.
73
- * @return Number of matches exported to `keys` and `distances`.
74
- */
75
- - (UInt32)searchSingle:(Float32 const *_Nonnull)vector
76
- count:(UInt32)count
77
- keys:(USearchKey *_Nullable)keys
78
- distances:(Float32 *_Nullable)distances NS_SWIFT_NAME(searchSingle(vector:count:keys:distances:));
79
-
80
- /**
81
- * @brief Adds a labeled vector to the index.
82
- * @param vector Double-precision vector.
83
- */
84
- - (void)addDouble:(USearchKey)key
85
- vector:(Float64 const *_Nonnull)vector NS_SWIFT_NAME(addDouble(key:vector:));
86
-
87
- /**
88
- * @brief Approximate nearest neighbors search.
89
- * @param vector Double-precision query vector.
90
- * @param count Upper limit on the number of matches to retrieve.
91
- * @param keys Optional output buffer for keys of approximate neighbors.
92
- * @param distances Optional output buffer for (increasing) distances to approximate neighbors.
93
- * @return Number of matches exported to `keys` and `distances`.
94
- */
95
- - (UInt32)searchDouble:(Float64 const *_Nonnull)vector
96
- count:(UInt32)count
97
- keys:(USearchKey *_Nullable)keys
98
- distances:(Float32 *_Nullable)distances NS_SWIFT_NAME(searchDouble(vector:count:keys:distances:));
99
-
100
- /**
101
- * @brief Adds a labeled vector to the index.
102
- * @param vector Half-precision vector.
103
- */
104
- - (void)addHalf:(USearchKey)key
105
- vector:(void const *_Nonnull)vector NS_SWIFT_NAME(addHalf(key:vector:));
106
-
107
- /**
108
- * @brief Approximate nearest neighbors search.
109
- * @param vector Half-precision query vector.
110
- * @param count Upper limit on the number of matches to retrieve.
111
- * @param keys Optional output buffer for keys of approximate neighbors.
112
- * @param distances Optional output buffer for (increasing) distances to approximate neighbors.
113
- * @return Number of matches exported to `keys` and `distances`.
114
- */
115
- - (UInt32)searchHalf:(void const *_Nonnull)vector
116
- count:(UInt32)count
117
- keys:(USearchKey *_Nullable)keys
118
- distances:(Float32 *_Nullable)distances NS_SWIFT_NAME(searchHalf(vector:count:keys:distances:));
119
-
120
-
121
- - (Boolean)contains:(USearchKey)key NS_SWIFT_NAME(contains(key:));
122
-
123
- - (UInt32)count:(USearchKey)key NS_SWIFT_NAME(count(key:));
124
-
125
- - (void)remove:(USearchKey)key NS_SWIFT_NAME(remove(key:));
126
-
127
- - (void)rename:(USearchKey)key to:(USearchKey)key NS_SWIFT_NAME(rename(from:to:));
128
-
129
-
130
- /**
131
- * @brief Saves pre-constructed index to disk.
132
- */
133
- - (void)save:(NSString *)path NS_SWIFT_NAME(save(path:));
134
-
135
- /**
136
- * @brief Loads a pre-constructed index from index.
137
- */
138
- - (void)load:(NSString *)path NS_SWIFT_NAME(load(path:));
139
-
140
- /**
141
- * @brief Views a pre-constructed index from disk without loading it into RAM.
142
- * Allows working with larger-than memory indexes and saving scarce
143
- * memory on device in read-only workloads.
144
- */
145
- - (void)view:(NSString *)path NS_SWIFT_NAME(view(path:));
146
-
147
- /**
148
- * @brief Removes all the data from index, while preserving the settings.
149
- */
150
- - (void)clear NS_SWIFT_NAME(clear());
151
-
152
- @end
153
-
154
- NS_ASSUME_NONNULL_END