Click or drag to resize
Accord.NET (logo)

Euclidean Structure

Euclidean distance metric.

Namespace:  Accord.Math.Distances
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public struct Euclidean : IMetric<double>, 
	IDistance<double>, IDistance<double, double>, 
	ISimilarity<double>, ISimilarity<double, double>, 
	IMetric<double[]>, IDistance<double[]>, IDistance<double[], double[]>, 
	ISimilarity<double[]>, ISimilarity<double[], double[]>, 
	IMetric<Tuple<double, double>>, IDistance<Tuple<double, double>>, 
	IDistance<Tuple<double, double>, Tuple<double, double>>, 
	ISimilarity<Tuple<double, double>>, ISimilarity<Tuple<double, double>, Tuple<double, double>>, 
	IDistance<Sparse<double>>, IDistance<Sparse<double>, Sparse<double>>, 
	ISimilarity<Sparse<double>>, ISimilarity<Sparse<double>, Sparse<double>>
Request Example View Source

The Euclidean type exposes the following members.

Methods
  NameDescription
Public methodDistance(Double, Double)
Computes the distance d(x,y) between points x and y.
Public methodCode exampleDistance(Double, Double)
Computes the distance d(x,y) between points x and y.
Public methodDistance(TupleDouble, Double, TupleDouble, Double)
Gets the Euclidean distance between two points.
Public methodDistance(SparseDouble, SparseDouble)
Computes the distance d(x,y) between points x and y.
Public methodCode exampleDistance(Double, Double, Double, Double)
Gets the Euclidean distance between two points. Note: this function is dangerous as it is too easy to invert its arguments by mistake. Please consider using the Tuple<double, double> overload instead.
Public methodEquals
Indicates whether this instance and a specified object are equal.
(Inherited from ValueType.)
Public methodGetHashCode
Returns the hash code for this instance.
(Inherited from ValueType.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodSimilarity(Double, Double)
Gets a similarity measure between two points.
Public methodSimilarity(Double, Double)
Gets a similarity measure between two points.
Public methodSimilarity(TupleDouble, Double, TupleDouble, Double)
Gets a similarity measure between two points.
Public methodSimilarity(SparseDouble, SparseDouble)
Gets a similarity measure between two points.
Public methodToString
Returns the fully qualified type name of this instance.
(Inherited from ValueType.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(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.)
Public Extension MethodToTOverloaded.
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
// Let's say the coordinates of the first 2D vector are
double x1 = 1.5;
double y1 = -2.1;

// And then the coordinates of the second 2D vector are:
double x2 = 4;
double y2 = 1;

// The euclidean distance between (x1, y1) and (x2, y2) are:
double a = Distance.Euclidean(x1, y1, x2, y2); // should be ~3.9824615503479754

// This is equivalent to 
double b = Distance.Euclidean(new[] { x1, y1 }, new[] { x2, y2 });
See Also