|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcommon.ImplicitVector
common.SparseVector
public class SparseVector
Simple implementation of a sparse vector, that is, a vector of doubles in which many elements are zero. Only the non-zero elements are stored explicitly. The class uses two arrays: one to hold the non-zero values, and one to hold their indices. The indices (and corresponding values) are kept in sorted order, so accessing an element by index takes time logarithmic in the number of non-zero entries.
Constructor Summary | |
---|---|
SparseVector()
Creates a new vector with no non-zero entries. |
Method Summary | |
---|---|
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. |
static void |
main(java.lang.String[] args)
Test program. |
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. |
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 |
---|
public SparseVector()
Method Detail |
---|
public double get(int i)
ImplicitVector
get
in class ImplicitVector
public void set(int i, double value)
set
in class ImplicitVector
public int numExplicit()
ImplicitVector
numExplicit
in class ImplicitVector
public int ithExplicitIndex(int i)
ImplicitVector
ithExplicitIndex
in class ImplicitVector
public double ithExplicitValue(int i)
ImplicitVector
ithExplicitValue
in class ImplicitVector
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |