public class SparseIntegerVector extends Object implements Serializable
Constructor and Description |
---|
SparseIntegerVector()
Sparse vector of int, implemented using two arrays.
|
SparseIntegerVector(HashMap<Integer,Integer> hashmap)
Sparse vector of int, implemented using two arrays.
|
SparseIntegerVector(int size)
Sparse vector of int, implemented using two arrays.
|
SparseIntegerVector(int[] array)
Sparse vector of int, implemented using two arrays.
|
Modifier and Type | Method and Description |
---|---|
double |
cosineSimilarity(SparseIntegerVector other)
Compute and return the cosine similarity (cosine of angle between both
vectors).
|
double |
dotProduct(double[] other)
Compute and return the dot product.
|
double |
dotProduct(SparseIntegerVector other)
Compute and return the dot product.
|
int |
getKey(int i)
Get the key at position i.
|
int |
getValue(int i)
Get the value of position i.
|
int |
intersection(SparseIntegerVector other)
Compute the number of values that are present in both vectors (used to
compute jaccard index).
|
double |
jaccard(SparseIntegerVector other)
Computes and return the Jaccard index with other SparseVector.
|
double |
norm()
Compute and return the L2 norm of the vector.
|
double |
qgram(SparseIntegerVector other)
Compute and return the qgram similarity with other vector.
|
int |
size()
Return the number of (non-zero) elements in this vector.
|
String |
toString() |
int |
union(SparseIntegerVector other)
Compute the size of the union of these two vectors.
|
public SparseIntegerVector(int size)
size
- number of non zero elements in the vectorpublic SparseIntegerVector()
public SparseIntegerVector(HashMap<Integer,Integer> hashmap)
hashmap
- public SparseIntegerVector(int[] array)
array
- public final double cosineSimilarity(SparseIntegerVector other)
other
- public final double dotProduct(SparseIntegerVector other)
other
- public final double dotProduct(double[] other)
other
- public final double norm()
public final double jaccard(SparseIntegerVector other)
other
- public final int union(SparseIntegerVector other)
other
- public final int intersection(SparseIntegerVector other)
other
- public final double qgram(SparseIntegerVector other)
other
- public final int size()
public final int getKey(int i)
i
- public final int getValue(int i)
i
- Copyright © 2017. All rights reserved.