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_TYPE
inputLabels, 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, rows
public LeightWeightMemoryInputVectorDistanceMatrix(InputData data, DistanceMetric metric) throws MetricException
MetricException
public LeightWeightMemoryInputVectorDistanceMatrix(java.lang.String fileName) throws java.io.IOException, SOMToolboxException
java.io.IOException
SOMToolboxException
protected void setValue(int x, int y, double value)
setValue
in class AbstractMemoryInputVectorDistanceMatrix
protected void initStorage()
initStorage
in class AbstractMemoryInputVectorDistanceMatrix
public double getDistance(int x, int y)
distances
getDistance
in class InputVectorDistanceMatrix
protected int getMatrixIndex(int x, int y)
public double[] getDistances(int x)
FullMemoryInputVectorDistanceMatrix
insteadgetDistances
in class InputVectorDistanceMatrix
public double[] getDistancesFlat()
getDistancesFlat
in class InputVectorDistanceMatrix
InputVectorDistanceMatrix.getDistancesFlat()
public java.lang.String toString()
toString
in class InputVectorDistanceMatrix