2
0
mirror of https://github.com/boostorg/odeint.git synced 2026-01-26 18:52:20 +00:00

fixes #109 by adding explicit conversions from multiprecision expression templates to numbers

This commit is contained in:
mariomulansky
2013-11-03 19:42:14 +01:00
parent c907f0151a
commit 6fb768e3f3
4 changed files with 12 additions and 11 deletions

View File

@@ -130,7 +130,7 @@ size_t integrate_adaptive(
while( less_with_sign( st.current_time() , end_time , st.current_time_step() ) )
{
while( less_eq_with_sign( st.current_time() + st.current_time_step() ,
while( less_eq_with_sign( static_cast<Time>(st.current_time() + st.current_time_step()) ,
end_time ,
st.current_time_step() ) )
{ //make sure we don't go beyond the end_time

View File

@@ -50,8 +50,8 @@ size_t integrate_const(
Time time = start_time;
int step = 0;
while( less_eq_with_sign( time+dt , end_time , dt ) )
// cast time+dt explicitely in case of expression templates (e.g. multiprecision)
while( less_eq_with_sign( static_cast<Time>(time+dt) , end_time , dt ) )
{
obs( start_state , time );
st.do_step( system , start_state , time , dt );
@@ -80,7 +80,7 @@ size_t integrate_const(
const Time time_step = dt;
int step = 0;
while( less_eq_with_sign( time+time_step , end_time , dt ) )
while( less_eq_with_sign( static_cast<Time>(time+time_step) , end_time , dt ) )
{
obs( start_state , time );
detail::integrate_adaptive( stepper , system , start_state , time , time+time_step , dt ,
@@ -115,7 +115,7 @@ size_t integrate_const(
int obs_step( 1 );
int real_step( 0 );
while( less_with_sign( time+dt , end_time , dt ) )
while( less_with_sign( static_cast<Time>(time+dt) , end_time , dt ) )
{
while( less_eq_with_sign( time , st.current_time() , dt ) )
{
@@ -127,7 +127,7 @@ size_t integrate_const(
time = start_time + static_cast< typename unit_value_type<Time>::type >(obs_step) * dt;
}
// we have not reached the end, do another real step
if( less_with_sign( st.current_time()+st.current_time_step() ,
if( less_with_sign( static_cast<Time>(st.current_time()+st.current_time_step()) ,
end_time ,
st.current_time_step() ) )
{

View File

@@ -79,7 +79,7 @@ Time integrate_n_steps(
for( size_t step = 0; step < num_of_steps ; ++step )
{
obs( start_state , time );
detail::integrate_adaptive( stepper , system , start_state , time , time+time_step , dt ,
detail::integrate_adaptive( stepper , system , start_state , time , static_cast<Time>(time+time_step) , dt ,
null_observer() , controlled_stepper_tag() );
// direct computation of the time avoids error propagation happening when using time += dt
// we need clumsy type analysis to get boost units working here
@@ -121,7 +121,7 @@ Time integrate_n_steps(
}
// we have not reached the end, do another real step
if( less_with_sign( st.current_time()+st.current_time_step() ,
if( less_with_sign( static_cast<Time>(st.current_time()+st.current_time_step()) ,
end_time ,
st.current_time_step() ) )
{
@@ -129,7 +129,7 @@ Time integrate_n_steps(
}
else if( less_with_sign( st.current_time() , end_time , st.current_time_step() ) )
{ // do the last step ending exactly on the end point
st.initialize( st.current_state() , st.current_time() , end_time - st.current_time() );
st.initialize( st.current_state() , st.current_time() , static_cast<Time>(end_time - st.current_time()) );
st.do_step( system );
}
}
@@ -137,9 +137,9 @@ Time integrate_n_steps(
while( st.current_time() < end_time )
{
if( less_with_sign( end_time ,
st.current_time()+st.current_time_step() ,
static_cast<Time>(st.current_time()+st.current_time_step()) ,
st.current_time_step() ) )
st.initialize( st.current_state() , st.current_time() , end_time - st.current_time() );
st.initialize( st.current_state() , st.current_time() , static_cast<Time>(end_time - st.current_time()) );
st.do_step( system );
}

View File

@@ -36,6 +36,7 @@ exe heun : heun.cpp ;
exe bind_member_functions : bind_member_functions.cpp ;
exe bind_member_functions_cpp11 : bind_member_functions_cpp11.cpp : <cxxflags>-std=c++0x ;
build-project multiprecision ;
# build-project mtl ;
# build-project ublas ;
# build-project gmpxx ;