uk.ac.gla.dcs.renaissance.kqpr.sparse
Class SparseVectors

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<T>
          extended by uk.ac.gla.dcs.renaissance.kqpr.KernelVectorList<SparseVector>
              extended by 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

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SparseVectors()
           
 
Method Summary
 boolean add(SparseVector e)
           
 boolean canLinearlyCombine()
          Returns true if the vectors can be linearly combined
 double computeInnerProduct(int i, SparseVector vector)
          Index from an id to a list of values from the vectors
 double[] computeInnerProducts(SparseVector vector)
          Compute the inner products with each of the vectors.
 SparseVector get(int index)
           
 int size()
           
 
Methods inherited from class uk.ac.gla.dcs.renaissance.kqpr.KernelVectorList
computeInnerProducts, linearCombination
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

SparseVectors

public SparseVectors()
Method Detail

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 list
vector - 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.