@Immutable public final class ImmutableSparseVector extends SparseVector implements Serializable
Compatibility: Public
Modifier | Constructor and Description |
---|---|
|
ImmutableSparseVector()
Create a new, empty immutable sparse vector.
|
protected |
ImmutableSparseVector(long[] ks,
double[] vs)
Construct a new vector from existing arrays.
|
protected |
ImmutableSparseVector(long[] ks,
double[] vs,
int sz)
Construct a new sparse vector from pre-existing arrays.
|
|
ImmutableSparseVector(Long2DoubleMap ratings)
Create a new immutable sparse vector from a map of ratings.
|
Modifier and Type | Method and Description |
---|---|
ImmutableSparseVector |
channel(Symbol channelSymbol)
Fetch the channel stored under a particular symbol.
|
<K> org.grouplens.lenskit.vectors.ImmutableTypedSideChannel<K> |
channel(TypedSymbol<K> channelSymbol)
Fetch the channel stored under a particular typed symbol.
|
Set<Symbol> |
getChannels()
Retrieve all symbols that map to side channels for this vector.
|
Set<TypedSymbol<?>> |
getTypedChannels()
Retrieve all symbols that map to typed side channels for this vector.
|
boolean |
hasChannel(Symbol channelSymbol)
Return whether this sparse vector has a channel stored under a
particular symbol.
|
boolean |
hasChannel(TypedSymbol<?> channelSymbol)
Return whether this sparse vector has a typed channel stored under a
particular typed symbol.
|
ImmutableSparseVector |
immutable()
Return an immutable snapshot of this sparse vector.
|
double |
mean()
Compute and return the mean of the vector's values.
|
MutableSparseVector |
mutableCopy()
Return a mutable copy of this sparse vector.
|
double |
norm()
Compute and return the L2 norm (Euclidian length) of the vector.
|
double |
sum()
Compute and return the L1 norm (sum) of the vector.
|
containsKey, countCommonKeys, dot, equals, fast, fast, fastIterator, fastIterator, fastPointer, fastPointer, findIndex, get, get, get, hashCode, isEmpty, iterator, keyDomain, keysByValue, keysByValue, keySet, pointer, pointer, size, toString, values
public ImmutableSparseVector()
public ImmutableSparseVector(Long2DoubleMap ratings)
ratings
- The ratings to make a vector from. Its key set is used as
the vector's key domain.protected ImmutableSparseVector(long[] ks, double[] vs)
ks
- The array of keys backing this vector. They must be sorted.vs
- The array of values backing this vector.protected ImmutableSparseVector(long[] ks, double[] vs, int sz)
ks
- The key array (will be the key domain).vs
- The value array.sz
- The length to actually use.public ImmutableSparseVector immutable()
SparseVector
SparseVector.keySet()
of this vector.immutable
in class SparseVector
public MutableSparseVector mutableCopy()
SparseVector
mutableCopy
in class SparseVector
public boolean hasChannel(Symbol channelSymbol)
SparseVector
hasChannel
in class SparseVector
channelSymbol
- the symbol under which the channel was
stored in the vector.public boolean hasChannel(TypedSymbol<?> channelSymbol)
SparseVector
hasChannel
in class SparseVector
channelSymbol
- the typed symbol under which the channel was
stored in the vector.public ImmutableSparseVector channel(Symbol channelSymbol)
SparseVector
channel
in class SparseVector
channelSymbol
- the symbol under which the channel was/is
stored in the vector.public <K> org.grouplens.lenskit.vectors.ImmutableTypedSideChannel<K> channel(TypedSymbol<K> channelSymbol)
SparseVector
channel
in class SparseVector
channelSymbol
- the typed symbol under which the channel was/is
stored in the vector.public Set<Symbol> getChannels()
SparseVector
getChannels
in class SparseVector
public Set<TypedSymbol<?>> getTypedChannels()
SparseVector
getTypedChannels
in class SparseVector
public double norm()
SparseVector
norm
in class SparseVector
public double sum()
SparseVector
sum
in class SparseVector
public double mean()
SparseVector
mean
in class SparseVector
Copyright © 2013 GroupLens Research. All Rights Reserved.