Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance.distancefunction
Class DimensionSelectingDistanceFunction<N extends Number,O extends FeatureVector<O,N>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
          extended by de.lmu.ifi.dbs.elki.distance.AbstractMeasurementFunction<O,D>
              extended by de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDistanceFunction<O,DoubleDistance>
                  extended by de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDoubleDistanceFunction<O>
                      extended by de.lmu.ifi.dbs.elki.distance.distancefunction.DimensionSelectingDistanceFunction<N,O>
All Implemented Interfaces:
DistanceFunction<O,DoubleDistance>, MeasurementFunction<O,DoubleDistance>, SpatialDistanceFunction<O,DoubleDistance>, Loggable, Parameterizable

public class DimensionSelectingDistanceFunction<N extends Number,O extends FeatureVector<O,N>>
extends AbstractDoubleDistanceFunction<O>
implements SpatialDistanceFunction<O,DoubleDistance>

Provides a distance function that computes the distance between feature vectors as the absolute difference of their values in a specified dimension.

Author:
Elke Achtert

Field Summary
private  int dim
          The dimension to be considered for distance computation.
static String DIM_D
          Description for parameter dim.
static String DIM_P
          Option string for parameter dim.
 
Fields inherited from class de.lmu.ifi.dbs.elki.distance.AbstractMeasurementFunction
INFINITY_PATTERN
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
optionHandler
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Constructor Summary
DimensionSelectingDistanceFunction()
           
 
Method Summary
 DoubleDistance centerDistance(HyperBoundingBox mbr1, HyperBoundingBox mbr2)
          Computes the distance between the centroids of the two given MBRs according to this distance function.
 String description()
          Returns a description of the class and the required parameters.
 DoubleDistance distance(HyperBoundingBox mbr1, HyperBoundingBox mbr2)
          Computes the distance between the two given MBRs according to this distance function.
 DoubleDistance distance(O o1, O o2)
          Computes the distance between two given DatabaseObjects according to this distance function.
 int getSelectedDimension()
          Returns the selected dimension.
 DoubleDistance minDist(HyperBoundingBox mbr, Integer id)
          Computes the minimum distance between the given MBR and the NumberVector object with the given id according to this distance function.
 DoubleDistance minDist(HyperBoundingBox mbr, O o)
          Computes the minimum distance between the given MBR and the NumberVector object according to this distance function.
 String[] setParameters(String[] args)
          Sets the attributes of the class accordingly to the given parameters.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDoubleDistanceFunction
infiniteDistance, nullDistance, undefinedDistance, valueOf
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDistanceFunction
distance, distance, isInfiniteDistance, isNullDistance, isUndefinedDistance
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.AbstractMeasurementFunction
getDatabase, matches, requiredInputPattern, setDatabase, setRequiredInputPattern
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
addOption, checkGlobalParameterConstraints, deleteOption, description, description, getAttributeSettings, getParameters, getParameterValue, getPossibleOptions, inlineDescription, isSet, setParameters
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.distance.distancefunction.DistanceFunction
distance, distance
 
Methods inherited from interface de.lmu.ifi.dbs.elki.distance.MeasurementFunction
infiniteDistance, isInfiniteDistance, isNullDistance, isUndefinedDistance, nullDistance, requiredInputPattern, setDatabase, undefinedDistance, valueOf
 
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, getAttributeSettings, getParameters, getPossibleOptions, inlineDescription
 

Field Detail

DIM_P

public static final String DIM_P
Option string for parameter dim.

See Also:
Constant Field Values

DIM_D

public static final String DIM_D
Description for parameter dim.

See Also:
Constant Field Values

dim

private int dim
The dimension to be considered for distance computation.

Constructor Detail

DimensionSelectingDistanceFunction

public DimensionSelectingDistanceFunction()
Method Detail

distance

public DoubleDistance distance(O o1,
                               O o2)
Computes the distance between two given DatabaseObjects according to this distance function.

Specified by:
distance in interface DistanceFunction<O extends FeatureVector<O,N>,DoubleDistance>
Parameters:
o1 - first DatabaseObject
o2 - second DatabaseObject
Returns:
the distance between two given DatabaseObjects according to this distance function

description

public String description()
Returns a description of the class and the required parameters.

This description should be suitable for a usage description.

Specified by:
description in interface Parameterizable
Overrides:
description in class AbstractParameterizable
Returns:
String a description of the class and the required parameters
See Also:
Parameterizable.description()

minDist

public DoubleDistance minDist(HyperBoundingBox mbr,
                              O o)
Computes the minimum distance between the given MBR and the NumberVector object according to this distance function.

Specified by:
minDist in interface SpatialDistanceFunction<O extends FeatureVector<O,N>,DoubleDistance>
Parameters:
mbr - the MBR object
o - the NumberVector object
Returns:
the minimum distance between the given MBR and the SpatialData object according to this distance function

minDist

public DoubleDistance minDist(HyperBoundingBox mbr,
                              Integer id)
Computes the minimum distance between the given MBR and the NumberVector object with the given id according to this distance function.

Specified by:
minDist in interface SpatialDistanceFunction<O extends FeatureVector<O,N>,DoubleDistance>
Parameters:
mbr - the MBR object
id - the id of the NumberVector object
Returns:
the minimum distance between the given MBR and the SpatialData object according to this distance function

distance

public DoubleDistance distance(HyperBoundingBox mbr1,
                               HyperBoundingBox mbr2)
Computes the distance between the two given MBRs according to this distance function.

Specified by:
distance in interface SpatialDistanceFunction<O extends FeatureVector<O,N>,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(HyperBoundingBox mbr1,
                                     HyperBoundingBox mbr2)
Computes the distance between the centroids of the two given MBRs according to this distance function.

Specified by:
centerDistance in interface SpatialDistanceFunction<O extends FeatureVector<O,N>,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

setParameters

public String[] setParameters(String[] args)
                       throws ParameterException
Description copied from interface: Parameterizable
Sets the attributes of the class accordingly to the given parameters. Returns a new String array containing those entries of the given array that are neither expected nor used by this Parameterizable.

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractParameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
String[] an array containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting
See Also:
Parameterizable.setParameters(String[])

getSelectedDimension

public int getSelectedDimension()
Returns the selected dimension.

Returns:
the selected dimension

Release 0.1 (2008-07-10_1838)