uk.ac.gla.dcs.renaissance.kqpr.sparse
Class SparseVectors
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<T>
uk.ac.gla.dcs.renaissance.kqpr.KernelVectorList<SparseVector>
uk.ac.gla.dcs.renaissance.kqpr.sparse.SparseVectors
- All Implemented Interfaces:
- Iterable<SparseVector>, Collection<SparseVector>, List<SparseVector>
public class SparseVectors
- extends KernelVectorList<SparseVector>
This is used for a simple kernel, where vectors are sparse. This class
optimises the computation of the inner product with a new vector
- Author:
- B. Piwowarski
Methods inherited from class java.util.AbstractList |
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList |
SparseVectors
public SparseVectors()
add
public boolean add(SparseVector e)
- Specified by:
add
in interface Collection<SparseVector>
- Specified by:
add
in interface List<SparseVector>
- Overrides:
add
in class AbstractList<SparseVector>
get
public SparseVector get(int index)
- Specified by:
get
in interface List<SparseVector>
- Specified by:
get
in class AbstractList<SparseVector>
size
public int size()
- Specified by:
size
in interface Collection<SparseVector>
- Specified by:
size
in interface List<SparseVector>
- Specified by:
size
in class AbstractCollection<SparseVector>
computeInnerProduct
public double computeInnerProduct(int i,
SparseVector vector)
- Index from an id to a list of values from the vectors
- Specified by:
computeInnerProduct
in class KernelVectorList<SparseVector>
- Parameters:
i
- The index of the vector in the listvector
- The vector provided
- Returns:
- The inner product between both vectors
computeInnerProducts
public double[] computeInnerProducts(SparseVector vector)
- Description copied from class:
KernelVectorList
- Compute the inner products with each of the vectors. This method might be
re-implemented for efficiency reason, and by default calls iteratively
#computeInnerProduct(int, Object).
- Overrides:
computeInnerProducts
in class KernelVectorList<SparseVector>
- Parameters:
vector
- The vector with which the inner product is computed each time
- Returns:
- A series of inner products, one for each of the base vectors
canLinearlyCombine
public boolean canLinearlyCombine()
- Description copied from class:
KernelVectorList
- Returns true if the vectors can be linearly combined
- Overrides:
canLinearlyCombine
in class KernelVectorList<SparseVector>
Copyright © 2011. All Rights Reserved.