de.lmu.ifi.dbs.elki.distance.distancevalue
Class DoubleDistance

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.distance.distancevalue.AbstractDistance<D>
      extended by de.lmu.ifi.dbs.elki.distance.distancevalue.NumberDistance<DoubleDistance,Double>
          extended by de.lmu.ifi.dbs.elki.distance.distancevalue.DoubleDistance
All Implemented Interfaces:
Distance<DoubleDistance>, Externalizable, Serializable, Comparable<DoubleDistance>

public class DoubleDistance
extends NumberDistance<DoubleDistance,Double>

Provides a Distance for a double-valued distance.

See Also:
Serialized Form

Field Summary
static DoubleDistance FACTORY
          The static factory instance
private static long serialVersionUID
          Generated serialVersionUID.
(package private)  double value
          The actual value.
 
Fields inherited from class de.lmu.ifi.dbs.elki.distance.distancevalue.AbstractDistance
DOUBLE_PATTERN, INFINITY_PATTERN, INTEGER_PATTERN
 
Constructor Summary
DoubleDistance()
          Empty constructor for serialization purposes.
DoubleDistance(double value)
          Constructs a new DoubleDistance object that represents the double argument.
 
Method Summary
 int compareTo(DoubleDistance other)
          Compares this NumberDistance with the given NumberDistance wrt the represented value.
 double doubleValue()
          Get the value as double.
 int externalizableSize()
          Returns the number of Bytes this distance uses if it is written to an external file.
 DoubleDistance fromDouble(double val)
          Build a new instance from a double value.
 Pattern getPattern()
          Get the pattern accepted by this distance
 Double getValue()
          Returns the value of this NumberDistance.
 int hashCode()
          Returns the hash code for this NumberDistance, which is the hash code of its value.
 DoubleDistance infiniteDistance()
          An infinite DoubleDistance is based on Double.POSITIVE_INFINITY.
 boolean isInfiniteDistance()
          Returns true, if the distance is an infinite distance, false otherwise.
 boolean isNullDistance()
          Returns true, if the distance is a null distance, false otherwise.
 boolean isUndefinedDistance()
          Returns true, if the distance is an undefined distance, false otherwise.
 long longValue()
          Get the value as long.
 DoubleDistance minus(DoubleDistance distance)
          Returns a new Distance by subtracting the given distance from this distance.
 DoubleDistance nullDistance()
          A null DoubleDistance is based on 0.
 DoubleDistance parseString(String val)
          As pattern is required a String defining a Double.
 DoubleDistance plus(DoubleDistance distance)
          Returns a new distance as sum of this distance and the given distance.
 void readExternal(ObjectInput in)
          Reads the double value of this DoubleDistance from the specified stream.
(package private)  void setValue(Double value)
          Sets the value of this NumberDistance.
 DoubleDistance times(double lambda)
          Returns a new distance as the product of this distance and the given double value.
 DoubleDistance times(DoubleDistance distance)
          Returns a new distance as the product of this distance and the given distance.
 DoubleDistance undefinedDistance()
          An undefined DoubleDistance is based on Double.NaN.
 void writeExternal(ObjectOutput out)
          Writes the double value of this DoubleDistance to the specified stream.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancevalue.NumberDistance
byteValue, floatValue, intValue, shortValue, toString
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancevalue.AbstractDistance
equals, requiredInputPattern, testInputPattern
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FACTORY

public static final DoubleDistance FACTORY
The static factory instance


value

double value
The actual value.


serialVersionUID

private static final long serialVersionUID
Generated serialVersionUID.

See Also:
Constant Field Values
Constructor Detail

DoubleDistance

public DoubleDistance()
Empty constructor for serialization purposes.


DoubleDistance

public DoubleDistance(double value)
Constructs a new DoubleDistance object that represents the double argument.

Parameters:
value - the value to be represented by the DoubleDistance.
Method Detail

fromDouble

public DoubleDistance fromDouble(double val)
Description copied from class: NumberDistance
Build a new instance from a double value.

Specified by:
fromDouble in class NumberDistance<DoubleDistance,Double>
Parameters:
val - Value
Returns:
Distance

plus

public DoubleDistance plus(DoubleDistance distance)
Description copied from interface: Distance
Returns a new distance as sum of this distance and the given distance.

Parameters:
distance - the distance to be added to this distance
Returns:
a new distance as sum of this distance and the given distance

minus

public DoubleDistance minus(DoubleDistance distance)
Description copied from interface: Distance
Returns a new Distance by subtracting the given distance from this distance.

Parameters:
distance - the distance to be subtracted from this distance
Returns:
a new Distance by subtracting the given distance from this distance

times

