databionics.math
Class Distances

java.lang.Object
  extended by databionics.math.Distances
Direct Known Subclasses:
ParetoDensity

public class Distances
extends java.lang.Object

Computes all pairwise distances between row vectors of a DoubleMatrix2D. In contrast to Statistic.distance the values are stored in a DoubeArrayList of length N(N-1)/2 rather than in a DoubleMatrix2D.


Field Summary
protected  cern.colt.matrix.DoubleMatrix1D[] data
           
protected  cern.colt.matrix.DoubleMatrix2D data2d
           
protected  cern.colt.function.VectorVectorFunction distanceFunction
           
protected  cern.colt.matrix.DoubleMatrix1D distances
           
protected static org.apache.log4j.Logger log
           
protected  int n
           
 
Constructor Summary
Distances()
           
 
Method Summary
protected  void calculateDistances()
           
 double get(int i, int j)
          Get the distance between row i and j of the original data matrix
 cern.colt.matrix.DoubleMatrix2D getData()
           
 cern.colt.function.VectorVectorFunction getDistanceFunction()
           
 cern.colt.matrix.DoubleMatrix2D getDistanceMatrix()
          getting the pairwise distances from matrix/vector set in setData().
 cern.colt.matrix.DoubleMatrix1D getDistances()
          getting the pairwise distances from matrix/vector invoked in setData().
 void set(int i, int j, double d)
          set distance between i and j to d
 void setData(cern.colt.matrix.DoubleMatrix1D d)
           
 void setData(cern.colt.matrix.DoubleMatrix1D[] d)
           
 void setData(cern.colt.matrix.DoubleMatrix2D d)
           
 void setDistanceFunction(cern.colt.function.VectorVectorFunction d)
          set the function to calculate distances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log

distanceFunction

protected cern.colt.function.VectorVectorFunction distanceFunction

data2d

protected cern.colt.matrix.DoubleMatrix2D data2d

data

protected cern.colt.matrix.DoubleMatrix1D[] data

distances

protected cern.colt.matrix.DoubleMatrix1D distances

n

protected int n
Constructor Detail

Distances

public Distances()
Method Detail

getDistances

public cern.colt.matrix.DoubleMatrix1D getDistances()
                                             throws java.lang.NullPointerException
getting the pairwise distances from matrix/vector invoked in setData(). If distance function is not set, euclidian distance is used

Returns:
Distances of data matrix
Throws:
java.lang.NullPointerException

getDistanceMatrix

public cern.colt.matrix.DoubleMatrix2D getDistanceMatrix()
                                                  throws java.lang.NullPointerException
getting the pairwise distances from matrix/vector set in setData(). If distance function is not set, euclidian distance is used

Returns:
Distances of data matrix
Throws:
java.lang.NullPointerException

get

public double get(int i,
                  int j)
           throws java.lang.NullPointerException
Get the distance between row i and j of the original data matrix

Parameters:
i - row number of first data vector
j - row number of second data vector
Returns:
distance between rows i and j
Throws:
java.lang.NullPointerException

setDistanceFunction

public void setDistanceFunction(cern.colt.function.VectorVectorFunction d)
set the function to calculate distances. Former calculation of distances are reset to null.

Parameters:
VectorVectorFunction - distanceFunction

getDistanceFunction

public cern.colt.function.VectorVectorFunction getDistanceFunction()

setData

public void setData(cern.colt.matrix.DoubleMatrix2D d)

setData

public void setData(cern.colt.matrix.DoubleMatrix1D d)

setData

public void setData(cern.colt.matrix.DoubleMatrix1D[] d)

set

public void set(int i,
                int j,
                double d)
set distance between i and j to d

Parameters:
i -
j -
d -

calculateDistances

protected void calculateDistances()

getData

public cern.colt.matrix.DoubleMatrix2D getData()
                                        throws java.lang.NullPointerException
Returns:
Returns the data (for equality-check)
Throws:
java.lang.NullPointerException


Copyright © 2005-2006 Databionics Research Group. All Rights Reserved.