1 #include <boost/config.hpp>
3 #pragma warning(disable:4996)
6 #define BOOST_TEST_MODULE odeint_adaptive_adams_coefficients
8 #include <boost/test/unit_test.hpp>
10 #include <boost/numeric/odeint/stepper/detail/adaptive_adams_coefficients.hpp>
14 #include <boost/mpl/list.hpp>
15 #include <boost/mpl/size_t.hpp>
16 #include <boost/mpl/range_c.hpp>
18 using namespace boost::unit_test
;
19 using namespace boost::numeric::odeint
;
21 typedef double value_type
;
23 BOOST_AUTO_TEST_SUITE( adaptive_adams_coefficients_test
)
25 typedef boost::mpl::range_c
< size_t , 2 , 10 > vector_of_steps
;
26 BOOST_AUTO_TEST_CASE_TEMPLATE( test_step
, step_type
, vector_of_steps
)
28 const static size_t steps
= step_type::value
;
30 typedef std::vector
<double> deriv_type
;
31 typedef double time_type
;
33 typedef detail::adaptive_adams_coefficients
<steps
, deriv_type
, time_type
> aac_type
;
35 std::vector
<double> deriv
;
42 for(size_t i
=0; i
<steps
; ++i
)
50 if(coeff
.m_eo
< steps
)
54 std::vector
<value_type
> v(10);
61 v
[6] = 19087.0/60480.0;
62 v
[7] = 5257.0/17280.0;
63 v
[8] = 5311869667636789.0/18014398509481984.0;
65 for(size_t i
=0; i
<steps
; ++i
)
67 BOOST_CHECK_SMALL(coeff
.beta
[1][i
] - 1.0, 1e-15);
70 BOOST_CHECK_SMALL(coeff
.phi
[2][i
].m_v
[0] + 1, 1e-15);
71 else if (i
== steps
-1 && steps
%2 == 1)
72 BOOST_CHECK_SMALL(coeff
.phi
[2][i
].m_v
[0] - 1, 1e-14);
73 else if (i
== steps
-1 && steps
%2 == 0)
74 BOOST_CHECK_SMALL(coeff
.phi
[2][i
].m_v
[0] + 1, 1e-14);
76 BOOST_CHECK_SMALL(coeff
.phi
[2][i
].m_v
[0], 1e-15);
78 BOOST_CHECK_SMALL(coeff
.g
[i
] - v
[i
], 1e-15);
82 BOOST_AUTO_TEST_CASE( test_copy
)
84 typedef std::vector
<double> deriv_type
;
85 typedef double time_type
;
87 typedef detail::adaptive_adams_coefficients
<3, deriv_type
, time_type
> aac_type
;
96 for(size_t i
=0; i
<3; ++i
)
109 BOOST_CHECK_EQUAL(c1
.phi
[0][0].m_v
[0], c2
.phi
[0][0].m_v
[0]);
110 BOOST_CHECK(&(c1
.phi
[0][0].m_v
) != &(c2
.phi
[0][0].m_v
));
113 deriv_type
*p1
= &(c3
.phi
[0][0].m_v
);
116 BOOST_CHECK(p1
== (&(c3
.phi
[0][0].m_v
)));
117 BOOST_CHECK_EQUAL(c1
.phi
[0][0].m_v
[0], c3
.phi
[0][0].m_v
[0]);
120 BOOST_AUTO_TEST_SUITE_END()