Package elki.index.lsh.hashfunctions
Class MultipleProjectionsLocalitySensitiveHashFunction
- java.lang.Object
-
- elki.index.lsh.hashfunctions.MultipleProjectionsLocalitySensitiveHashFunction
-
- All Implemented Interfaces:
LocalitySensitiveHashFunction<NumberVector>
@Reference(authors="M. Datar, N. Immorlica, P. Indyk, V. S. Mirrokni", title="Locality-sensitive hashing scheme based on p-stable distributions", booktitle="Proc. 20th Annual Symposium on Computational Geometry", url="https://doi.org/10.1145/997817.997857", bibkey="DBLP:conf/compgeom/DatarIIM04") public class MultipleProjectionsLocalitySensitiveHashFunction extends java.lang.Object implements LocalitySensitiveHashFunction<NumberVector>
LSH hash function for vector space data. Depending on the choice of random vectors, it can be appropriate for Manhattan and Euclidean distances.Reference:
M. Datar, N. Immorlica, P. Indyk, V. S. Mirrokni
Locality-sensitive hashing scheme based on p-stable distributions
Proc. 20th Annual Symposium on Computational Geometry- Since:
- 0.6.0
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description (package private) double
iwidth
Scaling factor: inverse of width.private static long
MASK32
Bit mask for signed int to unsigned long conversion.(package private) RandomProjectionFamily.Projection
projection
Projection matrix.(package private) int[]
randoms1
Random numbers for mixing the hash codes of the individual functions(package private) double[]
shift
Shift offset.
-
Constructor Summary
Constructors Constructor Description MultipleProjectionsLocalitySensitiveHashFunction(RandomProjectionFamily.Projection projection, double width, java.util.Random rnd)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
fastModPrime(long data)
Fast modulo operation for the largest unsigned integer prime.int
getNumberOfProjections()
Get the number of projections performed.int
hashObject(NumberVector vec)
Compute the hash value of an object.int
hashObject(NumberVector vec, double[] buf)
Compute the hash value of an object (faster version).
-
-
-
Field Detail
-
projection
RandomProjectionFamily.Projection projection
Projection matrix.
-
shift
double[] shift
Shift offset.
-
iwidth
double iwidth
Scaling factor: inverse of width.
-
randoms1
int[] randoms1
Random numbers for mixing the hash codes of the individual functions
-
MASK32
private static final long MASK32
Bit mask for signed int to unsigned long conversion.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MultipleProjectionsLocalitySensitiveHashFunction
public MultipleProjectionsLocalitySensitiveHashFunction(RandomProjectionFamily.Projection projection, double width, java.util.Random rnd)
Constructor.- Parameters:
projection
- Projection vectorswidth
- Width of binsrnd
- Random number generator
-
-
Method Detail
-
hashObject
public int hashObject(NumberVector vec)
Description copied from interface:LocalitySensitiveHashFunction
Compute the hash value of an object.- Specified by:
hashObject
in interfaceLocalitySensitiveHashFunction<NumberVector>
- Parameters:
vec
- Object to hash- Returns:
- Hash value
-
hashObject
public int hashObject(NumberVector vec, double[] buf)
Description copied from interface:LocalitySensitiveHashFunction
Compute the hash value of an object (faster version).- Specified by:
hashObject
in interfaceLocalitySensitiveHashFunction<NumberVector>
- Parameters:
vec
- Object to hashbuf
- Buffer, sized according to the number of projections.- Returns:
- Hash value
-
fastModPrime
public static int fastModPrime(long data)
Fast modulo operation for the largest unsigned integer prime.- Parameters:
data
- Long input- Returns:
data % (2^32 - 5)
.
-
getNumberOfProjections
public int getNumberOfProjections()
Description copied from interface:LocalitySensitiveHashFunction
Get the number of projections performed.- Specified by:
getNumberOfProjections
in interfaceLocalitySensitiveHashFunction<NumberVector>
- Returns:
- Number of projections.
-
-