Share via


Tensor.CosineSimilarity Method

Definition

Overloads

CosineSimilarity<T>(ReadOnlyTensorSpan<T>, ReadOnlyTensorSpan<T>)

Source:
TensorExtensions.cs
Source:
TensorExtensions.cs

Compute cosine similarity between x and y.

C#
public static System.Numerics.Tensors.Tensor<T> CosineSimilarity<T>(in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, in System.Numerics.Tensors.ReadOnlyTensorSpan<T> y) where T : System.Numerics.IRootFunctions<T>;

Type Parameters

T

Parameters

Returns

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)

CosineSimilarity<T>(ReadOnlyTensorSpan<T>, ReadOnlyTensorSpan<T>, TensorSpan<T>)

Source:
TensorExtensions.cs
Source:
TensorExtensions.cs

Compute cosine similarity between x and y.

C#
public static ref readonly System.Numerics.Tensors.TensorSpan<T> CosineSimilarity<T>(scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> x, scoped in System.Numerics.Tensors.ReadOnlyTensorSpan<T> y, in System.Numerics.Tensors.TensorSpan<T> destination) where T : System.Numerics.IRootFunctions<T>;

Type Parameters

T

Parameters

destination
TensorSpan<T>

Returns

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)