public static <T> CoverTree<T, T> of(T[] data, Metric<T> distance) {
        return new CoverTree<>(data, data, distance);
    }
@Test
    public void testNearest() {
        System.out.println("nearest");

        double[][] data = Matrix.randn(1000, 10).toArray();
        CoverTree<double[], double[]> coverTree = CoverTree.of(data, new EuclideanDistance());
        LinearSearch<double[], double[]> naive = LinearSearch.of(data, new EuclideanDistance());

        for (double[] datum : data) {
            Neighbor n1 = coverTree.nearest(datum);
            Neighbor n2 = naive.nearest(datum);
            assertEquals(n1.index, n2.index);
            assertEquals(n1.value, n2.value);
            assertEquals(n1.distance, n2.distance, 1E-7);
        }
    }