Package elki.distance.minkowski
Class SparseSquaredEuclideanDistance
- java.lang.Object
-
- elki.distance.minkowski.SparseSquaredEuclideanDistance
-
- All Implemented Interfaces:
Distance<SparseNumberVector>
,Norm<SparseNumberVector>
,PrimitiveDistance<SparseNumberVector>
public class SparseSquaredEuclideanDistance extends java.lang.Object implements PrimitiveDistance<SparseNumberVector>, Norm<SparseNumberVector>
Squared Euclidean distance function, optimized forSparseNumberVector
s.Squared Euclidean distance is defined as: \[ \text{Euclidean}^2(\vec{x},\vec{y}) := \sum\nolimits_i (x_i-y_i)^2 \]
For sparse vectors, we can skip those i where both vectors are 0.
- Since:
- 0.7.5
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SparseSquaredEuclideanDistance.Par
Parameterizer
-
Field Summary
Fields Modifier and Type Field Description static SparseSquaredEuclideanDistance
STATIC
Static instance
-
Constructor Summary
Constructors Constructor Description SparseSquaredEuclideanDistance()
Deprecated.Use static instance instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distance(SparseNumberVector v1, SparseNumberVector v2)
Computes the distance between two given DatabaseObjects according to this distance function.SimpleTypeInformation<? super SparseNumberVector>
getInputTypeRestriction()
Get the input data type of the function.boolean
isMetric()
Is this distance function metric (satisfy the triangle inequality)boolean
isSquared()
Squared distances, that would become metric after square root.double
norm(SparseNumberVector v1)
Compute the norm of object obj.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.distance.Distance
isSymmetric
-
Methods inherited from interface elki.distance.PrimitiveDistance
instantiate
-
-
-
-
Field Detail
-
STATIC
public static final SparseSquaredEuclideanDistance STATIC
Static instance
-
-
Constructor Detail
-
SparseSquaredEuclideanDistance
@Deprecated public SparseSquaredEuclideanDistance()
Deprecated.Use static instance instead.Constructor - useSTATIC
instead.
-
-
Method Detail
-
distance
public double distance(SparseNumberVector v1, SparseNumberVector v2)
Description copied from interface:PrimitiveDistance
Computes the distance between two given DatabaseObjects according to this distance function.- Specified by:
distance
in interfacePrimitiveDistance<SparseNumberVector>
- Parameters:
v1
- first DatabaseObjectv2
- second DatabaseObject- Returns:
- the distance between two given DatabaseObjects according to this distance function
-
norm
public double norm(SparseNumberVector v1)
Description copied from interface:Norm
Compute the norm of object obj.- Specified by:
norm
in interfaceNorm<SparseNumberVector>
- Parameters:
v1
- Object- Returns:
- Norm
-
getInputTypeRestriction
public SimpleTypeInformation<? super SparseNumberVector> getInputTypeRestriction()
Description copied from interface:Distance
Get the input data type of the function.- Specified by:
getInputTypeRestriction
in interfaceDistance<SparseNumberVector>
- Specified by:
getInputTypeRestriction
in interfacePrimitiveDistance<SparseNumberVector>
- Returns:
- Type restriction
-
isSquared
public boolean isSquared()
Description copied from interface:Distance
Squared distances, that would become metric after square root.E.g. squared Euclidean.
- Specified by:
isSquared
in interfaceDistance<SparseNumberVector>
- Returns:
true
when squared.
-
isMetric
public boolean isMetric()
Description copied from interface:Distance
Is this distance function metric (satisfy the triangle inequality)- Specified by:
isMetric
in interfaceDistance<SparseNumberVector>
- Returns:
true
when metric.
-
-