Beispiel #1
0
void testVpTree2()
{
    VpTree<Point<int>, int, EuclideanDistance<Point<int> >::DistanceIncremental> tree;
    int N = 1500000;
    for(int i = 0; i < N; ++i)
    {
        tree.insert(Point<int>(GlobalRNG.next(), GlobalRNG.next()), i);
    }
    int M = 15000;
    for(int i = 0; i < M; ++i)
    {
        assert(tree.nearestNeighbor(Point<int>(GlobalRNG.next(), GlobalRNG.next())));
        int k = 100;
        assert(tree.kNN(Point<int>(GlobalRNG.next(), GlobalRNG.next()), k).getSize() == k);
    }
}
Beispiel #2
0
void testVpTree()
{
    VpTree<Point<int>,int, EuclideanDistance<Point<int> >::DistanceIncremental> tree;
    int N = 5;
    for(int i = 0; i < N; ++i)
    {
        tree.insert(Point<int>(i, i), i);
    }
    for(int i = 0; i < N; ++i)
    {
        int* result = tree.find(Point<int>(i, i));
        if(result) DEBUG(*result);
        assert(result && *result == i);
    }

    Vector<VpTree<Point<int>,int, EuclideanDistance<Point<int> >::DistanceIncremental>::NodeType*> result2 = tree.distanceQuery(Point<int>(0, 4), sqrt(10));

    for(int i = 0; i < result2.getSize(); ++i)
    {
        DEBUG(result2[i]->key[0]);
        DEBUG(result2[i]->key[1]);
    }

}