Package elki.svm.qmatrix
Class CachedQMatrix
- java.lang.Object
-
- elki.svm.qmatrix.CachedQMatrix
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
chain
LRU: backward and forward chainingprivate float[][]
data
Data storageprivate QMatrix
inner
Wrapped inner matrixprivate int[]
len
Number of valid entries in each bufferprivate int
lru
LRU headprivate static long
MEGABYTES
Constant for parameterization in megabytesprivate long
size
Remaining memory (in floats)
-
Constructor Summary
Constructors Constructor Description CachedQMatrix(int l, double cache_size, QMatrix inner)
CachedQMatrix(int l, long size_, QMatrix inner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
discard(int h)
Discard a cache entry.(package private) float[]
get_data(int h, int len)
void
get_Q(int column, int len, float[] out)
Get a column of the matrix.double[]
get_QD()
Get the diagonal values, as reference.void
initialize()
Initialize the Q Matrix.private void
link(int p, int n)
Link two objects in the LRU chain.private void
lru_delete(int h)
Delete from the LRU list.private void
lru_insert(int h)
Insert into the last position of the LRU list.private int
next(int i)
Get the next element in the LRU chain.private int
prev(int i)
Get the previous element in the LRU chain.private void
selflink(int p)
Link an element to itself only.double
similarity(int i, int j)
(Slow) compute the similarity (not distance) of objects i and j.void
swap_index(int i, int j)
Reorganize the data by swapping two entries.
-
-
-
Field Detail
-
MEGABYTES
private static final long MEGABYTES
Constant for parameterization in megabytes- See Also:
- Constant Field Values
-
size
private long size
Remaining memory (in floats)
-
inner
private final QMatrix inner
Wrapped inner matrix
-
data
private final float[][] data
Data storage
-
len
private final int[] len
Number of valid entries in each buffer
-
lru
private int lru
LRU head
-
chain
private final int[] chain
LRU: backward and forward chaining
-
-
Method Detail
-
initialize
public void initialize()
Description copied from interface:QMatrix
Initialize the Q Matrix.- Specified by:
initialize
in interfaceQMatrix
-
next
private final int next(int i)
Get the next element in the LRU chain.- Parameters:
i
- Entry- Returns:
- Next
-
prev
private final int prev(int i)
Get the previous element in the LRU chain.- Parameters:
i
- Entry- Returns:
- Prev
-
link
private final void link(int p, int n)
Link two objects in the LRU chain.- Parameters:
p
- Previous objectn
- Next pbject
-
selflink
private final void selflink(int p)
Link an element to itself only.- Parameters:
p
- Element to link
-
lru_insert
private final void lru_insert(int h)
Insert into the last position of the LRU list.- Parameters:
h
- Object to be inserted
-
lru_delete
private final void lru_delete(int h)
Delete from the LRU list.- Parameters:
h
- Object index to be deleted
-
discard
private final void discard(int h)
Discard a cache entry.- Parameters:
h
- entry index
-
get_data
float[] get_data(int h, int len)
-
swap_index
public void swap_index(int i, int j)
Description copied from interface:QMatrix
Reorganize the data by swapping two entries.This also must modify the QD array!
- Specified by:
swap_index
in interfaceQMatrix
- Parameters:
i
- First entryj
- Second entry
-
get_Q
public void get_Q(int column, int len, float[] out)
Description copied from interface:QMatrix
Get a column of the matrix.
-
get_QD
public double[] get_QD()
Description copied from interface:QMatrix
Get the diagonal values, as reference.
-
similarity
public double similarity(int i, int j)
Description copied from interface:QMatrix
(Slow) compute the similarity (not distance) of objects i and j.If you need many, use
QMatrix.get_Q(int, int, float[])
instead.- Specified by:
similarity
in interfaceQMatrix
- Parameters:
i
- First objectj
- Second object- Returns:
- Similarity
-
-