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) ArrayDBIDs
ids
Indexed objects.(package private) double[][]
pij
Dense 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 double
get(int i, int j)
Get an entry by absolute position.int
iter(int x)
Iterator over non-zero features only.int
iterAdvance(int x, int iter)
Advance the iterator to the next position.DBIDArrayIter
iterDBIDs()
Array iterator over the stored objects.int
iterDim(int x, int iter)
Get the dimension an iterator points to.boolean
iterValid(int x, int iter)
Test the iterator position for validity.double
iterValue(int x, int iter)
Get the value an iterator points to.void
scale(double d)
Scale the whole matrix with a constant factor d.int
size()
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:AffinityMatrix
Get an entry by absolute position. Note: this may be expensive on sparse matrixes.- Specified by:
get
in interfaceAffinityMatrix
- Parameters:
i
- Rowj
- Column- Returns:
- Entry
-
scale
public void scale(double d)
Description copied from interface:AffinityMatrix
Scale the whole matrix with a constant factor d. This is used to add/remove early exaggeration of tSNE.- Specified by:
scale
in interfaceAffinityMatrix
- Parameters:
d
- Scaling factor.
-
size
public int size()
Description copied from interface:AffinityMatrix
Number of rows.- Specified by:
size
in interfaceAffinityMatrix
- Returns:
- Size
-
iterDBIDs
public DBIDArrayIter iterDBIDs()
Description copied from interface:AffinityMatrix
Array iterator over the stored objects.- Specified by:
iterDBIDs
in interfaceAffinityMatrix
- Returns:
- DBID iterator
-
iter
public int iter(int x)
Description copied from interface:AffinityMatrix
Iterator 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: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:
iter
in 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:AffinityMatrix
Advance the iterator to the next position.- Specified by:
iterAdvance
in interfaceAffinityMatrix
iter
- Previous iterator position- Returns:
- Next iterator position
-
iterDim
public int iterDim(int x, int iter)
Description copied from interface:AffinityMatrix
Get the dimension an iterator points to.- Specified by:
iterDim
in interfaceAffinityMatrix
iter
- Iterator position- Returns:
- Dimension the iterator refers to
-
iterValue
public double iterValue(int x, int iter)
Description copied from interface:AffinityMatrix
Get the value an iterator points to.- Specified by:
iterValue
in interfaceAffinityMatrix
iter
- Iterator position- Returns:
- Dimension the iterator refers to
-
iterValid
public boolean iterValid(int x, int iter)
Description copied from interface:AffinityMatrix
Test the iterator position for validity.- Specified by:
iterValid
in interfaceAffinityMatrix
iter
- Iterator position- Returns:
true
when it refers to a valid position.
-
-