at.tuwien.ifs.somtoolbox.data.distance
Class RandomAccessFileInputVectorDistanceMatrix
java.lang.Object
at.tuwien.ifs.somtoolbox.data.distance.InputVectorDistanceMatrix
at.tuwien.ifs.somtoolbox.data.distance.RandomAccessFileInputVectorDistanceMatrix
public class RandomAccessFileInputVectorDistanceMatrix
- extends InputVectorDistanceMatrix
A distance matrix based on a binary RandomAccessFile
. This implementation does not read the matrix into the
memory, and is thus suited especially for big datasets.
The file is built as follows:
- One integer value, giving the number of vectors
- A series of double values representing the upper-right half of the symmetric distance matrix, not containing the
values in the diagonal itself (as they are all 0).
Thus, there are (n-1)! double values, and the matrix file contains the following (x, y) tuples:
[(2,1) (3,1) (4,1) (5,1) (6,1)]
[ (3,2) (4,2) (5,1) (6,2)]
[ (4,3) (5,3) (6,3)]
[ (5,4) (6,4)]
[ (6,5)]
[ ]
- The name of the metric used, as String (until the end of the file).
- Version:
- $Id: RandomAccessFileInputVectorDistanceMatrix.java 3706 2010-07-20 11:07:54Z mayer $
- Author:
- Rudolf Mayer
Method Summary |
double |
getDistance(int x,
int y)
Return the distance between input vectors x and y. |
DistanceMetric |
getMetric()
|
protected static long |
getOffset(long x,
long y,
long numVectors)
Find the offset of a specific value in the linear order |
Methods inherited from class at.tuwien.ifs.somtoolbox.data.distance.InputVectorDistanceMatrix |
columns, equals, flatArraySize, getDistances, getDistancesFlat, getDistancesFlatAsMatrix, getInputLabels, getNNearest, initFromFile, numVectors, rows, toString |
BYTES_HEADER
public static final int BYTES_HEADER
- See Also:
- Constant Field Values
BYTES_CHAR
private static final int BYTES_CHAR
- See Also:
- Constant Field Values
BYTES_DOUBLE
private static final int BYTES_DOUBLE
- See Also:
- Constant Field Values
file
private RandomAccessFile file
RandomAccessFileInputVectorDistanceMatrix
public RandomAccessFileInputVectorDistanceMatrix(String fileName)
throws IOException,
SOMToolboxException
- Throws:
IOException
SOMToolboxException
getMetric
public DistanceMetric getMetric()
- Overrides:
getMetric
in class InputVectorDistanceMatrix
getDistance
public double getDistance(int x,
int y)
- Description copied from class:
InputVectorDistanceMatrix
- Return the distance between input vectors x and y.
- Specified by:
getDistance
in class InputVectorDistanceMatrix
getOffset
protected static long getOffset(long x,
long y,
long numVectors)
- Find the offset of a specific value in the linear order