Generated by DocFX

Struct Minkowski

The Minkowski distance is a metric in a normed vector space which can be considered as a generalization of both the Euclidean distance and the Manhattan distance.

Implements
IMetric<System.Double[]>
IDistance<System.Double[]>
IDistance<System.Double[], System.Double[]>
IMetric<System.Int32[]>
IDistance<System.Int32[]>
IDistance<System.Int32[], System.Int32[]>
ICloneable
Namespace: ISynergy.Framework.Mathematics.Distances
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public struct Minkowski : IMetric<double[]>, IDistance<double[]>, IDistance<double[], double[]>, IMetric<int[]>, IDistance<int[]>, IDistance<int[], int[]>
Remarks

The framework distinguishes between metrics and distances by using different types for them. This makes it possible to let the compiler figure out logic problems such as the specification of a non-metric for a method that requires a proper metric (i.e. that respects the triangle inequality).

The objective of this technique is to make it harder to make some mistakes. However, it is possible to bypass this mechanism by using the named constructors such as Nonmetric(Double) to create distances implementing the IMetric<T> interface that are not really metrics. Use at your own risk.

Constructors

View Source

Minkowski(Double)

Initializes a new instance of the Minkowski class.

Declaration
public Minkowski(double p)
Parameters
Type Name Description
System.Double p

The Minkowski order p.

Fields

View Source

Euclidean

Gets the Euclidean distance as a special case of the Minkowski distance.

Declaration
public static readonly Minkowski Euclidean
Field Value
Type Description
Minkowski
View Source

Manhattan

Gets the Manhattan distance as a special case of the Minkowski distance.

Declaration
public static readonly Minkowski Manhattan
Field Value
Type Description
Minkowski

Properties

View Source

Order

Gets the order p of this Minkowski distance.

Declaration
public readonly double Order { get; }
Property Value
Type Description
System.Double

Methods

View Source

Clone()

Creates a new object that is a copy of the current instance.

Declaration
public object Clone()
Returns
Type Description
System.Object

A new object that is a copy of this instance.

View Source

Distance(Double[], Double[])

Computes the distance d(x,y) between points x and y.

Declaration
public double Distance(double[] x, double[] y)
Parameters
Type Name Description
System.Double[] x

The first point x.

System.Double[] y

The second point y.

Returns
Type Description
System.Double

A double-precision value representing the distance d(x,y) between x and y according to the distance function implemented by this class.

View Source

Distance(Int32[], Int32[])

Computes the distance d(x,y) between points x and y.

Declaration
public double Distance(int[] x, int[] y)
Parameters
Type Name Description
System.Int32[] x

The first point x.

System.Int32[] y

The second point y.

Returns
Type Description
System.Double

A double-precision value representing the distance d(x,y) between x and y according to the distance function implemented by this class.

View Source

Nonmetric(Double)

Creates a non-metric Minkowski distance, bypassing argument checking. Use at your own risk.

Declaration
public static Minkowski Nonmetric(double p)
Parameters
Type Name Description
System.Double p

The Minkowski order p.

Returns
Type Description
Minkowski

A Minkowski object implementing a Minkowski distance that is not necessarily a metric. Use at your own risk.

Implements

IMetric<T>
IDistance<T>
IDistance<T, U>
IMetric<T>
IDistance<T>
IDistance<T, U>
ICloneable

Extension Methods

EnumExtensions.GetSymbol<T>(T)
ArrayExtensions.Concatenate<T>(T, T[])
CollectionExtensions.FromHierarchy<TSource>(TSource, Func<TSource, TSource>, Func<TSource, Boolean>)
ObjectExtensions.Clone<T>(T)
ObjectExtensions.AddressOf<T>(T)
ObjectExtensions.ToByteArray<T>(T)
ReflectionExtensions.GetPropertyInfo<T, TValue>(T, Expression<Func<T, TValue>>)