Cloud.Unum.USearch
2.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Cloud.Unum.USearch --version 2.0.3
NuGet\Install-Package Cloud.Unum.USearch -Version 2.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cloud.Unum.USearch" Version="2.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cloud.Unum.USearch --version 2.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Cloud.Unum.USearch, 2.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Cloud.Unum.USearch as a Cake Addin
#addin nuget:?package=Cloud.Unum.USearch&version=2.0.3
// Install Cloud.Unum.USearch as a Cake Tool
#tool nuget:?package=Cloud.Unum.USearch&version=2.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
USearch for C#
Installation
dotnet add package Cloud.Unum.USearch
Quickstart
using System.Diagnostics;
using Cloud.Unum.USearch;
using var index = new USearchIndex(
metricKind: MetricKind.Cos, // Choose cosine metric
quantization: ScalarKind.Float32, // Only quantization to Float32, Float64 is currently supported
dimensions: 3, // Define the number of dimensions in input vectors
connectivity: 16, // How frequent should the connections in the graph be, optional
expansionAdd: 128, // Control the recall of indexing, optional
expansionSearch: 64 // Control the quality of search, optional
);
var vector = new float[] { 0.2f, 0.6f, 0.4f };
index.Add(42, vector);
int matches = index.Search(vector, 10, out ulong[] keys, out float[] distances);
Trace.Assert(index.Size() == 1);
Trace.Assert(matches == 1);
Trace.Assert(keys[0] == 42);
Trace.Assert(distances[0] <= 0.001f);
Serialization
index.Save("index.usearch")
// Copy the whole index into memory
using var indexLoaded = new USearchIndex("index.usearch");
// Or view from disk without loading in memory
// using var indexLoaded = new USearchIndex("index.usearch", view: true);
Trace.Assert(indexLoaded.Size() == 1);
Trace.Assert(indexLoaded.Dimensions() == 3);
Trace.Assert(indexLoaded.Connectivity() == 16);
Trace.Assert(indexLoaded.Contains(42));
Batch Operations
Adding a batch of entries is identical to adding a single vector.
using var index = new USearchIndex(MetricKind.Cos, ScalarKind.Float32, dimensions: 3);
// Generate keys and random vectors
int n = 100;
ulong[] keys = Enumerable.Range(0, n).Select(i => (ulong)i).ToArray();
int dims = checked((int)index.Dimensions());
float[][] vectors = Enumerable.Range(0, n)
.Select(_ => Enumerable.Range(0, dims)
.Select(__ => (float)new Random().NextDouble() * 0.3f)
.ToArray())
.ToArray();
index.Add(keys, vectors);
int matches = index.Search(vectors[0], 10, out ulong[] foundKeys, out float[] foundDistances);
Trace.Assert(matches <= 10);
Trace.Assert(foundKeys[0] == 0);
Trace.Assert(foundDistances[0] <= 0.001f);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
GitHub repositories
This package is not used by any popular GitHub repositories.