public DoubleDistance times(DoubleDistance distance)
Returns a new distance as the product of this distance and the given distance.

Parameters:
distance - the distance to be multiplied with this distance
Returns:
a new distance as the product of this distance and the given distance

times

public DoubleDistance times(double lambda)
Returns a new distance as the product of this distance and the given double value.

Parameters:
lambda - the double value this distance should be multiplied with
Returns:
a new distance as the product of this distance and the given double value

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Writes the double value of this DoubleDistance to the specified stream.

Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Reads the double value of this DoubleDistance from the specified stream.

Throws:
IOException

externalizableSize

public int externalizableSize()
Returns the number of Bytes this distance uses if it is written to an external file.

Returns:
8 (8 Byte for a double value)

getValue

public Double getValue()
Description copied from class: NumberDistance
Returns the value of this NumberDistance.

Specified by:
getValue in class NumberDistance<DoubleDistance,Double>
Returns:
the value of this NumberDistance

setValue

void setValue(Double value)
Description copied from class: NumberDistance
Sets the value of this NumberDistance.

Specified by:
setValue in class NumberDistance<DoubleDistance,Double>
Parameters:
value - the value to be set

doubleValue

public double doubleValue()
Description copied from class: NumberDistance
Get the value as double.

Specified by:
doubleValue in class NumberDistance<DoubleDistance,Double>
Returns:
same result as getValue().doubleValue() but may be more efficient.

longValue

public long longValue()
Description copied from class: NumberDistance
Get the value as long.

Specified by:
longValue in class NumberDistance<DoubleDistance,Double>
Returns:
same result as getValue().longValue() but may be more efficient.

compareTo

public int compareTo(DoubleDistance other)
Description copied from class: NumberDistance
Compares this NumberDistance with the given NumberDistance wrt the represented value.

d1.compareTo(d2) is the same as Double.compare(d1.value.doubleValue(), d2.value.doubleValue()). Subclasses may need to overwrite this method if necessary.

Specified by:
compareTo in interface Comparable<DoubleDistance>
Overrides:
compareTo in class NumberDistance<DoubleDistance,Double>
Parameters:
other - Other object
Returns:
a negative integer, zero, or a positive integer as the value of this NumberDistance is less than, equal to, or greater than the value of the specified NumberDistance.

infiniteDistance

public DoubleDistance infiniteDistance()
An infinite DoubleDistance is based on Double.POSITIVE_INFINITY.

Returns:
an infinite distance

nullDistance

public DoubleDistance nullDistance()
A null DoubleDistance is based on 0.

Returns:
a null distance

undefinedDistance

public DoubleDistance undefinedDistance()
An undefined DoubleDistance is based on Double.NaN.

Returns:
an undefined distance

parseString

public DoubleDistance parseString(String val)
                           throws IllegalArgumentException
As pattern is required a String defining a Double.

Parameters:
val - a pattern defining a similarity suitable to this measurement function
Returns:
a measurement suitable to this measurement function based on the given pattern
Throws:
IllegalArgumentException - if the given pattern is not compatible with the requirements of this measurement function

isInfiniteDistance

public boolean isInfiniteDistance()
Description copied from interface: Distance
Returns true, if the distance is an infinite distance, false otherwise.

Specified by:
isInfiniteDistance in interface Distance<DoubleDistance>
Overrides:
isInfiniteDistance in class AbstractDistance<DoubleDistance>
Returns:
true, if the distance is an infinite distance, false otherwise

isNullDistance

public boolean isNullDistance()
Description copied from interface: Distance
Returns true, if the distance is a null distance, false otherwise.

Specified by:
isNullDistance in interface Distance<DoubleDistance>
Overrides:
isNullDistance in class AbstractDistance<DoubleDistance>
Returns:
true, if the distance is a null distance, false otherwise

isUndefinedDistance

public boolean isUndefinedDistance()
Description copied from interface: Distance
Returns true, if the distance is an undefined distance, false otherwise.

Specified by:
isUndefinedDistance in interface Distance<DoubleDistance>
Overrides:
isUndefinedDistance in class AbstractDistance<DoubleDistance>
Returns:
true, if the distance is an undefined distance, false otherwise

getPattern

public Pattern getPattern()
Description copied from class: AbstractDistance
Get the pattern accepted by this distance

Specified by:
getPattern in class AbstractDistance<DoubleDistance>
Returns:
Pattern

hashCode

public int hashCode()
Description copied from class: NumberDistance
Returns the hash code for this NumberDistance, which is the hash code of its value.

Overrides:
hashCode in class NumberDistance<DoubleDistance,Double>
Returns:
the hash code of the value

Release 0.4.0 (2011-09-20_1324)