Cosine distance

The Cosine distance is a measure of distance between two non-zero vectors of an inner product space.


Computational methods



Mathematical formulation

Refer to Developer Guide: Minkowski distance.

Programming Interface

All types and functions in this section are declared in the oneapi::dal::cosine_distance namespace.


template<typename Float = float, typename Method = method::by_default, typename Task = task::by_default>
class descriptor
Template Parameters
  • Float – The floating-point type that the algorithm uses for intermediate computations. Can be float or double.

  • Method – Tag-type that specifies the implementation of the algorithm. Can be method::dense.

  • Task – Tag-type that specifies the type of the problem to solve. Can be task::compute.


descriptor() = default

Creates a new instance of the class with the default property values.

Method tags

struct dense
using by_default = dense

Alias tag-type for the dense method.

Task tags

struct compute

Tag-type that parameterizes entities that are used to compute distances.

using by_default = compute

Alias tag-type for the compute task.