public final class Vectors extends Object
Modifier and Type | Method and Description |
---|---|
static Iterable<org.apache.commons.lang3.tuple.Pair<VectorEntry,VectorEntry>> |
fastIntersect(SparseVector v1,
SparseVector v2)
Iterate over the intersection of two vectors without the overhead of object creation.
|
static MutableSparseVector |
fromArray(IdIndexMapping map,
double[] values)
Create a mutable sparse vector from an array and index mapping.
|
static MutableSparseVector |
fromScoredIds(List<ScoredId> scores) |
static Iterable<org.apache.commons.lang3.tuple.ImmutablePair<VectorEntry,VectorEntry>> |
intersect(SparseVector v1,
SparseVector v2)
Iterate over the intersection of two vectors - they keys they have in common.
|
public static MutableSparseVector fromScoredIds(List<ScoredId> scores)
public static MutableSparseVector fromArray(IdIndexMapping map, double[] values)
map
- The index mapping specifying the keys.values
- The array of values.map
to the values in values
.IllegalArgumentException
- if values
not the same size as map
.public static Iterable<org.apache.commons.lang3.tuple.ImmutablePair<VectorEntry,VectorEntry>> intersect(SparseVector v1, SparseVector v2)
v1
- The first vector.v2
- The second vector.public static Iterable<org.apache.commons.lang3.tuple.Pair<VectorEntry,VectorEntry>> fastIntersect(SparseVector v1, SparseVector v2)
v1
- The first vector.v2
- The second vector.intersect(SparseVector, SparseVector)