#include #include #include /////////////////////////////////////////////////////////////////////////////// int main () { cruft::TAP::logger tap; // create one point and check it 'converges' to this one point { const std::array p { {{1,2,3}} }; std::array q; cruft::kmeans (cruft::view{p}, cruft::view{q}); // clang#19-rc2: ICE when instantiating p == q // // clang++-19: clang/include/clang/AST/DeclTemplate.h:1938: // void clang::ClassTemplateSpecializationDecl::setPointOfInstantiation(clang::SourceLocation): // Assertion `Loc.isValid() && "point of instantiation must be valid!"' failed. // // So just compare the items directly. static_assert (p.size () == q.size ()); tap.expect_eq (p[0], q[0], "single point, single k"); } // create two vectors, check if the mean converges to their average { const std::array p {{ {1}, {2} }}; std::array q; cruft::kmeans (cruft::view{p}, cruft::view{q}); tap.expect_eq (q[0], (p[0]+p[1])/2, "two point, single k"); } return tap.status (); }