Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance
Class SubspaceDistance

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

public class SubspaceDistance
extends AbstractDistance<SubspaceDistance>

The subspace distance is a special distance that indicates the dissimilarity between subspaces of equal dimensionality. The subspace distance between two points is a pair consisting of the distance between the two subspaces spanned by the strong eigenvectors of the two points and the affine distance between the two subspaces.

Author:
Elke Achtert
See Also:
Serialized Form

Field Summary
private  double affineDistance
          The affine distance.
static Pattern SEPARATOR
          Indicates a separator.
private static long serialVersionUID
           
private  double subspaceDistance
          The subspace distance.
 
Constructor Summary
SubspaceDistance()
          Empty constructor for serialization purposes.
SubspaceDistance(double subspaceDistance, double affineDistance)
          Constructs a new SubspaceDistance object consisting of the specified subspace distance and affine distance.
 
Method Summary
 int compareTo(SubspaceDistance other)
          Compares this SubspaceDistance with the given SubspaceDistance wrt the represented subspace distance values.
 String description()
          Returns a String as description of this Distance.
 int externalizableSize()
          Returns the number of Bytes this distance uses if it is written to an external file.
 double getAffineDistance()
          Returns the value of the affine distance.
 double getSubspaceDistance()
          Returns the value of the subspace distance.
 int hashCode()
          Any extending class should implement a proper hashCode method.
 SubspaceDistance minus(SubspaceDistance distance)
          Returns a new Distance by subtracting the given distance from this distance.
 SubspaceDistance plus(SubspaceDistance distance)
          Returns a new distance as sum of this distance and the given distance.
 void readExternal(ObjectInput in)
          Reads the subspace distance value and the affine distance value of this SubspaceDistance from the specified stream.
 String toString()
          Returns a string representation of this SubspaceDistance.
 void writeExternal(ObjectOutput out)
          Writes the subspace distance value and the affine distance value of this SubspaceDistance to the specified stream.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.AbstractDistance
equals
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

SEPARATOR

public static final Pattern SEPARATOR
Indicates a separator.


subspaceDistance

private double subspaceDistance
The subspace distance.


affineDistance

private double affineDistance
The affine distance.

Constructor Detail

SubspaceDistance

public SubspaceDistance()
Empty constructor for serialization purposes.


SubspaceDistance

public SubspaceDistance(double subspaceDistance,
                        double affineDistance)
Constructs a new SubspaceDistance object consisting of the specified subspace distance and affine distance.

Parameters:
subspaceDistance - the distance between the two subspaces spanned by the strong eigenvectors of the two points
affineDistance - the affine distance between the two subspaces
Method Detail

plus

public SubspaceDistance plus(SubspaceDistance 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 SubspaceDistance minus(SubspaceDistance 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

description

public String description()
Description copied from interface: Distance
Returns a String as description of this Distance.

Returns:
a String as description of this Distance

toString

public String toString()
Returns a string representation of this SubspaceDistance.

Specified by:
toString in interface Distance<SubspaceDistance>
Overrides:
toString in class Object
Returns:
the values of the subspace distance and the affine distance separated by blank

compareTo

public int compareTo(SubspaceDistance other)
Compares this SubspaceDistance with the given SubspaceDistance wrt the represented subspace distance values. If both values are considered to be equal, the values of the affine distances are compared.

Returns:
the value of Double.compare(this.subspaceDistance, other.subspaceDistance) if it is a non zero value, the value of Double.compare(this.affineDistance, other.affineDistance) otherwise

hashCode

public int hashCode()
Description copied from class: AbstractDistance
Any extending class should implement a proper hashCode method.

Specified by:
hashCode in class AbstractDistance<SubspaceDistance>

getSubspaceDistance

public double getSubspaceDistance()
Returns the value of the subspace distance.

Returns:
the value of the subspace distance

getAffineDistance

public double getAffineDistance()
Returns the value of the affine distance.

Returns:
the value of the affine distance

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Writes the subspace distance value and the affine distance value of this SubspaceDistance to the specified stream.

Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Reads the subspace distance value and the affine distance value of this SubspaceDistance 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:
16 (2 * 8 Byte for two double values)

Release 0.2 (2009-07-06_1820)