public class DenseAffinityMatrix extends java.lang.Object implements AffinityMatrix
Modifier and Type | Field and Description |
---|---|
(package private) ArrayDBIDs |
ids
Indexed objects.
|
(package private) double[][] |
pij
Dense storage.
|
Constructor and Description |
---|
DenseAffinityMatrix(double[][] affinities,
ArrayDBIDs ids)
Constructor.
|
Modifier and Type | Method and 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.
|
double[][] pij
ArrayDBIDs ids
public DenseAffinityMatrix(double[][] affinities, ArrayDBIDs ids)
affinities
- Raw affinity matrixids
- Indexed objectspublic double get(int i, int j)
AffinityMatrix
get
in interface AffinityMatrix
i
- Rowj
- Columnpublic void scale(double d)
AffinityMatrix
scale
in interface AffinityMatrix
d
- Scaling factor.public int size()
AffinityMatrix
size
in interface AffinityMatrix
public DBIDArrayIter iterDBIDs()
AffinityMatrix
iterDBIDs
in interface AffinityMatrix
public int iter(int x)
AffinityMatrix
AffinityMatrix.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);
}
Important: you need to use the return value of iterAdvance for the
next iteration, or you will have an endless loop.iter
in interface AffinityMatrix
x
- Point to get the neighbors forpublic int iterAdvance(int x, int iter)
AffinityMatrix
iterAdvance
in interface AffinityMatrix
iter
- Previous iterator positionpublic int iterDim(int x, int iter)
AffinityMatrix
iterDim
in interface AffinityMatrix
iter
- Iterator positionpublic double iterValue(int x, int iter)
AffinityMatrix
iterValue
in interface AffinityMatrix
iter
- Iterator positionpublic boolean iterValid(int x, int iter)
AffinityMatrix
iterValid
in interface AffinityMatrix
iter
- Iterator positiontrue
when it refers to a valid position.Copyright © 2019 ELKI Development Team. License information.