at.tuwien.ifs.somtoolbox.data.distance
Class LeightWeightMemoryInputVectorDistanceMatrix
java.lang.Object
at.tuwien.ifs.somtoolbox.data.distance.InputVectorDistanceMatrix
at.tuwien.ifs.somtoolbox.data.distance.AbstractMemoryInputVectorDistanceMatrix
at.tuwien.ifs.somtoolbox.data.distance.LeightWeightMemoryInputVectorDistanceMatrix
public class LeightWeightMemoryInputVectorDistanceMatrix
- extends AbstractMemoryInputVectorDistanceMatrix
This class implements an AbstractMemoryInputVectorDistanceMatrix
using a one-dimensional double array (i.e.
double[]).
Similar to 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.
Compared to FullMemoryInputVectorDistanceMatrix
, the memory consumption is lower, and
getDistancesFlat()
is very fast, while getDistances(int)
needs to be constructed on the fly.
- Version:
- $Id: LeightWeightMemoryInputVectorDistanceMatrix.java 3704 2010-07-20 10:42:42Z mayer $
- Author:
- Rudolf Mayer
Field Summary |
(package private) double[] |
distances
|
Method Summary |
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)
|
String |
toString()
|
distances
double[] distances
LeightWeightMemoryInputVectorDistanceMatrix
public LeightWeightMemoryInputVectorDistanceMatrix(InputData data,
DistanceMetric metric)
throws MetricException
- Throws:
MetricException
LeightWeightMemoryInputVectorDistanceMatrix
public LeightWeightMemoryInputVectorDistanceMatrix(String fileName)
throws IOException,
SOMToolboxException
- Throws:
IOException
SOMToolboxException
setValue
protected void setValue(int x,
int y,
double value)
- Specified by:
setValue
in class AbstractMemoryInputVectorDistanceMatrix
initStorage
protected void initStorage()
- Specified by:
initStorage
in class AbstractMemoryInputVectorDistanceMatrix
getDistance
public double getDistance(int x,
int y)
- Finds the index in vector for the matrix position (x,y); see
distances
- Specified by:
getDistance
in class InputVectorDistanceMatrix
getMatrixIndex
protected int getMatrixIndex(int x,
int y)
getDistances
public double[] getDistances(int x)
- This implementation is not of good performance, as the matrix row is always constructed on the fly. If you need
to use this method often, consider using a
FullMemoryInputVectorDistanceMatrix
instead
- Overrides:
getDistances
in class InputVectorDistanceMatrix
getDistancesFlat
public double[] getDistancesFlat()
- This implementation is of high performance, as it returns only the already internally constructed array.
- Overrides:
getDistancesFlat
in class InputVectorDistanceMatrix
- See Also:
InputVectorDistanceMatrix.getDistancesFlat()
toString
public String toString()
- Overrides:
toString
in class InputVectorDistanceMatrix