class MinHashLSH extends BaseLSH {

    @Override
    public DenseVector hashFunction(Vector vec) {
        double[] minHashSet = new double[randCoefficientsA.length];
        if (randCoefficientsA.length > 0) {
            int[] hashValues = new int[randCoefficientsA[0].length];
            if (vec instanceof SparseVector) {
                SparseVector elem = (SparseVector)vec;
                int[] indices = elem.getIndices();
                for (int i = 0; i < minHashSet.length; i++) {
                    for (int j = 0; j < hashValues.length; j++) {
                        int tmp = HASH_PRIME, cur;
                        for (int index : indices) {
                            cur = (int)((1L + index) * randCoefficientsA[i][j] + randCoefficientsB[i][j])
                                % HASH_PRIME;
                            tmp = Math.min(tmp, cur);
                        }
                        hashValues[j] = tmp;
                    }
                    minHashSet[i] = tableHash(hashValues);
                }
            } else if (vec instanceof DenseVector) {
                double[] elem = ((DenseVector)vec).getData();
                for (int i = 0; i < minHashSet.length; i++) {
                    for (int j = 0; j < hashValues.length; j++) {
                        int tmp = HASH_PRIME, cur;
                        for (int m = 0; m < elem.length; m++) {
                            if (elem[m] != 0) {
                                cur = (int)((1L + m) * randCoefficientsA[i][j] + randCoefficientsB[i][j]) % HASH_PRIME;
                                tmp = Math.min(tmp, cur);
                            }
                        }
                        hashValues[j] = tmp;
                    }
                    minHashSet[i] = tableHash(hashValues);
                }
            }
        }
        return new DenseVector(minHashSet);
    }

    public  MinHashLSH(long seed, int numProjectionsPerTable, int numHashTables);
    public  MinHashLSH(int[][] randCoefficientsA, int[][] randCoefficientsB);

}