@Test public void testHashFunction() { BucketRandomProjectionLSH lsh = new BucketRandomProjectionLSH(0, 5, 2, 2, 1); Vector vec1 = new DenseVector(new double[]{1, 2, 3, 4, 5}); Assert.assertEquals(new DenseVector(new double[]{-348137008, 1394862530}), lsh.hashFunction(vec1)); Vector vec2 = new SparseVector(5, new int[]{0, 4}, new double[]{1.0, 4.0}); Assert.assertEquals(new DenseVector(new double[]{-802232505, 1759100286}), lsh.hashFunction(vec2)); }
@Override public DenseVector hashFunction(Vector elemVec) { double[] brpSet = new double[randVectors.length]; if (randVectors.length > 0) { int[] hashValues = new int[randVectors[0].length]; for (int i = 0; i < brpSet.length; i++) { for (int j = 0; j < hashValues.length; j++) { double dot = elemVec.dot(randVectors[i][j]); hashValues[j] = (int) Math.floor((dot + randNumber[i][j]) / projectionWidth); } brpSet[i] = tableHash(hashValues); } } return new DenseVector(brpSet); }
BucketRandomProjectionLSH extends BaseLSH { @Override public DenseVector hashFunction(Vector elemVec) { double[] brpSet = new double[randVectors.length]; if (randVectors.length > 0) { int[] hashValues = new int[randVectors[0].length]; for (int i = 0; i < brpSet.length; i++) { for (int j = 0; j < hashValues.length; j++) { double dot = elemVec.dot(randVectors[i][j]); hashValues[j] = (int) Math.floor((dot + randNumber[i][j]) / projectionWidth); } brpSet[i] = tableHash(hashValues); } } return new DenseVector(brpSet); } }
BucketRandomProjectionLSH extends BaseLSH { @Override public DenseVector hashFunction(Vector elemVec) { double[] brpSet = new double[randVectors.length]; if (randVectors.length > 0) { int[] hashValues = new int[randVectors[0].length]; for (int i = 0; i < brpSet.length; i++) { for (int j = 0; j < hashValues.length; j++) { double dot = elemVec.dot(randVectors[i][j]); hashValues[j] = (int) Math.floor((dot + randNumber[i][j]) / projectionWidth); } brpSet[i] = tableHash(hashValues); } } return new DenseVector(brpSet); } BucketRandomProjectionLSH(long seed, int vectorSize, int numProjectionsPerTable, int numHashTables,
                                     double projectionWidth);  BucketRandomProjectionLSH(DenseVector[][] randVectors, double[][] randNumber, double projectionWidth); }
BucketRandomProjectionLSH extends BaseLSH { @Override public DenseVector hashFunction(Vector elemVec) { double[] brpSet = new double[randVectors.length]; if (randVectors.length > 0) { int[] hashValues = new int[randVectors[0].length]; for (int i = 0; i < brpSet.length; i++) { for (int j = 0; j < hashValues.length; j++) { double dot = elemVec.dot(randVectors[i][j]); hashValues[j] = (int) Math.floor((dot + randNumber[i][j]) / projectionWidth); } brpSet[i] = tableHash(hashValues); } } return new DenseVector(brpSet); } BucketRandomProjectionLSH(long seed, int vectorSize, int numProjectionsPerTable, int numHashTables,
                                     double projectionWidth);  BucketRandomProjectionLSH(DenseVector[][] randVectors, double[][] randNumber, double projectionWidth); @Override DenseVector hashFunction(Vector elemVec); }
BucketRandomProjectionLSH extends BaseLSH { @Override public DenseVector hashFunction(Vector elemVec) { double[] brpSet = new double[randVectors.length]; if (randVectors.length > 0) { int[] hashValues = new int[randVectors[0].length]; for (int i = 0; i < brpSet.length; i++) { for (int j = 0; j < hashValues.length; j++) { double dot = elemVec.dot(randVectors[i][j]); hashValues[j] = (int) Math.floor((dot + randNumber[i][j]) / projectionWidth); } brpSet[i] = tableHash(hashValues); } } return new DenseVector(brpSet); } BucketRandomProjectionLSH(long seed, int vectorSize, int numProjectionsPerTable, int numHashTables,
                                     double projectionWidth);  BucketRandomProjectionLSH(DenseVector[][] randVectors, double[][] randNumber, double projectionWidth); @Override DenseVector hashFunction(Vector elemVec);  }