Package elki.distance.minkowski
Class SquaredEuclideanDistance
- java.lang.Object
-
- elki.distance.AbstractNumberVectorDistance
-
- elki.distance.minkowski.SquaredEuclideanDistance
-
- All Implemented Interfaces:
Distance<NumberVector>,Norm<NumberVector>,NumberVectorDistance<NumberVector>,PrimitiveDistance<NumberVector>,SpatialPrimitiveDistance<NumberVector>
@Alias("squaredeuclidean") public class SquaredEuclideanDistance extends AbstractNumberVectorDistance implements SpatialPrimitiveDistance<NumberVector>, Norm<NumberVector>
Squared Euclidean distance, optimized forSparseNumberVectors. This results in the same rankings as regular Euclidean distance, but saves computing the square root.Squared Euclidean is defined as: \[ \text{Euclidean}^2(\vec{x},\vec{y}) := \sum_i (x_i-y_i)^2 \]
- Since:
- 0.1
- Author:
- Arthur Zimek
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSquaredEuclideanDistance.ParParameterization class.
-
Field Summary
Fields Modifier and Type Field Description static SquaredEuclideanDistanceSTATICStatic instance.
-
Constructor Summary
Constructors Constructor Description SquaredEuclideanDistance()Deprecated.Use static instance!
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubledistance(double[] v1, double[] v2)Special version for double arrays.doubledistance(NumberVector v1, NumberVector v2)Computes the distance between two given DatabaseObjects according to this distance function.booleanequals(java.lang.Object obj)SimpleTypeInformation<? super NumberVector>getInputTypeRestriction()Get the input data type of the function.inthashCode()booleanisSquared()Squared distances, that would become metric after square root.doubleminDist(SpatialComparable mbr1, SpatialComparable mbr2)Computes the distance between the two given MBRs according to this distance function.doublenorm(NumberVector v)Compute the norm of object obj.private doublepreDistance(double[] v1, double[] v2, int start, int end)private doublepreDistance(NumberVector v1, NumberVector v2, int start, int end)private doublepreDistanceMBR(SpatialComparable mbr1, SpatialComparable mbr2, int start, int end)private doublepreDistanceVM(NumberVector v, SpatialComparable mbr, int start, int end)private doublepreNorm(double[] v, int start, int end)private doublepreNorm(NumberVector v, int start, int end)private doublepreNormMBR(SpatialComparable mbr, int start, int end)java.lang.StringtoString()-
Methods inherited from class elki.distance.AbstractNumberVectorDistance
dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface elki.distance.Distance
isMetric, isSymmetric
-
Methods inherited from interface elki.distance.SpatialPrimitiveDistance
instantiate
-
-
-
-
Field Detail
-
STATIC
public static final SquaredEuclideanDistance STATIC
Static instance. Use this!
-
-
Constructor Detail
-
SquaredEuclideanDistance
@Deprecated public SquaredEuclideanDistance()
Deprecated.Use static instance!Constructor - useSTATICinstead.
-
-
Method Detail
-
preDistance
private double preDistance(double[] v1, double[] v2, int start, int end)
-
preDistance
private double preDistance(NumberVector v1, NumberVector v2, int start, int end)
-
preDistanceVM
private double preDistanceVM(NumberVector v, SpatialComparable mbr, int start, int end)
-
preDistanceMBR
private double preDistanceMBR(SpatialComparable mbr1, SpatialComparable mbr2, int start, int end)
-
preNorm
private double preNorm(NumberVector v, int start, int end)
-
preNorm
private double preNorm(double[] v, int start, int end)
-
preNormMBR
private double preNormMBR(SpatialComparable mbr, int start, int end)
-
distance
public double distance(NumberVector v1, NumberVector v2)
Description copied from interface:PrimitiveDistanceComputes the distance between two given DatabaseObjects according to this distance function.- Specified by:
distancein interfaceNumberVectorDistance<NumberVector>- Specified by:
distancein interfacePrimitiveDistance<NumberVector>- Parameters:
v1- first DatabaseObjectv2- second DatabaseObject- Returns:
- the distance between two given DatabaseObjects according to this distance function
-
distance
public double distance(double[] v1, double[] v2)Special version for double arrays.
-
norm
public double norm(NumberVector v)
Description copied from interface:NormCompute the norm of object obj.- Specified by:
normin interfaceNorm<NumberVector>- Parameters:
v- Object- Returns:
- Norm
-
minDist
public double minDist(SpatialComparable mbr1, SpatialComparable mbr2)
Description copied from interface:SpatialPrimitiveDistanceComputes the distance between the two given MBRs according to this distance function.- Specified by:
minDistin interfaceSpatialPrimitiveDistance<NumberVector>- Parameters:
mbr1- the first MBR objectmbr2- the second MBR object- Returns:
- the distance between the two given MBRs according to this distance function
-
isSquared
public boolean isSquared()
Description copied from interface:DistanceSquared distances, that would become metric after square root.E.g. squared Euclidean.
- Specified by:
isSquaredin interfaceDistance<NumberVector>- Returns:
truewhen squared.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getInputTypeRestriction
public SimpleTypeInformation<? super NumberVector> getInputTypeRestriction()
Description copied from interface:DistanceGet the input data type of the function.- Specified by:
getInputTypeRestrictionin interfaceDistance<NumberVector>- Specified by:
getInputTypeRestrictionin interfacePrimitiveDistance<NumberVector>- Overrides:
getInputTypeRestrictionin classAbstractNumberVectorDistance- Returns:
- Type restriction
-
-