Package elki.svm.qmatrix
Class CachedQMatrix
- java.lang.Object
-
- elki.svm.qmatrix.CachedQMatrix
-
-
Field Summary
Fields Modifier and Type Field Description private int[]chainLRU: backward and forward chainingprivate float[][]dataData storageprivate QMatrixinnerWrapped inner matrixprivate int[]lenNumber of valid entries in each bufferprivate intlruLRU headprivate static longMEGABYTESConstant for parameterization in megabytesprivate longsizeRemaining 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 voiddiscard(int h)Discard a cache entry.(package private) float[]get_data(int h, int len)voidget_Q(int column, int len, float[] out)Get a column of the matrix.double[]get_QD()Get the diagonal values, as reference.voidinitialize()Initialize the Q Matrix.private voidlink(int p, int n)Link two objects in the LRU chain.private voidlru_delete(int h)Delete from the LRU list.private voidlru_insert(int h)Insert into the last position of the LRU list.private intnext(int i)Get the next element in the LRU chain.private intprev(int i)Get the previous element in the LRU chain.private voidselflink(int p)Link an element to itself only.doublesimilarity(int i, int j)(Slow) compute the similarity (not distance) of objects i and j.voidswap_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:QMatrixInitialize the Q Matrix.- Specified by:
initializein 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:QMatrixReorganize the data by swapping two entries.This also must modify the QD array!
- Specified by:
swap_indexin interfaceQMatrix- Parameters:
i- First entryj- Second entry
-
get_Q
public void get_Q(int column, int len, float[] out)Description copied from interface:QMatrixGet a column of the matrix.
-
get_QD
public double[] get_QD()
Description copied from interface:QMatrixGet 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:
similarityin interfaceQMatrix- Parameters:
i- First objectj- Second object- Returns:
- Similarity
-
-