functors.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/integrate/detail/functors.hpp
  4. [begin_description]
  5. some functors for the iterator based integrate routines
  6. [end_description]
  7. Copyright 2009-2013 Karsten Ahnert
  8. Copyright 2009-2013 Mario Mulansky
  9. Distributed under the Boost Software License, Version 1.0.
  10. (See accompanying file LICENSE_1_0.txt or
  11. copy at http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED
  15. #include <utility>
  16. namespace boost {
  17. namespace numeric {
  18. namespace odeint {
  19. namespace detail {
  20. template< class Observer >
  21. struct obs_caller {
  22. size_t &m_n;
  23. Observer m_obs;
  24. obs_caller( size_t &m , Observer &obs ) : m_n(m) , m_obs( obs ) {}
  25. template< class State , class Time >
  26. void operator()( std::pair< const State & , const Time & > x )
  27. {
  28. typedef typename odeint::unwrap_reference< Observer >::type observer_type;
  29. observer_type &obs = m_obs;
  30. obs( x.first , x.second );
  31. m_n++;
  32. }
  33. };
  34. template< class Observer , class Time >
  35. struct obs_caller_time {
  36. Time &m_t;
  37. Observer m_obs;
  38. obs_caller_time( Time &t , Observer &obs ) : m_t(t) , m_obs( obs ) {}
  39. template< class State >
  40. void operator()( std::pair< const State & , const Time & > x )
  41. {
  42. typedef typename odeint::unwrap_reference< Observer >::type observer_type;
  43. observer_type &obs = m_obs;
  44. obs( x.first , x.second );
  45. m_t = x.second;
  46. }
  47. };
  48. } // namespace detail
  49. } // namespace odeint
  50. } // namespace numeric
  51. } // namespace boost
  52. #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_FUNCTORS_HPP_INCLUDED