Package elki.distance.minkowski
Class SparseLPNormDistance
- java.lang.Object
-
- elki.distance.minkowski.SparseLPNormDistance
-
- All Implemented Interfaces:
Distance<SparseNumberVector>
,Norm<SparseNumberVector>
,PrimitiveDistance<SparseNumberVector>
- Direct Known Subclasses:
SparseEuclideanDistance
,SparseManhattanDistance
,SparseMaximumDistance
public class SparseLPNormDistance extends java.lang.Object implements PrimitiveDistance<SparseNumberVector>, Norm<SparseNumberVector>
Lp-Norm, optimized forSparseNumberVector
s.The Lp distance is defined as: \[ L_p(\vec{x},\vec{y}) := \left(\sum\nolimits_i (x_i-y_i)\right)^{1/p} \]
- Since:
- 0.5.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SparseLPNormDistance.Par
Parameterizer
-
Constructor Summary
Constructors Constructor Description SparseLPNormDistance(double p)
Constructor.
-
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)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
isSquared, isSymmetric
-
Methods inherited from interface elki.distance.PrimitiveDistance
instantiate
-
-
-
-
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
-
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.
-
-