File: regression_149.cpp

package info (click to toggle)
boost1.74 1.74.0%2Bds1-21
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 463,588 kB
  • sloc: cpp: 3,338,117; xml: 131,293; python: 33,088; ansic: 14,292; asm: 4,038; sh: 3,353; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (93 lines) | stat: -rw-r--r-- 2,106 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 
 [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/test/unit_test.hpp>

#include <boost/mpl/vector.hpp>
#include <boost/range/algorithm/find_if.hpp>

#include <boost/numeric/odeint.hpp>

using namespace boost::unit_test;
using namespace boost::numeric::odeint;
namespace mpl = boost::mpl;

typedef std::vector<double> state_type;

void rhs( const state_type &x , state_type &dxdt , const double t )
{
}


template<class Stepper>
struct perform_test
{
    void operator()( void )
    {
        bulirsch_stoer< state_type > stepper( 1e-9, 0.0, 0.0, 0.0 );
        state_type x( 3, 10.0 );

        print( boost::find_if(
            make_adaptive_time_range( stepper, rhs, x, 0.0, 1.0, 0.01 ),
            pred ) );

    }

    static bool pred( const std::pair< const state_type &, double > &x )
    {
        return ( x.first[0] < 0.0 );
    }

    template<class Iterator>
    void print( Iterator iter )
    {
        std::cout << iter->second << "\t" << iter->first[0] << "\t"
                  << iter->first[1] << "\t" << iter->first[2] << "\n";
    }
};

typedef mpl::vector<
    euler< state_type > ,
    runge_kutta4< state_type > ,
    runge_kutta_cash_karp54< state_type > ,
    runge_kutta_dopri5< state_type > ,
    runge_kutta_fehlberg78< state_type > ,
    bulirsch_stoer< state_type >
    > steppers;


BOOST_AUTO_TEST_SUITE( regression_147_test )

BOOST_AUTO_TEST_CASE_TEMPLATE( regression_147_test , Stepper, 
                               steppers )
{
    perform_test< Stepper > tester;
    tester();
}

BOOST_AUTO_TEST_SUITE_END()