mirror of
https://github.com/boostorg/odeint.git
synced 2025-05-11 13:34:09 +00:00
fixes #168
fixed bug in less_eq_with_sign. equality was not correctly checked for, which resulted in wrong behavior when the numeric type had std::numeric_limits<T>::epsilon() == 0.
This commit is contained in:
parent
45fd4331c2
commit
ff755ff96e
@ -47,9 +47,9 @@ template< typename T >
|
||||
bool less_eq_with_sign( T t1 , T t2 , T dt )
|
||||
{
|
||||
if( get_unit_value(dt) > 0 )
|
||||
return t1-t2 < std::numeric_limits<T>::epsilon();
|
||||
return t1-t2 <= std::numeric_limits<T>::epsilon();
|
||||
else
|
||||
return t2-t1 < std::numeric_limits<T>::epsilon();
|
||||
return t2-t1 <= std::numeric_limits<T>::epsilon();
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
|
@ -25,5 +25,6 @@ test-suite "odeint"
|
||||
:
|
||||
[ run regression_147.cpp ]
|
||||
[ compile regression_149.cpp : <cxxflags>-std=c++0x ]
|
||||
[ run regression_168.cpp ]
|
||||
: <testing.launcher>valgrind
|
||||
;
|
||||
|
90
test/regression/regression_168.cpp
Normal file
90
test/regression/regression_168.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
|
||||
[begin_description]
|
||||
Test case for issue 149:
|
||||
Error C2582 with msvc-10 when using iterator-based integration
|
||||
[end_description]
|
||||
|
||||
Copyright 2011-2015 Karsten Ahnert
|
||||
Copyright 2011-2015 Mario Mulansky
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or
|
||||
copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
// disable checked iterator warning for msvc
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
#define BOOST_TEST_MODULE odeint_regression_147
|
||||
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/range/algorithm/find_if.hpp>
|
||||
|
||||
#include <boost/numeric/odeint.hpp>
|
||||
#include <boost/numeric/odeint/algebra/fusion_algebra.hpp>
|
||||
#include <boost/numeric/odeint/algebra/fusion_algebra_dispatcher.hpp>
|
||||
|
||||
|
||||
#include <boost/units/systems/si/length.hpp>
|
||||
#include <boost/units/systems/si/time.hpp>
|
||||
#include <boost/units/systems/si/velocity.hpp>
|
||||
#include <boost/units/systems/si/acceleration.hpp>
|
||||
#include <boost/units/systems/si/io.hpp>
|
||||
|
||||
#include <boost/fusion/container.hpp>
|
||||
|
||||
|
||||
using namespace boost::unit_test;
|
||||
using namespace boost::numeric::odeint;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
namespace units = boost::units;
|
||||
namespace si = boost::units::si;
|
||||
|
||||
typedef units::quantity< si::time , double > time_type;
|
||||
typedef units::quantity< si::length , double > length_type;
|
||||
typedef units::quantity< si::velocity , double > velocity_type;
|
||||
typedef units::quantity< si::acceleration , double > acceleration_type;
|
||||
typedef units::quantity< si::frequency , double > frequency_type;
|
||||
|
||||
typedef fusion::vector< length_type , velocity_type > state_type;
|
||||
typedef fusion::vector< velocity_type , acceleration_type > deriv_type;
|
||||
|
||||
|
||||
struct oscillator
|
||||
{
|
||||
frequency_type m_omega;
|
||||
|
||||
oscillator( const frequency_type &omega = 1.0 * si::hertz ) : m_omega( omega ) { }
|
||||
|
||||
void operator()( const state_type &x , deriv_type &dxdt , time_type t ) const
|
||||
{
|
||||
fusion::at_c< 0 >( dxdt ) = fusion::at_c< 1 >( x );
|
||||
fusion::at_c< 1 >( dxdt ) = - m_omega * m_omega * fusion::at_c< 0 >( x );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( regression_168 )
|
||||
{
|
||||
typedef runge_kutta_dopri5< state_type , double , deriv_type , time_type > stepper_type;
|
||||
|
||||
state_type x( 1.0 * si::meter , 0.0 * si::meter_per_second );
|
||||
|
||||
integrate_const( make_dense_output( 1.0e-6 , 1.0e-6 , stepper_type() ) , oscillator( 2.0 * si::hertz ) ,
|
||||
x , 0.0 * si::second , 100.0 * si::second , 0.1 * si::second);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user