@Override public int[] assign(long[][] data) { int [] argmins = new int [data.length]; double [] mins = new double [data.length]; nn.searchNN(data, argmins, mins); return argmins; }
@Override public void assignDistance(long[][] data, int[] indices, double[] distances) { nn.searchNN(data, indices, distances); }
@Override public IntDoublePair assignDistance(long[] data) { int [] index = new int [1]; double [] distance = new double [1]; nn.searchNN(new long[][] { data }, index, distance); return new IntDoublePair(index[0], distance[0]); }
/** * Quantise the given data using this Product Quantiser. The output is an * array of bytes corresponding to the index of the matching centroid for * each sub-vector (index numbers are offset by -128 so that 256 centroids * indexes can fit in a single byte). * * @param data * the data to quantise * @return the quantised data. */ public byte[] quantise(long[] data) { final byte[] quantised = new byte[assigners.length]; final int[] idx = { 0 }; final double[] dst = { 0 }; final long[][] qus = new long[1][0]; for (int i = 0, from = 0; i < assigners.length; i++) { final int to = assigners[i].numDimensions(); qus[0] = Arrays.copyOfRange(data, from, from + to); assigners[i].searchNN(qus, idx, dst); quantised[i] = (byte) (idx[0] - 128); from += to; } return quantised; }
/** * Quantise the given data using this Product Quantiser. The output is an * array of bytes corresponding to the index of the matching centroid for * each sub-vector (index numbers are offset by -128 so that 256 centroids * indexes can fit in a single byte). * * @param data * the data to quantise * @return the quantised data. */ public byte[] quantise(long[] data) { final byte[] quantised = new byte[assigners.length]; final int[] idx = { 0 }; final double[] dst = { 0 }; final long[][] qus = new long[1][0]; for (int i = 0, from = 0; i < assigners.length; i++) { final int to = assigners[i].numDimensions(); qus[0] = Arrays.copyOfRange(data, from, from + to); assigners[i].searchNN(qus, idx, dst); quantised[i] = (byte) (idx[0] - 128); from += to; } return quantised; }