|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.tumba.ngram.svm.Cache
public class Cache
SVM Kernel Cache, implementing a least recently used (LRU) policy. Since the Kernel is fully dense and may not be stored in computer memory, elements of the Kernel matrix are calculated as needed. The cache simply stores the more recently used elements, reducing the computational cost of later iterations.
Since final iterations usually need few columns of the kernel matrix, most evaluations can be avoided at the end.
Nested Class Summary | |
---|---|
private class |
Cache.CacheNode
Inner class representing a Cache node. |
Field Summary | |
---|---|
private int |
l
The number of total data items. |
private Cache.CacheNode |
lru_head
The first node in the LRU cache. |
private Cache.CacheNode[] |
nodes
The Nodes in the cache. |
private int |
size
The cache size limit in bytes. |
Constructor Summary | |
---|---|
Cache(int l,
int size)
Constructor for Cache |
Method Summary | |
---|---|
private void |
deleteLRU(Cache.CacheNode h)
Delete a node from the cache. |
(package private) int |
getData(int index,
float[][] data,
int len)
Returns free space in the cache. |
private void |
insertLRU(Cache.CacheNode h)
Insert a node in the cache (at the last position). |
void |
swapIndex(int i,
int j)
Swap two nodes in the cache. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final int l
private int size
private final Cache.CacheNode[] nodes
private Cache.CacheNode lru_head
Constructor Detail |
---|
public Cache(int l, int size)
l
- The number of total data items.size
- The cache size limit in bytes.Method Detail |
---|
private void deleteLRU(Cache.CacheNode h)
h
- The node to delete.private void insertLRU(Cache.CacheNode h)
h
- The node to insert.int getData(int index, float[][] data, int len)
index
- The least recently used index at the cache.data
- The data to store in the Cache.len
- maximum length of the data to store in the Cache.
public void swapIndex(int i, int j)
i
- Position in the List for the first node.j
- Position in the List for the second node.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |