common
Class DenseVector

java.lang.Object
  extended by common.ImplicitVector
      extended by common.DenseVector

public class DenseVector
extends ImplicitVector

Implementation of ImplicitVector in which the explicit entries form a prefix of the implicit infinite vector. In other words, this is an ordinary vector in which entries beyond the end of the explicitly represented vector are treated as zeroes. Entries between the explicitly set entries that have not been set themselves are also treated as zeroes.


Constructor Summary
DenseVector()
          Creates a new vector with no explicit entries.
DenseVector(int initialCapacity)
          Creates a new vector with no explicit entries, but with memory allocated for the given number of entries.
 
Method Summary
 void add(double value)
          Adds the given value at the next index after the last explicitly set index.
 double get(int i)
          Returns the value at the given index.
 int ithExplicitIndex(int i)
          Returns the ith explicitly represented index in this vector.
 double ithExplicitValue(int i)
          Returns the value at the ith explicitly represented index.
 int numExplicit()
          Returns the number of explicitly represented entries in this vector.
 void set(int i, double value)
          Sets the value at the given index, filling in any gap between this index and the previous highest explicit index with explicit zeroes.
 java.lang.String toString()
           
 
Methods inherited from class common.ImplicitVector
dotProduct, dotProduct, maxExplicitIndex, sampleIndex, sum
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DenseVector

public DenseVector()
Creates a new vector with no explicit entries.


DenseVector

public DenseVector(int initialCapacity)
Creates a new vector with no explicit entries, but with memory allocated for the given number of entries. This just affects memory management.

Method Detail

get

public double get(int i)
Description copied from class: ImplicitVector
Returns the value at the given index. This is zero if no value is explicitly stored for the given index.

Specified by:
get in class ImplicitVector

set

public void set(int i,
                double value)
Sets the value at the given index, filling in any gap between this index and the previous highest explicit index with explicit zeroes. The specified value is stored explicitly even if it is zero.

Specified by:
set in class ImplicitVector

add

public void add(double value)
Adds the given value at the next index after the last explicitly set index.


numExplicit

public int numExplicit()
Description copied from class: ImplicitVector
Returns the number of explicitly represented entries in this vector.

Specified by:
numExplicit in class ImplicitVector

ithExplicitIndex

public int ithExplicitIndex(int i)
Description copied from class: ImplicitVector
Returns the ith explicitly represented index in this vector.

Specified by:
ithExplicitIndex in class ImplicitVector

ithExplicitValue

public double ithExplicitValue(int i)
Description copied from class: ImplicitVector
Returns the value at the ith explicitly represented index.

Specified by:
ithExplicitValue in class ImplicitVector

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object