|
JScience v3.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.context.RealtimeObject
org.jscience.mathematics.vectors.Vector<F>
org.jscience.mathematics.vectors.SparseVector<F>
public final class SparseVector<F extends Field<F>>
This class represents a sparse vector.
Sparse vectors can be created using an index-to-element mapping or
by adding single elements sparse vectors together. For example:
// Creates a sparse vector of dimension 256 but with only 3 non-zero elements.
SparseVector<Float64> V = SparseVector.valueOf(256, Float64.ZERO, 127, Float64.valueOf(0.5));
V = V.plus(SparseVector.valueOf(256, Float64.ZERO, 128, Float64.valueOf(1.0)));
V = V.plus(SparseVector.valueOf(256, Float64.ZERO, 129, Float64.valueOf(2.0)));
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javolution.context.RealtimeObject |
|---|
RealtimeObject.Factory<T extends RealtimeObject> |
| Nested classes/interfaces inherited from interface javolution.context.Realtime |
|---|
Realtime.ObjectSpace |
| Field Summary | |
|---|---|
protected static XMLFormat<SparseVector> |
XML
Holds the default XML representation for sparse vectors. |
| Method Summary | ||
|---|---|---|
F |
get(int i)
Returns a single element from this vector. |
|
int |
getDimension()
Returns the number of elements held by this vector. |
|
F |
getZero()
Returns the value of the non-set elements for this sparse vector. |
|
boolean |
move(Realtime.ObjectSpace os)
|
|
SparseVector<F> |
opposite()
Returns the negation of this vector. |
|
SparseVector<F> |
plus(Vector<F> that)
Returns the sum of this vector with the one specified. |
|
SparseVector<F> |
times(F k)
Returns the product of this vector with the specified coefficient. |
|
F |
times(Vector<F> that)
Returns the dot product of this vector with the one specified. |
|
static
|
valueOf(int dimension,
F zero,
int i,
F element)
Returns a sparse vector having a single element at the specified index. |
|
static
|
valueOf(int dimension,
F zero,
java.util.Map<Index,F> elements)
Returns a sparse vector from the specified index to element mapping. |
|
static
|
valueOf(Vector<F> that,
F zero)
Returns a sparse vector equivalent to the specified vector but with the zero elements removed removed using a default object equality comparator. |
|
static
|
valueOf(Vector<F> that,
F zero,
FastComparator<? super F> comparator)
Returns a sparse vector equivalent to the specified vector but with the zero elements removed using the specified object equality comparator. |
|
| Methods inherited from class org.jscience.mathematics.vectors.Vector |
|---|
cross, equals, equals, hashCode, minus, toText, valueOf, valueOf |
| Methods inherited from class javolution.context.RealtimeObject |
|---|
export, isLocal, moveHeap, preserve, toString, unpreserve |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final XMLFormat<SparseVector> XML
<SparseVector dimension="16">
<Zero class="Complex" real="0.0" imaginary="0.0" />
<Elements>
<Index value="4" />
<Complex real="1.0" imaginary="0.0" />
<Index value="6" />
<Complex real="0.0" imaginary="1.0" />
</Elements>
</SparseVector>
| Method Detail |
|---|
public static <F extends Field<F>> SparseVector<F> valueOf(int dimension,
F zero,
int i,
F element)
dimension - this vector dimension.zero - the element representing zero.i - the index value of this vector single element.element - the element at the specified index.
public static <F extends Field<F>> SparseVector<F> valueOf(int dimension,
F zero,
java.util.Map<Index,F> elements)
dimension - this vector dimension.zero - the element representing zero.elements - the index to element mapping.
public static <F extends Field<F>> SparseVector<F> valueOf(Vector<F> that,
F zero)
that - the vector to convert.zero - the zero element for the sparse vector to return.
SparseVector.valueOf(that, zero, FastComparator.DEFAULT)
public static <F extends Field<F>> SparseVector<F> valueOf(Vector<F> that,
F zero,
FastComparator<? super F> comparator)
that - the vector to convert.zero - the zero element for the sparse vector to return.comparator - the comparator used to determinate zero equality.
public F getZero()
public int getDimension()
Vector
getDimension in class Vector<F extends Field<F>>public F get(int i)
Vector
get in class Vector<F extends Field<F>>i - the element index (range [0..n[).
i.public SparseVector<F> opposite()
Vector
opposite in interface GroupAdditive<Vector<F extends Field<F>>>opposite in class Vector<F extends Field<F>>-this.public SparseVector<F> plus(Vector<F> that)
Vector
plus in interface GroupAdditive<Vector<F extends Field<F>>>plus in class Vector<F extends Field<F>>that - the vector to be added.
this + that.public SparseVector<F> times(F k)
Vector
times in interface VectorSpace<Vector<F extends Field<F>>,F extends Field<F>>times in class Vector<F extends Field<F>>k - the coefficient multiplier.
this · kpublic F times(Vector<F> that)
Vector
times in class Vector<F extends Field<F>>that - the vector multiplier.
this · thatpublic boolean move(Realtime.ObjectSpace os)
move in interface Realtimemove in class RealtimeObject
|
JScience v3.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||