@Override public double compare(final double[] h1, final double[] 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(DoubleFV h, DoubleFVComparison 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(MultidimensionalDoubleFV h, DoubleFVComparison 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(MultidimensionalDoubleFV h, DoubleFVComparison method) { return method.compare(this, h); }
@Override public double compare(final double[] h1, final double[] 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(DoubleFV h, DoubleFVComparison method) { return method.compare(this, h); }
@Override public double compare(double[] o1, double[] o2) { return dst.compare(o1, o2); }
@Override public double compare(DoubleFV h1, DoubleFV h2) { return compare(h1.values, h2.values); }
@Override public double compare(double[] o1, double[] o2) { return dst.compare(o1, o2); }
@Override public double compare(DoubleFV h1, DoubleFV h2) { return compare(h1.values, h2.values); }
@Override public double compare(final double[] h1, final double[] h2) { return Math.acos( COSINE_SIM.compare(h1, h2) ); } },
@Override public double compare(final double[] h1, final double[] 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 DoubleSDCNearestNeighbours(DoubleProductQuantiser pq, double[][][] pqCentroids, double[][] dataPoints) { super(pq, dataPoints); this.distances = new double[pq.assigners.length][][]; for (int i = 0; i < pq.assigners.length; i++) { final double[][] centroids = pqCentroids[i]; distances[i] = new double[centroids.length][centroids.length]; for (int j = 0; j < centroids.length; j++) { for (int k = j; k < centroids.length; k++) { distances[i][j][k] = (double) DoubleFVComparison.SUM_SQUARE.compare(centroids[j], centroids[k]); distances[i][k][j] = distances[i][j][k]; } } } }
/** * 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 DoubleSDCNearestNeighbours(DoubleProductQuantiser pq, double[][][] pqCentroids, double[][] dataPoints) { super(pq, dataPoints); this.distances = new double[pq.assigners.length][][]; for (int i = 0; i < pq.assigners.length; i++) { final double[][] centroids = pqCentroids[i]; distances[i] = new double[centroids.length][centroids.length]; for (int j = 0; j < centroids.length; j++) { for (int k = j; k < centroids.length; k++) { distances[i][j][k] = (double) DoubleFVComparison.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 double computeDistance(double[] a, double[] b) { if (distance == null) return (double) DoubleFVComparison.SUM_SQUARE.compare(a, b); return (double) 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 double computeDistance(double[] a, double[] b) { if (distance == null) return (double) DoubleFVComparison.SUM_SQUARE.compare(a, b); return (double) distance.compare(a, b); }
for (int i = 0; i < feats.length; i++) { for (int j = i; j < feats.length; j++) { double d = dist.compare(feats[i], feats[j]); if (d > eps) d = Double.NaN;
final Histogram ff = h.getFeatureVector(rr); final double c = DoubleFVComparison.EUCLIDEAN.compare(f, ff); data.add(ObjectDoublePair.pair(rr, c));
final Histogram ff = h.getFeatureVector(rr); final double c = DoubleFVComparison.EUCLIDEAN.compare(f, ff); data.add(ObjectDoublePair.pair(rr, c));