Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:55

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/stepper/detail/rotating_buffer.hpp
0004 
0005  [begin_description]
0006  Implemetation of a rotating (cyclic) buffer for use in the Adam Bashforth stepper
0007  [end_description]
0008 
0009  Copyright 2011 Karsten Ahnert
0010  Copyright 2011 Mario Mulansky
0011 
0012  Distributed under the Boost Software License, Version 1.0.
0013  (See accompanying file LICENSE_1_0.txt or
0014  copy at http://www.boost.org/LICENSE_1_0.txt)
0015  */
0016 
0017 
0018 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED
0019 #define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED
0020 
0021 #include <boost/array.hpp>
0022 
0023 namespace boost {
0024 namespace numeric {
0025 namespace odeint {
0026 namespace detail {
0027 
0028 template< class T , size_t N >
0029 class rotating_buffer
0030 {
0031 public:
0032 
0033     typedef T value_type;
0034     const static size_t dim = N;
0035 
0036     rotating_buffer( void ) : m_first( 0 )
0037     { }
0038 
0039     size_t size( void ) const
0040     {
0041         return dim;
0042     }
0043 
0044     value_type& operator[]( size_t i )
0045     {
0046         return m_data[ get_index( i ) ];
0047     }
0048 
0049     const value_type& operator[]( size_t i ) const
0050     {
0051         return m_data[ get_index( i ) ];
0052     }
0053 
0054     void rotate( void )
0055     {
0056         if( m_first == 0 )
0057             m_first = dim-1;
0058         else
0059             --m_first;
0060     }
0061 
0062 protected:
0063 
0064     value_type m_data[N];
0065 
0066 private:
0067 
0068     size_t get_index( size_t i ) const
0069     {
0070         return ( ( i + m_first ) % dim );
0071     }
0072 
0073     size_t m_first;
0074 
0075 };
0076 
0077 
0078 } // detail
0079 } // odeint
0080 } // numeric
0081 } // boost
0082 
0083 
0084 #endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED