Package it.unimi.dsi.law.vector
Class Int2DoubleMapVector
java.lang.Object
it.unimi.dsi.law.vector.Vector
it.unimi.dsi.law.vector.Int2DoubleMapVector
- All Implemented Interfaces:
Serializable
public class Int2DoubleMapVector extends Vector
A mutable implementation of
Vector
for sparse vectors.
It is possible to create sparse vector by iteratively adding values. This implementation uses the supertype method for every operation.
It should be converted with toImmutableSparseVector()
before being actually used.- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class it.unimi.dsi.law.vector.Vector
ell1norm, ell2norm, id, INVALID_ID, INVALID_NORM, size
-
Method Summary
Modifier and Type Method Description double
get(int idx)
Gets the value at index idx.static Int2DoubleMapVector
getInstance(int size, int id)
Returns an instance of given size with zero values.static Int2DoubleMapVector
getInstance(int size, Int2DoubleMap value, int id)
Returns an instance from the givenInt2DoubleMap
.void
set(int idx, double val)
Sets the value val at index idx.ImmutableSparseVector
toImmutableSparseVector()
Methods inherited from class it.unimi.dsi.law.vector.Vector
add, dotProduct, ell1Norm, ell2Norm, euclideanDistance, isMutable, scale, zero
-
Method Details
-
getInstance
Returns an instance of given size with zero values.- Parameters:
size
- the size.id
- the id of description of this vector.- Returns:
- a vector
-
getInstance
Returns an instance from the givenInt2DoubleMap
.- Parameters:
size
- the size.value
- a map of values.id
- the id of description of this vector.- Returns:
- a vector.
-
set
public void set(int idx, double val)Description copied from class:Vector
Sets the value val at index idx. -
get
public double get(int idx)Description copied from class:Vector
Gets the value at index idx. -
toImmutableSparseVector
-