MCPcopy Create free account
hub / github.com/davisking/dlib / test_cyl_bessel_j

Function test_cyl_bessel_j

dlib/test/math.cpp:62–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60
61 template<typename R>
62 void test_cyl_bessel_j()
63 {
64 constexpr R tol = std::is_same<R,float>::value ? 1e-3 : 1e-7;
65
66 // check case when nu=0
67 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,0.0f) - 1.000000000000000) < tol);
68 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,1e-5) - 0.999999999975000000000156249999999565972) < tol);
69 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,0.1f) - 0.99750156206604012610) < tol);
70 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,0.2f) - 0.990024972239576) < tol);
71 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,0.5f) - 0.938469807240813) < tol);
72 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,1.0f) - 0.7651976865579665514497175261026632209093) < tol);
73 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,2.0f) - 0.2238907791412356680518274546499486258252) < tol);
74 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,3.0f) - -0.260051954901934) < tol);
75 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,4.0f) - -0.3971498098638473722865907684516980419756) < tol);
76 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,6.0f) - 0.150645257250997) < tol);
77 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.0f,8.0f) - 0.1716508071375539060908694078519720010684) < tol);
78
79 // check case when nu=0.5
80 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.5f,0.0f) - 0.000000000000000) < tol);
81 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.5f,0.1f) - 0.251892940326001) < tol);
82 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.5f,0.2f) - 0.354450744211402) < tol);
83 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.5f,0.5f) - 0.540973789934529) < tol);
84 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.5f,1.0f) - 0.671396707141804) < tol);
85 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.5f,2.0f) - 0.513016136561828) < tol);
86 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.5f,3.0f) - 0.065008182877376) < tol);
87 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.5f,4.0f) - -0.301920513291637) < tol);
88 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.5f,6.0f) - -0.091015409523068) < tol);
89 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (0.5f,8.0f) - 0.279092808570990) < tol);
90
91 // check case when nu=1.7
92 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (1.7f,0.0f) - 0.000000000000000) < tol);
93 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (1.7f,0.1f) - 0.003971976455203) < tol);
94 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (1.7f,0.2f) - 0.012869169735073) < tol);
95 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (1.7f,0.5f) - 0.059920175825578) < tol);
96 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (1.7f,1.0f) - 0.181417665056645) < tol);
97 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (1.7f,2.0f) - 0.437811462130677) < tol);
98 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (1.7f,3.0f) - 0.494432522734784) < tol);
99 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (1.7f,4.0f) - 0.268439400467270) < tol);
100 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (1.7f,6.0f) - -0.308175744215833) < tol);
101 DLIB_TEST(std::abs(dlib::cyl_bessel_j<R,R> (1.7f,8.0f) - -0.001102600927987) < tol);
102 }
103
104 /*! Data generated using numpy.kaiser(100,10) !*/
105 const static double KAISER_DATA_N_100_BETA_10[100] = {

Callers

nothing calls this directly

Calls 1

absFunction · 0.85

Tested by

no test coverage detected