﻿ Cosine Structure   # Cosine Structure

Cosine distance. For a proper distance metric, see Angular.

Namespace:  Accord.Math.Distances
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0 Syntax
```[SerializableAttribute]
public struct Cosine : IDistance<double[]>,
IDistance<double[], double[]>, ISimilarity<double[]>,
ISimilarity<double[], double[]>```

The Cosine type exposes the following members. Methods
NameDescription  Distance
Computes the distance d(x,y) between points x and y. Equals
Indicates whether this instance and a specified object are equal.
(Inherited from ValueType.) GetHashCode
Returns the hash code for this instance.
(Inherited from ValueType.) GetType
Gets the Type of the current instance.
(Inherited from Object.) Similarity
Gets a similarity measure between two points. ToString
Returns the fully qualified type name of this instance.
(Inherited from ValueType.)
Top Extension Methods
NameDescription HasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) IsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.) To(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) ToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top Examples
```// The Cosine distance between (0, 2, 4) and (2, 5, 1) can be directly computed as:
double a = Distance.Cosine(new[] { 0.0, 2.0, 4.0 }, new[] { 2.0, 5.0, 1.0 }); // ~0.42845239335059182d

// Or could also be computed by instantiating the Cosine class beforehand as:
Cosine cos = new Cosine();
double b = cos.Distance(new[] { 0.0, 2.0, 4.0 }, new[] { 2.0, 5.0, 1.0 }); // ~0.42845239335059182d``` See Also