diff --git a/tests/test_utils.hpp b/tests/test_utils.hpp index e366bef..4447d65 100644 --- a/tests/test_utils.hpp +++ b/tests/test_utils.hpp @@ -9,12 +9,15 @@ const size_t N = 1e7; +void init_x(std::vector &x) { + for (size_t i = 0; i < x.size(); ++i) { + x[i] = (i % 360) * 0.0174533f; // degrees to radians + } +} + 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; - } + init_x(x); ReferenceBackend ref; Backend backend; @@ -30,10 +33,7 @@ template inline void test_sinf(float 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; - } + init_x(x); ReferenceBackend ref; Backend backend; @@ -49,10 +49,7 @@ template inline void test_cosf(float 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; - } + init_x(x); ReferenceBackend ref; Backend backend;