#pragma once #include #include #include #include #include const size_t N = 1e7; template inline void test_sinf(float tol) { std::vector x(N), s_ref(N), s(N); for (size_t i = 0; i < N; ++i) { x[i] = float(i) * 0.01f; } ReferenceBackend ref; Backend backend; backend.init(); ref.compute_sinf(N, x.data(), s_ref.data()); backend.compute_sinf(N, x.data(), s.data()); for (size_t i = 0; i < N; ++i) { REQUIRE_THAT(s[i], Catch::Matchers::WithinAbs(s_ref[i], tol)); } } template inline void test_cosf(float tol) { std::vector x(N), c_ref(N), c(N); for (size_t i = 0; i < N; ++i) { x[i] = float(i) * 0.01f; } ReferenceBackend ref; Backend backend; backend.init(); ref.compute_cosf(N, x.data(), c_ref.data()); backend.compute_cosf(N, x.data(), c.data()); for (size_t i = 0; i < N; ++i) { REQUIRE_THAT(c[i], Catch::Matchers::WithinAbs(c_ref[i], tol)); } } template inline void test_sincosf(float tol) { std::vector x(N), s_ref(N), c_ref(N), s(N), c(N); for (size_t i = 0; i < N; ++i) { x[i] = float(i) * 0.01f; } ReferenceBackend ref; Backend backend; backend.init(); ref.compute_sincosf(N, x.data(), s_ref.data(), c_ref.data()); backend.compute_sincosf(N, x.data(), s.data(), c.data()); for (size_t i = 0; i < N; ++i) { REQUIRE_THAT(s[i], Catch::Matchers::WithinAbs(s_ref[i], tol)); REQUIRE_THAT(c[i], Catch::Matchers::WithinAbs(c_ref[i], tol)); } }