Exemplo n.º 1
0
 @Test
 public void testMetricBound() {
   System.out.println("metricBound");
   ChebyshevDistance instance = new ChebyshevDistance();
   assertTrue(instance.metricBound() > 0);
   assertTrue(Double.isInfinite(instance.metricBound()));
 }
Exemplo n.º 2
0
 @Test
 public void testMetricProperties() {
   System.out.println("isSymmetric");
   ChebyshevDistance instance = new ChebyshevDistance();
   assertTrue(instance.isSymmetric());
   assertTrue(instance.isSubadditive());
   assertTrue(instance.isIndiscemible());
 }
Exemplo n.º 3
0
  @Test
  public void testDist_Vec_Vec() {
    System.out.println("dist");

    ChebyshevDistance dist = new ChebyshevDistance();

    List<Double> cache = dist.getAccelerationCache(vecs);
    List<Double> cache2 = dist.getAccelerationCache(vecs, ex);
    if (cache != null) {
      assertEquals(cache.size(), cache2.size());
      for (int i = 0; i < cache.size(); i++) assertEquals(cache.get(i), cache2.get(i), 0.0);
      assertTrue(dist.supportsAcceleration());
    } else {
      assertNull(cache2);
      assertFalse(dist.supportsAcceleration());
    }

    try {
      dist.dist(half, new DenseVector(half.length() + 1));
      fail("Distance between vecs should have erred");
    } catch (Exception ex) {

    }

    for (int i = 0; i < vecs.size(); i++)
      for (int j = 0; j < vecs.size(); j++) {
        ChebyshevDistance d = dist.clone();
        assertEquals(expected[i][j], d.dist(vecs.get(i), vecs.get(j)), 1e-12);
        assertEquals(expected[i][j], d.dist(i, j, vecs, cache), 1e-12);
        assertEquals(expected[i][j], d.dist(i, vecs.get(j), vecs, cache), 1e-12);
        assertEquals(
            expected[i][j],
            d.dist(i, vecs.get(j), dist.getQueryInfo(vecs.get(j)), vecs, cache),
            1e-12);
      }
  }