MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/CompactNSearch / compute_average_distance

Function compute_average_distance

demo/main.cpp:37–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37Real
38compute_average_distance(NeighborhoodSearch const& nsearch)
39{
40 unsigned long long res = 0;
41 auto const& d = nsearch.point_set(0);
42 unsigned long long count = 0;
43 for (int i = 0; i < d.n_points(); ++i)
44 {
45 std::size_t nn = d.n_neighbors(i);
46 for (int j = 0; j < nn; ++j)
47 {
48 CompactNSearch::PointID const& k = d.neighbor(i, j);
49 res += std::abs(i - static_cast<int>(k.point_id));
50 count++;
51 }
52 }
53 return static_cast<Real>(res) / static_cast<Real>(count);
54}
55
56std::vector<std::vector<unsigned int>>
57brute_force_search()

Callers 1

mainFunction · 0.85

Calls 2

n_pointsMethod · 0.80
n_neighborsMethod · 0.80

Tested by

no test coverage detected