class library: Spawner - don't access PriorityQueue-array
[supercollider.git] / testsuite / supernova / approximation_test.cpp
blobd29ac1d8cd93cc571bfeb8454e9e6600d35ffd4f
1 #include <iostream>
2 #include <boost/test/unit_test.hpp>
3 #include <boost/test/floating_point_comparison.hpp>
5 #include <cmath>
7 #include "utilities/fast_approximations.hpp"
9 using namespace nova;
10 using namespace std;
12 namespace
15 template <typename F>
16 void run_fast_atan2_tests(void)
18 for (F y = -4; y < 4; y+=0.01)
19 for (F x = -4; x < 4; x+=0.01)
21 if (abs(x) < 1e-8)
22 continue;
24 F accurate = atan2(y, x);
25 F fast = fast_atan2(y, x);
26 F faster = faster_atan2(y, x);
28 BOOST_CHECK_SMALL( accurate - fast, F(0.011) );
29 BOOST_CHECK_SMALL( accurate - faster, F(0.072) );
35 BOOST_AUTO_TEST_CASE( atan2_tests_float )
37 run_fast_atan2_tests<float>();
40 BOOST_AUTO_TEST_CASE( atan2_tests_double )
42 run_fast_atan2_tests<double>();