2018-04-18 21:48:24 +10:00
|
|
|
#include "tap.hpp"
|
|
|
|
|
|
|
|
#include "kmeans.hpp"
|
|
|
|
|
2018-05-12 14:28:23 +10:00
|
|
|
#include "point.hpp"
|
2018-04-18 21:48:24 +10:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
int
|
|
|
|
main ()
|
|
|
|
{
|
|
|
|
util::TAP::logger tap;
|
|
|
|
|
|
|
|
// create one point and check it 'converges' to this one point
|
|
|
|
{
|
|
|
|
const std::array<util::point3f,1> p { {{1,2,3}} };
|
|
|
|
std::array<util::point3f,1> q;
|
|
|
|
|
|
|
|
util::kmeans (util::view{p}, util::view{q});
|
|
|
|
tap.expect_eq (p, q, "single point, single k");
|
|
|
|
}
|
|
|
|
|
|
|
|
// create two vectors, check if the mean converges to their average
|
|
|
|
{
|
|
|
|
const std::array<util::vector3f,2> p {{
|
|
|
|
{1}, {2}
|
|
|
|
}};
|
|
|
|
std::array<util::vector3f,1> q;
|
|
|
|
|
|
|
|
util::kmeans (util::view{p}, util::view{q});
|
|
|
|
tap.expect_eq (q[0], (p[0]+p[1])/2, "two point, single k");
|
|
|
|
}
|
|
|
|
|
|
|
|
return tap.status ();
|
|
|
|
}
|