mirror of
https://github.com/boostorg/odeint.git
synced 2026-02-14 13:02:09 +00:00
removed iterators from master
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
|
||||
[include details_integrate_functions.qbk]
|
||||
|
||||
[include details_iterators.qbk]
|
||||
|
||||
[include details_state_types_algebras_operations.qbk]
|
||||
|
||||
[include details_boost_ref.qbk]
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
[/============================================================================
|
||||
Boost.odeint
|
||||
|
||||
Copyright (c) 2009-2012 Karsten Ahnert
|
||||
Copyright (c) 2009-2012 Mario Mulansky
|
||||
|
||||
Use, modification and distribution is subject to 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)
|
||||
=============================================================================/]
|
||||
|
||||
|
||||
[section Iterators and Ranges]
|
||||
|
||||
|
||||
|
||||
odeint supports iterators for iterating through an ordinary differential equation. They offer you an alternative to the integrate functions. Furthermore, many of the standard algorithms in the C++ standard library and Boost.Range can be used with the odeint's iterators.
|
||||
|
||||
[import ../examples/const_step_iterator.cpp]
|
||||
|
||||
Four iterators are provided. They are all single pass iterators. The first one is a iterator which solves the odeint with constant step size. An example is
|
||||
|
||||
[const_step_iterator_accumulate]
|
||||
|
||||
In this example all x-values of the solution are accumulated. The iterator itself does not occur directly in this example but it is generated by the factory functions `make_const_step_iterator_begin` and `make_const_step_iterator_end`. odeint also supports Boost.Range, that is you write the above example in a more succinct form with the factory function `make_const_step_range`
|
||||
|
||||
[const_step_iterator_accumulate_range]
|
||||
|
||||
The second iterator type is also a iterator with const step size. But the value type of this iterator consists here of a pair of the time and the state of the solution of the ODE. An example is
|
||||
|
||||
[const_step_time_iterator_accumulate_range]
|
||||
|
||||
The factory functions are now `make_const_step_time_iterator_begin`, `make_const_step_time_iterator_end` and `make_const_step_time_range`.
|
||||
|
||||
|
||||
[import ../examples/adaptive_iterator.cpp]
|
||||
|
||||
The other two iterator types adaptive iterators which are completely analogous to the const step iterators. Examples are
|
||||
|
||||
[adaptive_iterator_accumulate_range]
|
||||
|
||||
[adaptive_time_iterator_accumulate_range]
|
||||
|
||||
|
||||
[section const_step_iterator]
|
||||
|
||||
* Definition: `const_step_iterator< Stepper , System >`
|
||||
* `value_type` is `Stepper::state_type`
|
||||
* Factory functions
|
||||
* `make_const_step_iterator_begin( stepper , system , state , t_start , t_end , dt )`
|
||||
* `make_const_step_iterator_end( stepper , system , state )`
|
||||
* `make_const_step_range( stepper , system , state , t_start , t_end , dt )`
|
||||
* This stepper works with all steppers fulfilling the Stepper concept or the DenseOutputStepper concept.
|
||||
* This stepper updates the value of `state`. The value of `state` is the current state of the ODE during the iteration.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section const_step_time_iterator]
|
||||
|
||||
* Definition: `const_step_iterator< Stepper , System >`
|
||||
* `value_type` is `std::pair< Stepper::state_type& , Stepper::time_type >`
|
||||
* Factory functions
|
||||
* `make_const_step_time_iterator_begin( stepper , system , state , t_start , t_end , dt )`
|
||||
* `make_const_step_time_iterator_end( stepper , system , state )`
|
||||
* `make_const_step_time_range( stepper , system , state , t_start , t_end , dt )`
|
||||
* This stepper works with all steppers fulfilling the Stepper concept or the DenseOutputStepper concept.
|
||||
* This stepper updates the value of `state`. The value of `state` is the current state of the ODE during the iteration.
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[section adaptive_step_iterator]
|
||||
|
||||
* Definition: `adaptive_iterator< Stepper , System >`
|
||||
* `value_type` is `Stepper::state_type`
|
||||
* Factory functions
|
||||
* `make_adaptive_iterator_begin( stepper , system , state , t_start , t_end , dt )`
|
||||
* `make_adaptive_iterator_end( stepper , system , state )`
|
||||
* `make_adaptive_range( stepper , system , state , t_start , t_end , dt )`
|
||||
* This stepper works with all steppers fulfilling the ControlledStepper concept or the DenseOutputStepper concept.
|
||||
* For steppers fulfilling the ControlledStepper concept `state` is modified according to the current state of the ODE. For DenseOutputStepper the state is not modified due to performance optimizations.
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
[section adaptive_step_time_iterator]
|
||||
|
||||
* Definition: `adaptive_iterator< Stepper , System >`
|
||||
* `value_type` is `std::pair< Stepper::state_type& , Stepper::time_type >`
|
||||
* Factory functions
|
||||
* `make_adaptive_time_iterator_begin( stepper , system , state , t_start , t_end , dt )`
|
||||
* `make_adaptive_time_iterator_end( stepper , system , state )`
|
||||
* `make_adaptive_time_range( stepper , system , state , t_start , t_end , dt )`
|
||||
* This stepper works with all steppers fulfilling the ControlledStepper concept or the DenseOutputStepper concept.
|
||||
* This stepper updates the value of `state`. The value of `state` is the current state of the ODE during the iteration.
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[endsect]
|
||||
@@ -108,14 +108,6 @@ When using `make_controlled` or `make_dense_output` one should be aware which ex
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Using iterators]
|
||||
|
||||
odeint supports iterators for solving ODEs. That is you instantiate a pair of iterators and instead of using the integrate routines with an appropriate observer you put the iterators in one of the algorithm from the C++ standard library or from Boost.Range. An example is
|
||||
|
||||
[harm_iterator_const_step]
|
||||
|
||||
[endsect]
|
||||
|
||||
The full source file for this example can be found here: [github_link libs/numeric/odeint/examples/harmonic_oscillator.cpp harmonic_oscillator.cpp]
|
||||
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ exe simple1d : simple1d.cpp ;
|
||||
exe stochastic_euler : stochastic_euler.cpp ;
|
||||
exe generation_functions : generation_functions.cpp ;
|
||||
exe heun : heun.cpp ;
|
||||
exe const_step_iterator : const_step_iterator.cpp : <cxxflags>-std=c++0x ;
|
||||
exe adaptive_iterator : adaptive_iterator.cpp : <cxxflags>-std=c++0x ;
|
||||
exe bind_member_functions : bind_member_functions.cpp ;
|
||||
exe bind_member_functions_cpp11 : bind_member_functions_cpp11.cpp : <cxxflags>-std=c++0x ;
|
||||
|
||||
|
||||
@@ -1,361 +0,0 @@
|
||||
/*
|
||||
* adaptive_iterator.cpp
|
||||
*
|
||||
* Copyright 2009-2012 Karsten Ahnert
|
||||
* Copyright 2009-2012 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)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
#include <boost/range/algorithm.hpp>
|
||||
#include <boost/range/adaptor/filtered.hpp>
|
||||
#include <boost/range/numeric.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
|
||||
#include <boost/numeric/odeint/stepper/runge_kutta_dopri5.hpp>
|
||||
#include <boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp>
|
||||
#include <boost/numeric/odeint/stepper/generation.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/iterator/adaptive_iterator.hpp>
|
||||
#include <boost/numeric/odeint/iterator/adaptive_time_iterator.hpp>
|
||||
|
||||
#define tab "\t"
|
||||
|
||||
using namespace std;
|
||||
using namespace boost::numeric::odeint;
|
||||
|
||||
const double sigma = 10.0;
|
||||
const double R = 28.0;
|
||||
const double b = 8.0 / 3.0;
|
||||
|
||||
struct lorenz
|
||||
{
|
||||
template< class State , class Deriv >
|
||||
void operator()( const State &x , Deriv &dxdt , double t ) const
|
||||
{
|
||||
dxdt[0] = sigma * ( x[1] - x[0] );
|
||||
dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
|
||||
dxdt[2] = -b * x[2] + x[0] * x[1];
|
||||
}
|
||||
};
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
int main( int argc , char **argv )
|
||||
{
|
||||
typedef boost::array< double , 3 > state_type;
|
||||
|
||||
/*
|
||||
* Controlled steppers with time iterator
|
||||
*/
|
||||
|
||||
// std::for_each
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
std::for_each( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
|
||||
[]( const std::pair< state_type&, double > &x ) {
|
||||
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
|
||||
}
|
||||
|
||||
// std::copy_if
|
||||
{
|
||||
std::vector< pair< state_type , double > > res;
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
std::copy_if( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
|
||||
std::back_inserter( res ) ,
|
||||
[]( const pair< state_type& , double > &x ) {
|
||||
return ( x.first[0] > 0.0 ) ? true : false; } );
|
||||
for( size_t i=0 ; i<res.size() ; ++i )
|
||||
cout << res[i].first[0] << tab << res[i].first[1] << tab << res[i].first[2] << "\n";
|
||||
}
|
||||
|
||||
// std::accumulate
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
double res = std::accumulate( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
|
||||
0.0 ,
|
||||
[]( double sum , const pair< state_type& , double > &x ) {
|
||||
return sum + x.first[0]; } );
|
||||
cout << res << endl;
|
||||
}
|
||||
|
||||
|
||||
// std::transform
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
vector< double > weights;
|
||||
std::transform( make_adaptive_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_adaptive_time_iterator_end( stepper , lorenz() , x ) ,
|
||||
back_inserter( weights ) ,
|
||||
[]( const pair< state_type& , double > &x ) {
|
||||
return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } );
|
||||
for( size_t i=0 ; i<weights.size() ; ++i )
|
||||
cout << weights[i] << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Boost.Range versions of controlled stepper with time iterator
|
||||
*/
|
||||
|
||||
|
||||
// boost::range::for_each
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
boost::range::for_each( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
[]( const std::pair< state_type& , double > &x ) {
|
||||
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
|
||||
}
|
||||
|
||||
|
||||
// boost::range::copy with filtered adaptor (simulating std::copy_if)
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
std::vector< std::pair< state_type , double > > res;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
boost::range::copy( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) |
|
||||
boost::adaptors::filtered( [] ( const pair< state_type& , double > &x ) { return ( x.first[0] > 0.0 ); } ) ,
|
||||
std::back_inserter( res ) );
|
||||
for( size_t i=0 ; i<res.size() ; ++i )
|
||||
cout << res[i].first[0] << tab << res[i].first[1] << tab << res[i].first[2] << "\n";
|
||||
}
|
||||
|
||||
// boost::range::accumulate
|
||||
{
|
||||
//[adaptive_time_iterator_accumulate_range
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
double res = boost::accumulate( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 ,
|
||||
[]( double sum , const pair< state_type& , double > &x ) {
|
||||
return sum + x.first[0]; } );
|
||||
cout << res << endl;
|
||||
//]
|
||||
}
|
||||
|
||||
|
||||
// boost::range::transform
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
vector< double > weights;
|
||||
boost::transform( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , back_inserter( weights ) ,
|
||||
[]( const pair< state_type& , double > &x ) {
|
||||
return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } );
|
||||
for( size_t i=0 ; i<weights.size() ; ++i )
|
||||
cout << weights[i] << "\n";
|
||||
}
|
||||
|
||||
|
||||
// boost::range::find with time iterator
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
auto iter = boost::find_if( make_adaptive_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
[]( const std::pair< state_type & , double > &x ) {
|
||||
return ( x.first[0] < 0.0 ); } );
|
||||
cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// /*
|
||||
// * Boost.Range versions for dense output steppers
|
||||
// */
|
||||
|
||||
// // boost::range::for_each
|
||||
// {
|
||||
// runge_kutta_dopri5< state_type > stepper;
|
||||
// state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
// boost::range::for_each( make_adaptive_range( make_dense_output( 1.0e-6 , 1.0e-6 , stepper ) , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
// []( const state_type &x ) {
|
||||
// std::cout << x[0] << tab << x[1] << tab << x[2] << "\n"; } );
|
||||
// }
|
||||
|
||||
|
||||
// // boost::range::for_each with time iterator
|
||||
// {
|
||||
// runge_kutta_dopri5< state_type > stepper;
|
||||
// state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
// boost::range::for_each( make_adaptive_time_range( make_dense_output( 1.0e-6 , 1.0e-6 , stepper ) , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
// []( const std::pair< state_type& , double > &x ) {
|
||||
// std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Pure iterators for controlled stepper without time iterator
|
||||
*/
|
||||
|
||||
// std::for_each
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
std::for_each( make_adaptive_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_adaptive_iterator_end( stepper , lorenz() , x ) ,
|
||||
[]( const state_type& x ) {
|
||||
std::cout << x[0] << tab << x[1] << tab << x[2] << "\n"; } );
|
||||
}
|
||||
|
||||
// std::copy_if
|
||||
{
|
||||
std::vector< state_type > res;
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
std::copy_if( make_adaptive_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_adaptive_iterator_end( stepper , lorenz() , x ) ,
|
||||
std::back_inserter( res ) ,
|
||||
[]( const state_type& x ) {
|
||||
return ( x[0] > 0.0 ) ? true : false; } );
|
||||
for( size_t i=0 ; i<res.size() ; ++i )
|
||||
cout << res[i][0] << tab << res[i][1] << tab << res[i][2] << "\n";
|
||||
}
|
||||
|
||||
// std::accumulate
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
double res = std::accumulate( make_adaptive_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_adaptive_iterator_end( stepper , lorenz() , x ) ,
|
||||
0.0 ,
|
||||
[]( double sum , const state_type& x ) {
|
||||
return sum + x[0]; } );
|
||||
cout << res << endl;
|
||||
}
|
||||
|
||||
|
||||
// std::transform
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
vector< double > weights;
|
||||
std::transform( make_adaptive_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_adaptive_iterator_end( stepper , lorenz() , x ) ,
|
||||
back_inserter( weights ) ,
|
||||
[]( const state_type& x ) {
|
||||
return sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] ); } );
|
||||
for( size_t i=0 ; i<weights.size() ; ++i )
|
||||
cout << weights[i] << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Boost.Range versions of controlled stepper WITHOUT time iterator
|
||||
*/
|
||||
|
||||
|
||||
// boost::range::for_each
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
boost::range::for_each( make_adaptive_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
[]( const state_type &x ) {
|
||||
std::cout << x[0] << tab << x[1] << tab << x[2] << "\n"; } );
|
||||
}
|
||||
|
||||
|
||||
// boost::range::copy with filtered adaptor (simulating std::copy_if)
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
std::vector< state_type > res;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
boost::range::copy( make_adaptive_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) |
|
||||
boost::adaptors::filtered( [] ( const state_type& x ) { return ( x[0] > 0.0 ); } ) ,
|
||||
std::back_inserter( res ) );
|
||||
for( size_t i=0 ; i<res.size() ; ++i )
|
||||
cout << res[i][0] << tab << res[i][1] << tab << res[i][2] << "\n";
|
||||
}
|
||||
|
||||
// boost::range::accumulate
|
||||
{
|
||||
//[adaptive_iterator_accumulate_range
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
double res = boost::accumulate( make_adaptive_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 ,
|
||||
[]( double sum , const state_type& x ) {
|
||||
return sum + x[0]; } );
|
||||
cout << res << endl;
|
||||
//]
|
||||
}
|
||||
|
||||
|
||||
// boost::range::transform
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
vector< double > weights;
|
||||
boost::transform( make_adaptive_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , back_inserter( weights ) ,
|
||||
[]( const state_type& x ) {
|
||||
return sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] ); } );
|
||||
for( size_t i=0 ; i<weights.size() ; ++i )
|
||||
cout << weights[i] << "\n";
|
||||
}
|
||||
|
||||
|
||||
// boost::range::find
|
||||
{
|
||||
auto stepper = make_controlled( 1.0e-6 , 1.0e-6 , runge_kutta_cash_karp54< state_type >() );
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
auto iter = boost::find_if( make_adaptive_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
[]( const state_type &x ) {
|
||||
return ( x[0] < 0.0 ); } );
|
||||
cout << (*iter)[0] << "\t" << (*iter)[1] << "\t" << (*iter)[2] << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,294 +0,0 @@
|
||||
/*
|
||||
* const_step_iterator.cpp
|
||||
*
|
||||
* Copyright 2009-2012 Karsten Ahnert
|
||||
* Copyright 2009-2012 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)
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include <boost/range/algorithm.hpp>
|
||||
#include <boost/range/adaptor/filtered.hpp>
|
||||
#include <boost/range/numeric.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
|
||||
#include <boost/numeric/odeint/stepper/runge_kutta_dopri5.hpp>
|
||||
#include <boost/numeric/odeint/stepper/generation.hpp>
|
||||
#include <boost/numeric/odeint/iterator/const_step_iterator.hpp>
|
||||
#include <boost/numeric/odeint/iterator/const_step_time_iterator.hpp>
|
||||
|
||||
#define tab "\t"
|
||||
|
||||
using namespace std;
|
||||
using namespace boost::numeric::odeint;
|
||||
|
||||
const double sigma = 10.0;
|
||||
const double R = 28.0;
|
||||
const double b = 8.0 / 3.0;
|
||||
|
||||
struct lorenz
|
||||
{
|
||||
template< class State , class Deriv >
|
||||
void operator()( const State &x , Deriv &dxdt , double t ) const
|
||||
{
|
||||
dxdt[0] = sigma * ( x[1] - x[0] );
|
||||
dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
|
||||
dxdt[2] = -b * x[2] + x[0] * x[1];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
int main( int argc , char **argv )
|
||||
{
|
||||
typedef std::array< double , 3 > state_type;
|
||||
|
||||
// std::for_each
|
||||
{
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
std::for_each( make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_const_step_time_iterator_end( stepper , lorenz() , x ) ,
|
||||
[]( const std::pair< state_type&, double > &x ) {
|
||||
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
|
||||
}
|
||||
|
||||
// std::copy_if
|
||||
{
|
||||
std::vector< state_type > res;
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
std::copy_if( make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_const_step_iterator_end( stepper , lorenz() , x ) ,
|
||||
std::back_inserter( res ) ,
|
||||
[]( const state_type& x ) {
|
||||
return ( x[0] > 0.0 ) ? true : false; } );
|
||||
for( size_t i=0 ; i<res.size() ; ++i )
|
||||
cout << res[i][0] << tab << res[i][1] << tab << res[i][2] << "\n";
|
||||
}
|
||||
|
||||
// std::accumulate
|
||||
{
|
||||
//[ const_step_iterator_accumulate
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
double res = std::accumulate( make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_const_step_iterator_end( stepper , lorenz() , x ) ,
|
||||
0.0 ,
|
||||
[]( double sum , const state_type &x ) {
|
||||
return sum + x[0]; } );
|
||||
cout << res << endl;
|
||||
//]
|
||||
}
|
||||
|
||||
|
||||
// std::transform
|
||||
{
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
vector< double > weights;
|
||||
std::transform( make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_const_step_iterator_end( stepper , lorenz() , x ) ,
|
||||
back_inserter( weights ) ,
|
||||
[]( const state_type &x ) {
|
||||
return sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] ); } );
|
||||
for( size_t i=0 ; i<weights.size() ; ++i )
|
||||
cout << weights[i] << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// std::transform with time_iterator
|
||||
{
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
vector< double > weights;
|
||||
std::transform( make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
make_const_step_time_iterator_end( stepper , lorenz() , x ) ,
|
||||
back_inserter( weights ) ,
|
||||
[]( const std::pair< state_type &, double > &x ) {
|
||||
return sqrt( x.first[0] * x.first[0] + x.first[1] * x.first[1] + x.first[2] * x.first[2] ); } );
|
||||
for( size_t i=0 ; i<weights.size() ; ++i )
|
||||
cout << weights[i] << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// /*
|
||||
// * Boost.Range versions
|
||||
// */
|
||||
|
||||
|
||||
// boost::range::for_each
|
||||
{
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
boost::range::for_each( make_const_step_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
[]( const state_type &x ) {
|
||||
std::cout << x[0] << tab << x[1] << tab << x[2] << "\n"; } );
|
||||
}
|
||||
|
||||
// boost::range::for_each with time iterator
|
||||
{
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
boost::range::for_each( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
[]( const std::pair< state_type& , double > &x ) {
|
||||
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
|
||||
}
|
||||
|
||||
|
||||
// boost::range::copy with filtered adaptor (simulating std::copy_if)
|
||||
{
|
||||
std::vector< state_type > res;
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
boost::range::copy( make_const_step_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) |
|
||||
boost::adaptors::filtered( [] ( const state_type &x ) { return ( x[0] > 0.0 ); } ) ,
|
||||
std::back_inserter( res ) );
|
||||
for( size_t i=0 ; i<res.size() ; ++i )
|
||||
cout << res[i][0] << tab << res[i][1] << tab << res[i][2] << "\n";
|
||||
}
|
||||
|
||||
// boost::range::accumulate
|
||||
{
|
||||
//[const_step_iterator_accumulate_range
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
double res = boost::accumulate( make_const_step_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 ,
|
||||
[]( double sum , const state_type &x ) {
|
||||
return sum + x[0]; } );
|
||||
cout << res << endl;
|
||||
//]
|
||||
}
|
||||
|
||||
// boost::range::accumulate with time iterator
|
||||
{
|
||||
//[const_step_time_iterator_accumulate_range
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
double res = boost::accumulate( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , 0.0 ,
|
||||
[]( double sum , const std::pair< state_type &, double > &x ) {
|
||||
return sum + x.first[0]; } );
|
||||
cout << res << endl;
|
||||
//]
|
||||
}
|
||||
|
||||
|
||||
// boost::range::transform
|
||||
{
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
vector< double > weights;
|
||||
boost::transform( make_const_step_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) , back_inserter( weights ) ,
|
||||
[]( const state_type &x ) {
|
||||
return sqrt( x[0] * x[0] + x[1] * x[1] + x[2] * x[2] ); } );
|
||||
for( size_t i=0 ; i<weights.size() ; ++i )
|
||||
cout << weights[i] << "\n";
|
||||
}
|
||||
|
||||
|
||||
// boost::range::find with time iterator
|
||||
{
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
auto iter = boost::find_if( make_const_step_time_range( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
[]( const std::pair< state_type & , double > &x ) {
|
||||
return ( x.first[0] < 0.0 ); } );
|
||||
cout << iter->second << "\t" << iter->first[0] << "\t" << iter->first[1] << "\t" << iter->first[2] << "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Boost.Range versions for dense output steppers
|
||||
*/
|
||||
|
||||
// boost::range::for_each
|
||||
{
|
||||
runge_kutta_dopri5< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
boost::range::for_each( make_const_step_range( make_dense_output( 1.0e-6 , 1.0e-6 , stepper ) , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
[]( const state_type &x ) {
|
||||
std::cout << x[0] << tab << x[1] << tab << x[2] << "\n"; } );
|
||||
}
|
||||
|
||||
|
||||
// boost::range::for_each with time iterator
|
||||
{
|
||||
runge_kutta_dopri5< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
boost::range::for_each( make_const_step_time_range( make_dense_output( 1.0e-6 , 1.0e-6 , stepper ) , lorenz() , x , 0.0 , 1.0 , 0.01 ) ,
|
||||
[]( const std::pair< state_type& , double > &x ) {
|
||||
std::cout << x.second << tab << x.first[0] << tab << x.first[1] << tab << x.first[2] << "\n"; } );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Pure iterators
|
||||
*/
|
||||
{
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
auto first = make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 );
|
||||
auto last = make_const_step_iterator_end( stepper , lorenz() , x );
|
||||
while( first != last )
|
||||
{
|
||||
assert( last != first );
|
||||
cout << (*first)[0] << tab << (*first)[1] << tab << (*first)[2] << "\n";
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
auto first = make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , 1.0 , 0.01 );
|
||||
auto last = make_const_step_time_iterator_end( stepper , lorenz() , x );
|
||||
while( first != last )
|
||||
{
|
||||
assert( last != first );
|
||||
cout << first->second << tab << first->first[0] << tab << first->first[1] << tab << first->first[2] << "\n";
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -194,10 +194,4 @@ int main(int /* argc */ , char** /* argv */ )
|
||||
#endif
|
||||
|
||||
|
||||
//[harm_iterator_const_step
|
||||
std::for_each( make_adaptive_iterator_begin( controlled_stepper , harmonic_oscillator , x , 0.0 , 10.0 , 0.01 ) ,
|
||||
make_adaptive_iterator_end( controlled_stepper , harmonic_oscillator , x ) ,
|
||||
write_state() );
|
||||
//]
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +69,3 @@ exe rt_generic_rk4_phase_lattice
|
||||
;
|
||||
|
||||
|
||||
exe const_step_iterator
|
||||
: const_step_iterator.cpp
|
||||
: <cxxflags>-std=c++0x
|
||||
;
|
||||
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* odeint_rk4_lorenz.cpp
|
||||
*
|
||||
* Copyright 2009-2012 Karsten Ahnert
|
||||
* Copyright 2009-2012 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)
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
#include <boost/range/algorithm.hpp>
|
||||
#include <boost/range/adaptor/filtered.hpp>
|
||||
#include <boost/range/numeric.hpp>
|
||||
#include <boost/timer.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
|
||||
#include <boost/numeric/odeint/stepper/runge_kutta_dopri5.hpp>
|
||||
#include <boost/numeric/odeint/stepper/generation.hpp>
|
||||
#include <boost/numeric/odeint/iterator/const_step_iterator.hpp>
|
||||
#include <boost/numeric/odeint/iterator/const_step_time_iterator.hpp>
|
||||
#include <boost/numeric/odeint/integrate/integrate_const.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace boost::numeric::odeint;
|
||||
|
||||
typedef std::array< double , 3 > state_type;
|
||||
typedef std::vector< double > state_type2;
|
||||
|
||||
std::ostream& operator<<( std::ostream &out , const state_type &x )
|
||||
{
|
||||
out << x[0] << "\t" << x[1] << "\t" << x[2];
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream &out , const state_type2 &x )
|
||||
{
|
||||
if( !x.empty() ) out << x[0];
|
||||
for( size_t i=1 ; i<x.size() ; ++i ) out << "\t" << x[i];
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
const double sigma = 10.0;
|
||||
const double R = 28.0;
|
||||
const double b = 8.0 / 3.0;
|
||||
|
||||
struct lorenz
|
||||
{
|
||||
template< class State , class Deriv >
|
||||
void operator()( const State &x , Deriv &dxdt , double t ) const
|
||||
{
|
||||
dxdt[0] = sigma * ( x[1] - x[0] );
|
||||
dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
|
||||
dxdt[2] = -b * x[2] + x[0] * x[1];
|
||||
}
|
||||
};
|
||||
|
||||
boost::timer timer;
|
||||
|
||||
void test1_iterator( double t_end = 1000000.0 , double dt = 0.01 )
|
||||
{
|
||||
cout << "Test 1 Iterator with array : ";
|
||||
timer.restart();
|
||||
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
auto first = make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , t_end , dt );
|
||||
auto last = make_const_step_iterator_end( stepper , lorenz() , x );
|
||||
for( ; first != last ; )
|
||||
++first;
|
||||
|
||||
cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl;
|
||||
}
|
||||
|
||||
void test1_time_iterator( double t_end = 1000000.0 , double dt = 0.01 )
|
||||
{
|
||||
cout << "Test 1 Time iterator with array : ";
|
||||
timer.restart();
|
||||
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
auto first = make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , t_end , dt );
|
||||
auto last = make_const_step_time_iterator_end( stepper , lorenz() , x );
|
||||
for( ; first != last ; )
|
||||
++first;
|
||||
|
||||
cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl;
|
||||
}
|
||||
|
||||
void test1_integrate( double t_end = 1000000.0 , double dt = 0.01 )
|
||||
{
|
||||
cout << "Test 1 Integrate with array : ";
|
||||
timer.restart();
|
||||
|
||||
runge_kutta4< state_type > stepper;
|
||||
state_type x = {{ 10.0 , 10.0 , 10.0 }};
|
||||
integrate_const( stepper , lorenz() , x , 0.0 , t_end , dt );
|
||||
|
||||
cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void test2_iterator( double t_end = 1000000.0 , double dt = 0.01 )
|
||||
{
|
||||
cout << "Test 2 Iterator with vector : ";
|
||||
timer.restart();
|
||||
|
||||
runge_kutta4< state_type2 > stepper;
|
||||
state_type2 x = { 10.0 , 10.0 , 10.0 };
|
||||
auto first = make_const_step_iterator_begin( stepper , lorenz() , x , 0.0 , t_end , dt );
|
||||
auto last = make_const_step_iterator_end( stepper , lorenz() , x );
|
||||
for( ; first != last ; )
|
||||
++first;
|
||||
|
||||
cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl;
|
||||
}
|
||||
|
||||
void test2_time_iterator( double t_end = 1000000.0 , double dt = 0.01 )
|
||||
{
|
||||
cout << "Test 2 Time iterator with vector : ";
|
||||
timer.restart();
|
||||
|
||||
runge_kutta4< state_type2 > stepper;
|
||||
state_type2 x = { 10.0 , 10.0 , 10.0 };
|
||||
auto first = make_const_step_time_iterator_begin( stepper , lorenz() , x , 0.0 , t_end , dt );
|
||||
auto last = make_const_step_time_iterator_end( stepper , lorenz() , x );
|
||||
for( ; first != last ; )
|
||||
++first;
|
||||
|
||||
cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl;
|
||||
}
|
||||
|
||||
void test2_integrate( double t_end = 1000000.0 , double dt = 0.01 )
|
||||
{
|
||||
cout << "Test 2 Integrate with vector : ";
|
||||
timer.restart();
|
||||
runge_kutta4< state_type2 > stepper;
|
||||
state_type2 x = { 10.0 , 10.0 , 10.0 };
|
||||
integrate_const( stepper , lorenz() , x , 0.0 , t_end , dt );
|
||||
cout << "\t" << x << " elapsed time : " << timer.elapsed() << " s" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main( int argc , char **argv )
|
||||
{
|
||||
test1_iterator( 1000000.0 );
|
||||
test1_time_iterator( 1000000.0 );
|
||||
test1_integrate( 1000000.0 );
|
||||
|
||||
test2_iterator( 1000000.0 );
|
||||
test2_time_iterator( 1000000.0 );
|
||||
test2_integrate( 1000000.0 );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -47,10 +47,6 @@ test-suite "odeint"
|
||||
[ run integrate_implicit.cpp ]
|
||||
[ run generation.cpp ]
|
||||
[ run trivial_state.cpp ]
|
||||
[ run const_step_iterator.cpp ]
|
||||
[ run const_step_time_iterator.cpp ]
|
||||
[ run adaptive_iterator.cpp ]
|
||||
[ run adaptive_time_iterator.cpp ]
|
||||
[ run is_resizeable.cpp ]
|
||||
[ run resize.cpp ]
|
||||
[ run same_size.cpp ]
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
[auto_generated]
|
||||
libs/numeric/odeint/test/adaptive_iterator.cpp
|
||||
|
||||
[begin_description]
|
||||
This file tests the adaptive iterators.
|
||||
[end_description]
|
||||
|
||||
Copyright 2009-2012 Karsten Ahnert
|
||||
Copyright 2009-2012 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)
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_TEST_MODULE odeint_adaptive_iterator
|
||||
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/numeric/odeint/config.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/iterator/adaptive_iterator.hpp>
|
||||
#include "dummy_steppers.hpp"
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
using namespace boost::numeric::odeint;
|
||||
|
||||
struct dummy_system { };
|
||||
|
||||
typedef dummy_stepper::state_type state_type;
|
||||
typedef dummy_stepper::value_type value_type;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE( adaptive_iterator_test )
|
||||
|
||||
typedef mpl::vector<
|
||||
dummy_controlled_stepper
|
||||
, dummy_dense_output_stepper
|
||||
> dummy_steppers;
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers )
|
||||
{
|
||||
typedef adaptive_iterator< Stepper , dummy_system > stepper_iterator;
|
||||
|
||||
state_type x = {{ 1.0 }};
|
||||
stepper_iterator first1( Stepper() , dummy_system() , x , 2.5 , 2.0 , 0.1 );
|
||||
stepper_iterator last1( Stepper() , dummy_system() , x );
|
||||
stepper_iterator last2( Stepper() , dummy_system() , x );
|
||||
|
||||
BOOST_CHECK( first1 == last1 );
|
||||
BOOST_CHECK( first1 == last2 );
|
||||
BOOST_CHECK( last1 == last2 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers )
|
||||
{
|
||||
typedef adaptive_iterator< Stepper , dummy_system > stepper_iterator;
|
||||
state_type x = {{ 1.0 }};
|
||||
std::vector< state_type > res;
|
||||
stepper_iterator first( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 );
|
||||
stepper_iterator last( Stepper() , dummy_system() , x );
|
||||
|
||||
std::copy( first , last , std::back_insert_iterator< std::vector< state_type > >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers )
|
||||
{
|
||||
state_type x = {{ 1.0 }};
|
||||
std::vector< state_type > res;
|
||||
std::copy( make_adaptive_iterator_begin( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) ,
|
||||
make_adaptive_iterator_end( Stepper() , dummy_system() , x ) ,
|
||||
std::back_insert_iterator< std::vector< state_type > >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers )
|
||||
{
|
||||
state_type x = {{ 1.0 }};
|
||||
std::vector< state_type > res;
|
||||
boost::range::copy( make_adaptive_range( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) ,
|
||||
std::back_insert_iterator< std::vector< state_type > >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
[auto_generated]
|
||||
libs/numeric/odeint/test/adaptive_time_iterator.cpp
|
||||
|
||||
[begin_description]
|
||||
This file tests the adaptive time iterator.
|
||||
[end_description]
|
||||
|
||||
Copyright 2009-2012 Karsten Ahnert
|
||||
Copyright 2009-2012 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)
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_TEST_MODULE odeint_adaptive_time_iterator
|
||||
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/numeric/odeint/config.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/iterator/adaptive_time_iterator.hpp>
|
||||
#include "dummy_steppers.hpp"
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
using namespace boost::numeric::odeint;
|
||||
|
||||
struct dummy_system { };
|
||||
|
||||
typedef dummy_stepper::state_type state_type;
|
||||
typedef dummy_stepper::value_type value_type;
|
||||
typedef dummy_stepper::time_type time_type;
|
||||
typedef std::vector< std::pair< state_type , time_type > > result_vector;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE( adaptive_time_iterator_test )
|
||||
|
||||
typedef mpl::vector<
|
||||
// dummy_controlled_stepper
|
||||
dummy_dense_output_stepper
|
||||
> dummy_steppers;
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers )
|
||||
{
|
||||
typedef adaptive_time_iterator< Stepper , dummy_system > stepper_iterator;
|
||||
|
||||
state_type x = {{ 1.0 }};
|
||||
stepper_iterator first1( Stepper() , dummy_system() , x , 1.5 , 1.0 , 0.1 );
|
||||
stepper_iterator last1( Stepper() , dummy_system() , x );
|
||||
stepper_iterator last2( Stepper() , dummy_system() , x );
|
||||
|
||||
BOOST_CHECK( first1 == last1 );
|
||||
BOOST_CHECK( first1 == last2 );
|
||||
BOOST_CHECK( last1 == last2 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers )
|
||||
{
|
||||
typedef adaptive_time_iterator< Stepper , dummy_system > stepper_iterator;
|
||||
state_type x = {{ 1.0 }};
|
||||
result_vector res;
|
||||
stepper_iterator first( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 );
|
||||
stepper_iterator last( Stepper() , dummy_system() , x );
|
||||
|
||||
std::copy( first , last , std::back_insert_iterator< result_vector >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
|
||||
|
||||
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
|
||||
}
|
||||
|
||||
// BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers )
|
||||
// {
|
||||
// state_type x = {{ 1.0 }};
|
||||
// result_vector res;
|
||||
// std::copy( make_adaptive_time_iterator_begin( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) ,
|
||||
// make_adaptive_time_iterator_end( Stepper() , dummy_system() , x ) ,
|
||||
// std::back_insert_iterator< result_vector >( res ) );
|
||||
|
||||
// BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
// BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
|
||||
|
||||
// BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
|
||||
// }
|
||||
|
||||
// BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers )
|
||||
// {
|
||||
// state_type x = {{ 1.0 }};
|
||||
// result_vector res;
|
||||
// boost::range::copy( make_adaptive_time_range( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) ,
|
||||
// std::back_insert_iterator< result_vector >( res ) );
|
||||
|
||||
// BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
// BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
|
||||
// BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
|
||||
|
||||
// BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
@@ -1,141 +0,0 @@
|
||||
/*
|
||||
[auto_generated]
|
||||
libs/numeric/odeint/test/const_step_iterator.cpp
|
||||
|
||||
[begin_description]
|
||||
This file tests the const step iterator.
|
||||
[end_description]
|
||||
|
||||
Copyright 2009-2012 Karsten Ahnert
|
||||
Copyright 2009-2012 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)
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_TEST_MODULE odeint_const_step_iterator
|
||||
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/numeric/odeint/config.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/iterator/const_step_iterator.hpp>
|
||||
#include "dummy_steppers.hpp"
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
using namespace boost::numeric::odeint;
|
||||
|
||||
struct dummy_system { };
|
||||
|
||||
typedef dummy_stepper::state_type state_type;
|
||||
typedef dummy_stepper::value_type value_type;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE( const_step_iterator_test )
|
||||
|
||||
typedef mpl::vector<
|
||||
dummy_stepper
|
||||
, dummy_dense_output_stepper
|
||||
> dummy_steppers;
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers )
|
||||
{
|
||||
typedef const_step_iterator< Stepper , dummy_system > stepper_iterator;
|
||||
|
||||
state_type x = {{ 1.0 }};
|
||||
stepper_iterator first1( Stepper() , dummy_system() , x , 2.5 , 2.0 , 0.1 );
|
||||
stepper_iterator last1( Stepper() , dummy_system() , x );
|
||||
stepper_iterator last2( Stepper() , dummy_system() , x );
|
||||
|
||||
BOOST_CHECK( first1 == last1 );
|
||||
BOOST_CHECK( first1 == last2 );
|
||||
BOOST_CHECK( last1 == last2 );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers )
|
||||
{
|
||||
typedef const_step_iterator< Stepper , dummy_system > stepper_iterator;
|
||||
state_type x = {{ 1.0 }};
|
||||
std::vector< state_type > res;
|
||||
stepper_iterator first( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 );
|
||||
stepper_iterator last( Stepper() , dummy_system() , x );
|
||||
|
||||
std::copy( first , last , std::back_insert_iterator< std::vector< state_type > >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );
|
||||
|
||||
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_negative_time_step , Stepper , dummy_steppers )
|
||||
{
|
||||
typedef const_step_iterator< Stepper , dummy_system > stepper_iterator;
|
||||
state_type x = {{ 1.0 }};
|
||||
std::vector< state_type > res;
|
||||
stepper_iterator first( Stepper() , dummy_system() , x , 0.3 , -0.05 , -0.1 );
|
||||
stepper_iterator last( Stepper() , dummy_system() , x );
|
||||
|
||||
std::copy( first , last , std::back_insert_iterator< std::vector< state_type > >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );
|
||||
|
||||
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers )
|
||||
{
|
||||
state_type x = {{ 1.0 }};
|
||||
std::vector< state_type > res;
|
||||
std::copy( make_const_step_iterator_begin( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) ,
|
||||
make_const_step_iterator_end( Stepper() , dummy_system() , x ) ,
|
||||
std::back_insert_iterator< std::vector< state_type > >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );
|
||||
|
||||
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers )
|
||||
{
|
||||
state_type x = {{ 1.0 }};
|
||||
std::vector< state_type > res;
|
||||
boost::range::copy( make_const_step_range( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) ,
|
||||
std::back_insert_iterator< std::vector< state_type > >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0][0] , 1.0 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[1][0] , 1.25 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[2][0] , 1.5 , 1.0e-14 );
|
||||
BOOST_CHECK_CLOSE( res[3][0] , 1.75 , 1.0e-14 );
|
||||
|
||||
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-14 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
[auto_generated]
|
||||
libs/numeric/odeint/test/const_step_time_iterator.cpp
|
||||
|
||||
[begin_description]
|
||||
This file tests the const step time iterator.
|
||||
[end_description]
|
||||
|
||||
Copyright 2009-2012 Karsten Ahnert
|
||||
Copyright 2009-2012 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)
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_TEST_MODULE odeint_const_step_time_iterator
|
||||
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/numeric/odeint/config.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
|
||||
#include <boost/numeric/odeint/iterator/const_step_time_iterator.hpp>
|
||||
#include "dummy_steppers.hpp"
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
using namespace boost::numeric::odeint;
|
||||
|
||||
struct dummy_system { };
|
||||
|
||||
typedef dummy_stepper::state_type state_type;
|
||||
typedef dummy_stepper::value_type value_type;
|
||||
typedef dummy_stepper::time_type time_type;
|
||||
typedef std::vector< std::pair< state_type , time_type > > result_vector;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE( const_step_time_iterator_test )
|
||||
|
||||
typedef mpl::vector<
|
||||
dummy_stepper
|
||||
, dummy_dense_output_stepper
|
||||
> dummy_steppers;
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( transitivity1 , Stepper , dummy_steppers )
|
||||
{
|
||||
typedef const_step_time_iterator< Stepper , dummy_system > stepper_iterator;
|
||||
|
||||
state_type x = {{ 1.0 }};
|
||||
stepper_iterator first1( Stepper() , dummy_system() , x , 1.5 , 1.0 , 0.1 );
|
||||
stepper_iterator last1( Stepper() , dummy_system() , x );
|
||||
stepper_iterator last2( Stepper() , dummy_system() , x );
|
||||
|
||||
BOOST_CHECK( first1 == last1 );
|
||||
BOOST_CHECK( first1 == last2 );
|
||||
BOOST_CHECK( last1 == last2 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm , Stepper , dummy_steppers )
|
||||
{
|
||||
typedef const_step_time_iterator< Stepper , dummy_system > stepper_iterator;
|
||||
state_type x = {{ 1.0 }};
|
||||
result_vector res;
|
||||
stepper_iterator first( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 );
|
||||
stepper_iterator last( Stepper() , dummy_system() , x );
|
||||
|
||||
std::copy( first , last , std::back_insert_iterator< result_vector >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-13 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_factory , Stepper , dummy_steppers )
|
||||
{
|
||||
state_type x = {{ 1.0 }};
|
||||
result_vector res;
|
||||
std::copy( make_const_step_time_iterator_begin( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) ,
|
||||
make_const_step_time_iterator_end( Stepper() , dummy_system() , x ) ,
|
||||
std::back_insert_iterator< result_vector >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-13 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE( copy_algorithm_with_range_factory , Stepper , dummy_steppers )
|
||||
{
|
||||
state_type x = {{ 1.0 }};
|
||||
result_vector res;
|
||||
boost::range::copy( make_const_step_time_range( Stepper() , dummy_system() , x , 0.0 , 0.35 , 0.1 ) ,
|
||||
std::back_insert_iterator< result_vector >( res ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( res.size() , size_t( 4 ) );
|
||||
BOOST_CHECK_CLOSE( res[0].first[0] , 1.0 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[0].second , 0.0 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[1].first[0] , 1.25 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[1].second , 0.1 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[2].first[0] , 1.5 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[2].second , 0.2 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[3].first[0] , 1.75 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( res[3].second , 0.3 , 1.0e-13 );
|
||||
BOOST_CHECK_CLOSE( x[0] , 2.0 , 1.0e-13 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user