|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.tuwien.ifs.somtoolbox.data.distance.InputVectorDistanceMatrix
public abstract class InputVectorDistanceMatrix
Base for classes providing a distance matrix of the input vectors, with generic methods and fields.
A distance matrix is of size n*n
, where n
is the number of input vectors. The matrix is
symmetric, i.e. the upper-right and lower-left halves contain the same values. The diagonal contains the distances of
one element to itself, and is thus always 0.
Field Summary | |
---|---|
protected ArrayList<String> |
inputLabels
|
protected DistanceMetric |
metric
|
protected int |
numVectors
|
Constructor Summary | |
---|---|
InputVectorDistanceMatrix()
|
Method Summary | |
---|---|
int |
columns()
|
boolean |
equals(Object obj)
|
protected int |
flatArraySize()
|
abstract double |
getDistance(int x,
int y)
Return the distance between input vectors x and y. |
double[] |
getDistances(int x)
Return the distances to all vectors from input x. |
double[] |
getDistancesFlat()
Gets all the distances in a single flat array avoiding duplicates from the pairwise distances, thus of the size of numVectors * (numVectors - * 1) / 2 .This is a default implementation always constructing the array on the fly using the getDistance(int, int) method. |
cern.colt.matrix.impl.DenseDoubleMatrix1D |
getDistancesFlatAsMatrix()
|
ArrayList<String> |
getInputLabels()
|
DistanceMetric |
getMetric()
|
int[] |
getNNearest(int x,
int num)
Return the n nearest vectors of input x. |
static InputVectorDistanceMatrix |
initFromFile(String fileName)
Factory method that reads and creates an InputVectorDistanceMatrix from the given file. |
int |
numVectors()
|
int |
rows()
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int numVectors
protected DistanceMetric metric
protected ArrayList<String> inputLabels
Constructor Detail |
---|
public InputVectorDistanceMatrix()
Method Detail |
---|
public DistanceMetric getMetric()
public ArrayList<String> getInputLabels()
public abstract double getDistance(int x, int y)
public int[] getNNearest(int x, int num)
public double[] getDistances(int x)
getDistance(int, int)
,
sub-classes might provide an optimised implementation.
public int numVectors()
public double[] getDistancesFlat()
numVectors * (numVectors - * 1) / 2
.getDistance(int, int)
method. Specific subclasses might provide better performing implementations, as
e.g. LeightWeightMemoryInputVectorDistanceMatrix
.
public cern.colt.matrix.impl.DenseDoubleMatrix1D getDistancesFlatAsMatrix()
public String toString()
toString
in class Object
public boolean equals(Object obj)
equals
in class Object
public static InputVectorDistanceMatrix initFromFile(String fileName) throws IOException, SOMToolboxException
InputVectorDistanceMatrix
from the given file. Depending on the
filename, returns either a RandomAccessFileInputVectorDistanceMatrix
(if the filename ends with '.bin')
or a LeightWeightMemoryInputVectorDistanceMatrix
(all other cases).
IOException
SOMToolboxException
protected int flatArraySize()
public int rows()
public int columns()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |