Package elki.projection
Class DenseAffinityMatrix
- java.lang.Object
-
- elki.projection.DenseAffinityMatrix
-
- All Implemented Interfaces:
AffinityMatrix
public class DenseAffinityMatrix extends java.lang.Object implements AffinityMatrix
Dense affinity matrix storage. TODO: it is likely faster to store this in a 1-d array when possible.- Since:
- 0.7.5
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ArrayDBIDsidsIndexed objects.(package private) double[][]pijDense storage.
-
Constructor Summary
Constructors Constructor Description DenseAffinityMatrix(double[][] affinities, ArrayDBIDs ids)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleget(int i, int j)Get an entry by absolute position.intiter(int x)Iterator over non-zero features only.intiterAdvance(int x, int iter)Advance the iterator to the next position.DBIDArrayIteriterDBIDs()Array iterator over the stored objects.intiterDim(int x, int iter)Get the dimension an iterator points to.booleaniterValid(int x, int iter)Test the iterator position for validity.doubleiterValue(int x, int iter)Get the value an iterator points to.voidscale(double d)Scale the whole matrix with a constant factor d.intsize()Number of rows.
-
-
-
Field Detail
-
pij
double[][] pij
Dense storage.
-
ids
ArrayDBIDs ids
Indexed objects.
-
-
Constructor Detail
-
DenseAffinityMatrix
public DenseAffinityMatrix(double[][] affinities, ArrayDBIDs ids)Constructor.- Parameters:
affinities- Raw affinity matrixids- Indexed objects
-
-
Method Detail
-
get
public double get(int i, int j)Description copied from interface:AffinityMatrixGet an entry by absolute position. Note: this may be expensive on sparse matrixes.- Specified by:
getin interfaceAffinityMatrix- Parameters:
i- Rowj- Column- Returns:
- Entry
-
scale
public void scale(double d)
Description copied from interface:AffinityMatrixScale the whole matrix with a constant factor d. This is used to add/remove early exaggeration of tSNE.- Specified by:
scalein interfaceAffinityMatrix- Parameters:
d- Scaling factor.
-
size
public int size()
Description copied from interface:AffinityMatrixNumber of rows.- Specified by:
sizein interfaceAffinityMatrix- Returns:
- Size
-
iterDBIDs
public DBIDArrayIter iterDBIDs()
Description copied from interface:AffinityMatrixArray iterator over the stored objects.- Specified by:
iterDBIDsin interfaceAffinityMatrix- Returns:
- DBID iterator
-
iter
public int iter(int x)
Description copied from interface:AffinityMatrixIterator over non-zero features only. Note: depending on the underlying implementation, this may or may not be the dimension. UseAffinityMatrix.iterDim(int, int)to get the actual dimension. In fact, usually this will be the ith non-zero value, assuming an array representation. Think of this number as an iterator. But for efficiency, it has a primitive type, so it does not require garbage collection. With Java 10 value types, we will likely be able to make this both type-safe and highly efficient again. Intended usage:
Important: you need to use the return value of iterAdvance for the next iteration, or you will have an endless loop.for (int iter = v.iter(x); v.iterValid(x, iter); iter = v.iterAdvance(x, iter)) { final int dim = v.iterDim(x, iter); final int val = v.iterValue(x, iter); }- Specified by:
iterin interfaceAffinityMatrix- Parameters:
x- Point to get the neighbors for- Returns:
- Identifier for the first non-zero dimension, not necessarily the dimension!
-
iterAdvance
public int iterAdvance(int x, int iter)Description copied from interface:AffinityMatrixAdvance the iterator to the next position.- Specified by:
iterAdvancein interfaceAffinityMatrixiter- Previous iterator position- Returns:
- Next iterator position
-
iterDim
public int iterDim(int x, int iter)Description copied from interface:AffinityMatrixGet the dimension an iterator points to.- Specified by:
iterDimin interfaceAffinityMatrixiter- Iterator position- Returns:
- Dimension the iterator refers to
-
iterValue
public double iterValue(int x, int iter)Description copied from interface:AffinityMatrixGet the value an iterator points to.- Specified by:
iterValuein interfaceAffinityMatrixiter- Iterator position- Returns:
- Dimension the iterator refers to
-
iterValid
public boolean iterValid(int x, int iter)Description copied from interface:AffinityMatrixTest the iterator position for validity.- Specified by:
iterValidin interfaceAffinityMatrixiter- Iterator position- Returns:
truewhen it refers to a valid position.
-
-