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
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 SourceMinkowski(Double)
Initializes a new instance of the Minkowski class.
Declaration
public Minkowski(double p)
Parameters
Type | Name | Description |
---|---|---|
System.Double | p | The Minkowski order |
Fields
View SourceEuclidean
Declaration
public static readonly Minkowski Euclidean
Field Value
Type | Description |
---|---|
Minkowski |
Manhattan
Declaration
public static readonly Minkowski Manhattan
Field Value
Type | Description |
---|---|
Minkowski |
Properties
View SourceOrder
Gets the order p
of this Minkowski distance.
Declaration
public readonly double Order { get; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
View SourceClone()
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. |
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 |
System.Double[] | y | The second point |
Returns
Type | Description |
---|---|
System.Double | A double-precision value representing the distance |
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 |
System.Int32[] | y | The second point |
Returns
Type | Description |
---|---|
System.Double | A double-precision value representing the distance |
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 |
Returns
Type | Description |
---|---|
Minkowski | A Minkowski object implementing a Minkowski distance that is not necessarily a metric. Use at your own risk. |