/** * Compare this FV to another with the given method. * * @param h the feature to compare against. * @param method the method to compare with. * @return a score determined by the comparison method. */ public double compare(MultidimensionalIntFV h, IntFVComparison method) { return method.compare(this, h); }
/** * Compare this FV to another with the given method. * * @param h the feature to compare against. * @param method the method to compare with. * @return a score determined by the comparison method. */ public double compare(IntFV h, IntFVComparison method) { return method.compare(this, h); }
@Override public double compare(final int[] h1, final int[] h2) { return -1 * COSINE_SIM.compare(h1, h2); } },
/** * Compare this FV to another with the given method. * * @param h the feature to compare against. * @param method the method to compare with. * @return a score determined by the comparison method. */ public double compare(IntFV h, IntFVComparison method) { return method.compare(this, h); }
/** * Compare this FV to another with the given method. * * @param h the feature to compare against. * @param method the method to compare with. * @return a score determined by the comparison method. */ public double compare(MultidimensionalIntFV h, IntFVComparison method) { return method.compare(this, h); }
@Override public double compare(final int[] h1, final int[] h2) { return -1 * COSINE_SIM.compare(h1, h2); } },
@Override public double compare(int[] o1, int[] o2) { return dst.compare(o1, o2); }
@Override public double compare(IntFV h1, IntFV h2) { return compare(h1.values, h2.values); }
@Override public double compare(IntFV h1, IntFV h2) { return compare(h1.values, h2.values); }
@Override public double compare(int[] o1, int[] o2) { return dst.compare(o1, o2); }
/** * Construct the SDC with the given quantiser, centroids (corresponding to * the quantiser's internal assigners), and data. * * @param pq * the Product Quantiser * @param pqCentroids * the centroids corresponding to the the Product Quantiser's * internal assigners. * @param dataPoints * the data to index */ public IntSDCNearestNeighbours(IntProductQuantiser pq, int[][][] pqCentroids, int[][] dataPoints) { super(pq, dataPoints); this.distances = new int[pq.assigners.length][][]; for (int i = 0; i < pq.assigners.length; i++) { final int[][] centroids = pqCentroids[i]; distances[i] = new int[centroids.length][centroids.length]; for (int j = 0; j < centroids.length; j++) { for (int k = j; k < centroids.length; k++) { distances[i][j][k] = (int) IntFVComparison.SUM_SQUARE.compare(centroids[j], centroids[k]); distances[i][k][j] = distances[i][j][k]; } } } }
@Override public double compare(final int[] h1, final int[] h2) { return Math.acos( COSINE_SIM.compare(h1, h2) ); } },
@Override public double compare(final int[] h1, final int[] h2) { return Math.acos( COSINE_SIM.compare(h1, h2) ); } },
/** * Construct the SDC with the given quantiser, centroids (corresponding to * the quantiser's internal assigners), and data. * * @param pq * the Product Quantiser * @param pqCentroids * the centroids corresponding to the the Product Quantiser's * internal assigners. * @param dataPoints * the data to index */ public IntSDCNearestNeighbours(IntProductQuantiser pq, int[][][] pqCentroids, int[][] dataPoints) { super(pq, dataPoints); this.distances = new int[pq.assigners.length][][]; for (int i = 0; i < pq.assigners.length; i++) { final int[][] centroids = pqCentroids[i]; distances[i] = new int[centroids.length][centroids.length]; for (int j = 0; j < centroids.length; j++) { for (int k = j; k < centroids.length; k++) { distances[i][j][k] = (int) IntFVComparison.SUM_SQUARE.compare(centroids[j], centroids[k]); distances[i][k][j] = distances[i][j][k]; } } } }
/** * Compute the distance between two vectors using the underlying distance * comparison used by this class. * * @param a * the first vector * @param b * the second vector * @return the distance between the two vectors */ public float computeDistance(int[] a, int[] b) { if (distance == null) return (float) IntFVComparison.SUM_SQUARE.compare(a, b); return (float) distance.compare(a, b); }
/** * Compute the distance between two vectors using the underlying distance * comparison used by this class. * * @param a * the first vector * @param b * the second vector * @return the distance between the two vectors */ public float computeDistance(int[] a, int[] b) { if (distance == null) return (float) IntFVComparison.SUM_SQUARE.compare(a, b); return (float) distance.compare(a, b); }