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

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.SquaredEuclideanDistanceFunction
All Implemented Interfaces:
DistanceFunction<NumberVector<?,?>,DoubleDistance>, PrimitiveDistanceFunction<NumberVector<?,?>,DoubleDistance>, PrimitiveDoubleDistanceFunction<NumberVector<?,?>>, SpatialPrimitiveDistanceFunction<NumberVector<?,?>,DoubleDistance>, SpatialPrimitiveDoubleDistanceFunction<NumberVector<?,?>>, InspectionUtilFrequentlyScanned, Parameterizable

public class SquaredEuclideanDistanceFunction
extends AbstractVectorDoubleDistanceFunction
implements SpatialPrimitiveDoubleDistanceFunction<NumberVector<?,?>>

Provides the squared Euclidean distance for FeatureVectors. This results in the same rankings, but saves computing the square root as often.


Nested Class Summary
static class SquaredEuclideanDistanceFunction.Parameterizer
          Parameterization class.
 
Field Summary
static SquaredEuclideanDistanceFunction STATIC
          Static instance.
 
Constructor Summary
SquaredEuclideanDistanceFunction()
          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)
          Provides the squared Euclidean distance between the given two vectors.
 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.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 SquaredEuclideanDistanceFunction STATIC
Static instance. Use this!

Constructor Detail

SquaredEuclideanDistanceFunction

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

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

Method Detail

doubleDistance

public double doubleDistance(NumberVector<?,?> v1,
                             NumberVector<?,?> v2)
Provides the squared Euclidean distance between the given two vectors.

Specified by:
doubleDistance in interface PrimitiveDoubleDistanceFunction<NumberVector<?,?>>
Parameters:
v1 - first Object
v2 - second Object
Returns:
the squared Euclidean distance between the given two vectors as raw double 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

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

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

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 AbstractPrimitiveDistanceFunction<NumberVector<?,?>,DoubleDistance>
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 Object

equals

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

Release 0.4.0 (2011-09-20_1324)