Package elki.distance.minkowski
Class LPIntegerNormDistance
- java.lang.Object
-
- elki.distance.minkowski.LPNormDistance
-
- elki.distance.minkowski.LPIntegerNormDistance
-
- All Implemented Interfaces:
Distance<NumberVector>
,Norm<NumberVector>
,NumberVectorDistance<NumberVector>
,PrimitiveDistance<NumberVector>
,SpatialPrimitiveDistance<NumberVector>
- Direct Known Subclasses:
EuclideanDistance
,ManhattanDistance
public class LPIntegerNormDistance extends LPNormDistance
Lp-Norm forNumberVector
s, optimized version for integer values of p. This will likely not have huge impact, but may vary from CPU and virtual machine version.When using the parameterization API,
LPNormDistance
will automatically use this class for integer values.The Lp distance is defined as: \[ L_p(\vec{x},\vec{y}) := \left(\sum_i (x_i-y_i)\right)^{1/p} \]
- Since:
- 0.6.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LPIntegerNormDistance.Par
Parameterization class.
-
Field Summary
Fields Modifier and Type Field Description (package private) int
intp
Integer value of p.-
Fields inherited from class elki.distance.minkowski.LPNormDistance
invp, p
-
-
Constructor Summary
Constructors Constructor Description LPIntegerNormDistance(int p)
Constructor, internal version.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distance(NumberVector v1, NumberVector v2)
Computes the distance between two given DatabaseObjects according to this distance function.boolean
equals(java.lang.Object obj)
int
hashCode()
double
minDist(SpatialComparable mbr1, SpatialComparable mbr2)
Computes the distance between the two given MBRs according to this distance function.double
norm(NumberVector v)
Compute the norm of object obj.private double
preDistance(NumberVector v1, NumberVector v2, int start, int end)
Compute unscaled distance in a range of dimensions.private double
preDistanceMBR(SpatialComparable mbr1, SpatialComparable mbr2, int start, int end)
Compute unscaled distance in a range of dimensions.private double
preDistanceVM(NumberVector v, SpatialComparable mbr, int start, int end)
Compute unscaled distance in a range of dimensions.private double
preNorm(NumberVector v, int start, int end)
Compute unscaled norm in a range of dimensions.private double
preNormMBR(SpatialComparable mbr, int start, int end)
Compute unscaled norm in a range of dimensions.-
Methods inherited from class elki.distance.minkowski.LPNormDistance
getInputTypeRestriction, getInvP, getP, isMetric, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface elki.distance.Distance
isSquared, isSymmetric
-
Methods inherited from interface elki.distance.SpatialPrimitiveDistance
instantiate
-
-
-
-
Method Detail
-
preDistance
private double preDistance(NumberVector v1, NumberVector v2, int start, int end)
Compute unscaled distance in a range of dimensions.- Parameters:
v1
- First objectv2
- Second objectstart
- First dimensionend
- Exclusive last dimension- Returns:
- Aggregated values.
-
preDistanceVM
private double preDistanceVM(NumberVector v, SpatialComparable mbr, int start, int end)
Compute unscaled distance in a range of dimensions.- Parameters:
v
- First vectormbr
- Second MBRstart
- First dimensionend
- Exclusive last dimension- Returns:
- Aggregated values.
-
preDistanceMBR
private double preDistanceMBR(SpatialComparable mbr1, SpatialComparable mbr2, int start, int end)
Compute unscaled distance in a range of dimensions.- Parameters:
mbr1
- First MBRmbr2
- Second MBRstart
- First dimensionend
- Exclusive last dimension- Returns:
- Aggregated values.
-
preNorm
private double preNorm(NumberVector v, int start, int end)
Compute unscaled norm in a range of dimensions.- Parameters:
v
- Data objectstart
- First dimensionend
- Exclusive last dimension- Returns:
- Aggregated values.
-
preNormMBR
private double preNormMBR(SpatialComparable mbr, int start, int end)
Compute unscaled norm in a range of dimensions.- Parameters:
mbr
- Data objectstart
- First dimensionend
- Exclusive last dimension- Returns:
- Aggregated values.
-
distance
public double distance(NumberVector v1, NumberVector v2)
Description copied from interface:PrimitiveDistance
Computes the distance between two given DatabaseObjects according to this distance function.- Specified by:
distance
in interfaceNumberVectorDistance<NumberVector>
- Specified by:
distance
in interfacePrimitiveDistance<NumberVector>
- Overrides:
distance
in classLPNormDistance
- Parameters:
v1
- first DatabaseObjectv2
- second DatabaseObject- Returns:
- the distance between two given DatabaseObjects according to this distance function
-
norm
public double norm(NumberVector v)
Description copied from interface:Norm
Compute the norm of object obj.- Specified by:
norm
in interfaceNorm<NumberVector>
- Overrides:
norm
in classLPNormDistance
- Parameters:
v
- Object- Returns:
- Norm
-
minDist
public double minDist(SpatialComparable mbr1, SpatialComparable mbr2)
Description copied from interface:SpatialPrimitiveDistance
Computes the distance between the two given MBRs according to this distance function.- Specified by:
minDist
in interfaceSpatialPrimitiveDistance<NumberVector>
- Overrides:
minDist
in classLPNormDistance
- Parameters:
mbr1
- the first MBR objectmbr2
- the second MBR object- Returns:
- the distance between the two given MBRs according to this distance function
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classLPNormDistance
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classLPNormDistance
-
-