@Override public int[] assign(float[][] data) { int [] argmins = new int [data.length]; float [] mins = new float [data.length]; nn.searchNN(data, argmins, mins); return argmins; }
@Override public void assignDistance(float[][] data, int[] indices, float[] distances) { nn.searchNN(data, indices, distances); }
@Override public IntFloatPair assignDistance(float[] data) { int [] index = new int [1]; float [] distance = new float [1]; nn.searchNN(new float[][] { data }, index, distance); return new IntFloatPair(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(float[] data) { final byte[] quantised = new byte[assigners.length]; final int[] idx = { 0 }; final float[] dst = { 0 }; final float[][] qus = new float[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(float[] data) { final byte[] quantised = new byte[assigners.length]; final int[] idx = { 0 }; final float[] dst = { 0 }; final float[][] qus = new float[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; }