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 forNumberVectors, 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,
LPNormDistancewill 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 classLPIntegerNormDistance.ParParameterization class.
-
Field Summary
Fields Modifier and Type Field Description (package private) intintpInteger 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 doubledistance(NumberVector v1, NumberVector v2)Computes the distance between two given DatabaseObjects according to this distance function.booleanequals(java.lang.Object obj)inthashCode()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(NumberVector v1, NumberVector v2, int start, int end)Compute unscaled distance in a range of dimensions.private doublepreDistanceMBR(SpatialComparable mbr1, SpatialComparable mbr2, int start, int end)Compute unscaled distance in a range of dimensions.private doublepreDistanceVM(NumberVector v, SpatialComparable mbr, int start, int end)Compute unscaled distance in a range of dimensions.private doublepreNorm(NumberVector v, int start, int end)Compute unscaled norm in a range of dimensions.private doublepreNormMBR(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:PrimitiveDistanceComputes the distance between two given DatabaseObjects according to this distance function.- Specified by:
distancein interfaceNumberVectorDistance<NumberVector>- Specified by:
distancein interfacePrimitiveDistance<NumberVector>- Overrides:
distancein 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:NormCompute the norm of object obj.- Specified by:
normin interfaceNorm<NumberVector>- Overrides:
normin classLPNormDistance- 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>- Overrides:
minDistin 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:
equalsin classLPNormDistance
-
hashCode
public int hashCode()
- Overrides:
hashCodein classLPNormDistance
-
-