de.lmu.ifi.dbs.elki.distance.distancefunction
Class ManhattanDistanceFunction

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractPrimitiveDistanceFunction<NumberVector<?,?>,DoubleDistance>
      extended by de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractVectorDoubleDistanceFunction
          extended by de.lmu.ifi.dbs.elki.distance.distancefunction.LPNormDistanceFunction
              extended by de.lmu.ifi.dbs.elki.distance.distancefunction.ManhattanDistanceFunction
All Implemented Interfaces:
DistanceFunction<NumberVector<?,?>,DoubleDistance>, PrimitiveDistanceFunction<NumberVector<?,?>,DoubleDistance>, PrimitiveDoubleDistanceFunction<NumberVector<?,?>>, SpatialPrimitiveDistanceFunction<NumberVector<?,?>,DoubleDistance>, SpatialPrimitiveDoubleDistanceFunction<NumberVector<?,?>>, InspectionUtilFrequentlyScanned, Parameterizable

public class ManhattanDistanceFunction
extends LPNormDistanceFunction
implements SpatialPrimitiveDoubleDistanceFunction<NumberVector<?,?>>

Manhattan distance function to compute the Manhattan distance for a pair of FeatureVectors.


Nested Class Summary
static class ManhattanDistanceFunction.Parameterizer
          Parameterization class.
 
Field Summary
static ManhattanDistanceFunction STATIC
          The static instance to use.
 
Fields inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.LPNormDistanceFunction
P_ID
 
Constructor Summary
ManhattanDistanceFunction()
          Deprecated. Use static instance!
 
Method Summary
 DoubleDistance centerDistance(SpatialComparable mbr1, SpatialComparable mbr2)
          Computes the distance between the centroids of the two given MBRs according to this distance function.
 double doubleCenterDistance(SpatialComparable mbr1, SpatialComparable mbr2)
          Computes the distance between the centroids of the two given MBRs according to this distance function.
 double doubleDistance(NumberVector<?,?> v1, NumberVector<?,?> v2)
          Compute the Manhattan distance
 double doubleMinDist(SpatialComparable mbr1, SpatialComparable mbr2)
          Computes the distance between the two given MBRs according to this distance function.
protected  double doubleMinDistObject(SpatialComparable mbr, NumberVector<?,?> v)
           
 boolean equals(Object obj)
           
<T extends NumberVector<?,?>>
SpatialPrimitiveDistanceQuery<T,DoubleDistance>
instantiate(Relation<T> relation)
          Instantiate with a database to get the actual distance query.
 boolean isMetric()
          Is this distance function metric (in particular, does it satisfy the triangle equation?)
 DoubleDistance minDist(SpatialComparable mbr1, SpatialComparable mbr2)
          Computes the distance between the two given MBRs according to this distance function.
 String toString()
           
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.LPNormDistanceFunction
getP
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractVectorDoubleDistanceFunction
distance, getDistanceFactory, getInputTypeRestriction
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractPrimitiveDistanceFunction
isSymmetric
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.distance.distancefunction.PrimitiveDistanceFunction
distance, getInputTypeRestriction
 
Methods inherited from interface de.lmu.ifi.dbs.elki.distance.distancefunction.DistanceFunction
getDistanceFactory, isSymmetric
 

Field Detail

STATIC

public static final ManhattanDistanceFunction STATIC
The static instance to use.

Constructor Detail

ManhattanDistanceFunction

@Deprecated
public ManhattanDistanceFunction()
Deprecated. Use static instance!

Provides a Manhattan distance function that can compute the Manhattan distance (that is a DoubleDistance) for FeatureVectors.

Method Detail

doubleDistance

public double doubleDistance(NumberVector<?,?> v1,
                             NumberVector<?,?> v2)
Compute the Manhattan distance

Specified by:
doubleDistance in interface PrimitiveDoubleDistanceFunction<NumberVector<?,?>>
Overrides:
doubleDistance in class LPNormDistanceFunction
Parameters:
v1 - first vector
v2 - second vector
Returns:
Manhattan distance value

doubleMinDistObject

protected double doubleMinDistObject(SpatialComparable mbr,
                                     NumberVector<?,?> v)

doubleMinDist

public double doubleMinDist(SpatialComparable mbr1,
                            SpatialComparable mbr2)
Description copied from interface: SpatialPrimitiveDoubleDistanceFunction
Computes the distance between the two given MBRs according to this distance function.

Specified by:
doubleMinDist in interface SpatialPrimitiveDoubleDistanceFunction<NumberVector<?,?>>
Parameters:
mbr1 - the first MBR object
mbr2 - the second MBR object
Returns:
the distance between the two given MBRs according to this distance function

doubleCenterDistance

public double doubleCenterDistance(SpatialComparable mbr1,
                                   SpatialComparable mbr2)
Description copied from interface: SpatialPrimitiveDoubleDistanceFunction
Computes the distance between the centroids of the two given MBRs according to this distance function.

Specified by:
doubleCenterDistance in interface SpatialPrimitiveDoubleDistanceFunction<NumberVector<?,?>>
Parameters:
mbr1 - the first MBR object
mbr2 - the second MBR object
Returns:
the distance between the centroids of the two given MBRs according to this distance function

minDist

public DoubleDistance minDist(SpatialComparable mbr1,
                              SpatialComparable mbr2)
Description copied from interface: SpatialPrimitiveDistanceFunction
Computes the distance between the two given MBRs according to this distance function.

Specified by:
minDist in interface SpatialPrimitiveDistanceFunction<NumberVector<?,?>,DoubleDistance>
Parameters:
mbr1 - the first MBR object
mbr2 - the second MBR object
Returns:
the distance between the two given MBRs according to this distance function

centerDistance

public DoubleDistance centerDistance(SpatialComparable mbr1,
                                     SpatialComparable mbr2)
Description copied from interface: SpatialPrimitiveDistanceFunction
Computes the distance between the centroids of the two given MBRs according to this distance function.

Specified by:
centerDistance in interface SpatialPrimitiveDistanceFunction<NumberVector<?,?>,DoubleDistance>
Parameters:
mbr1 - the first MBR object
mbr2 - the second MBR object
Returns:
the distance between the centroids of the two given MBRs according to this distance function

isMetric

public boolean isMetric()
Description copied from interface: DistanceFunction
Is this distance function metric (in particular, does it satisfy the triangle equation?)

Specified by:
isMetric in interface DistanceFunction<NumberVector<?,?>,DoubleDistance>
Overrides:
isMetric in class LPNormDistanceFunction
Returns:
true when metric.

instantiate

public <T extends NumberVector<?,?>> SpatialPrimitiveDistanceQuery<T,DoubleDistance> instantiate(Relation<T> relation)
Description copied from class: AbstractPrimitiveDistanceFunction
Instantiate with a database to get the actual distance query.

Specified by:
instantiate in interface DistanceFunction<NumberVector<?,?>,DoubleDistance>
Specified by:
instantiate in interface SpatialPrimitiveDistanceFunction<NumberVector<?,?>,DoubleDistance>
Overrides:
instantiate in class AbstractPrimitiveDistanceFunction<NumberVector<?,?>,DoubleDistance>
Parameters:
relation - Representation
Returns:
Actual distance query.

toString

public String toString()
Overrides:
toString in class LPNormDistanceFunction

equals

public boolean equals(Object obj)
Overrides:
equals in class LPNormDistanceFunction

Release 0.4.0 (2011-09-20_1324)