public class LeightWeightMemoryInputVectorDistanceMatrix extends AbstractMemoryInputVectorDistanceMatrix
AbstractMemoryInputVectorDistanceMatrix using a one-dimensional double array (i.e.
double[]).RandomAccessFileInputVectorDistanceMatrix, the storage is sparse, not containing the diagonal and
the lower half, i.e. as follows:
[(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)] [ ]Thus, there are (n-1)! double values. If this is still too much memory consumption, consider using
RandomAccessFileInputVectorDistanceMatrix instead.FullMemoryInputVectorDistanceMatrix, the memory consumption is lower, and
getDistancesFlat() is very fast, while getDistances(int) needs to be constructed on the fly.| Modifier and Type | Field and Description |
|---|---|
(package private) double[] |
distances |
FILE_TYPEinputLabels, metric, numVectors| Constructor and Description |
|---|
LeightWeightMemoryInputVectorDistanceMatrix(InputData data,
DistanceMetric metric) |
LeightWeightMemoryInputVectorDistanceMatrix(java.lang.String fileName) |
| Modifier and Type | Method and Description |
|---|---|
double |
getDistance(int x,
int y)
Finds the index in vector for the matrix position (x,y); see
distances |
double[] |
getDistances(int x)
This implementation is not of good performance, as the matrix row is always constructed on the fly.
|
double[] |
getDistancesFlat()
This implementation is of high performance, as it returns only the already internally constructed array.
|
protected int |
getMatrixIndex(int x,
int y) |
protected void |
initStorage() |
protected void |
setValue(int x,
int y,
double value) |
java.lang.String |
toString() |
columns, equals, flatArraySize, getDistancesFlatAsMatrix, getInputLabels, getMetric, getNNearest, initFromFile, numVectors, rowspublic LeightWeightMemoryInputVectorDistanceMatrix(InputData data, DistanceMetric metric) throws MetricException
MetricExceptionpublic LeightWeightMemoryInputVectorDistanceMatrix(java.lang.String fileName)
throws java.io.IOException,
SOMToolboxException
java.io.IOExceptionSOMToolboxExceptionprotected void setValue(int x,
int y,
double value)
setValue in class AbstractMemoryInputVectorDistanceMatrixprotected void initStorage()
initStorage in class AbstractMemoryInputVectorDistanceMatrixpublic double getDistance(int x,
int y)
distancesgetDistance in class InputVectorDistanceMatrixprotected int getMatrixIndex(int x,
int y)
public double[] getDistances(int x)
FullMemoryInputVectorDistanceMatrix insteadgetDistances in class InputVectorDistanceMatrixpublic double[] getDistancesFlat()
getDistancesFlat in class InputVectorDistanceMatrixInputVectorDistanceMatrix.getDistancesFlat()public java.lang.String toString()
toString in class InputVectorDistanceMatrix