Mercurial > hg > vamp-build-and-test
annotate DEPENDENCIES/generic/include/boost/numeric/odeint/stepper/detail/rotating_buffer.hpp @ 133:4acb5d8d80b6 tip
Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author | Chris Cannam |
---|---|
date | Tue, 30 Jul 2019 12:25:44 +0100 |
parents | c530137014c0 |
children |
rev | line source |
---|---|
Chris@16 | 1 /* |
Chris@16 | 2 [auto_generated] |
Chris@16 | 3 boost/numeric/odeint/stepper/detail/rotating_buffer.hpp |
Chris@16 | 4 |
Chris@16 | 5 [begin_description] |
Chris@16 | 6 Implemetation of a rotating (cyclic) buffer for use in the Adam Bashforth stepper |
Chris@16 | 7 [end_description] |
Chris@16 | 8 |
Chris@101 | 9 Copyright 2011 Karsten Ahnert |
Chris@101 | 10 Copyright 2011 Mario Mulansky |
Chris@16 | 11 |
Chris@16 | 12 Distributed under the Boost Software License, Version 1.0. |
Chris@16 | 13 (See accompanying file LICENSE_1_0.txt or |
Chris@16 | 14 copy at http://www.boost.org/LICENSE_1_0.txt) |
Chris@16 | 15 */ |
Chris@16 | 16 |
Chris@16 | 17 |
Chris@16 | 18 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED |
Chris@16 | 19 #define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED |
Chris@16 | 20 |
Chris@16 | 21 #include <boost/array.hpp> |
Chris@16 | 22 |
Chris@16 | 23 namespace boost { |
Chris@16 | 24 namespace numeric { |
Chris@16 | 25 namespace odeint { |
Chris@16 | 26 namespace detail { |
Chris@16 | 27 |
Chris@16 | 28 template< class T , size_t N > |
Chris@16 | 29 class rotating_buffer |
Chris@16 | 30 { |
Chris@16 | 31 public: |
Chris@16 | 32 |
Chris@16 | 33 typedef T value_type; |
Chris@16 | 34 const static size_t dim = N; |
Chris@16 | 35 |
Chris@16 | 36 rotating_buffer( void ) : m_first( 0 ) |
Chris@16 | 37 { } |
Chris@16 | 38 |
Chris@16 | 39 size_t size( void ) const |
Chris@16 | 40 { |
Chris@16 | 41 return dim; |
Chris@16 | 42 } |
Chris@16 | 43 |
Chris@16 | 44 value_type& operator[]( size_t i ) |
Chris@16 | 45 { |
Chris@16 | 46 return m_data[ get_index( i ) ]; |
Chris@16 | 47 } |
Chris@16 | 48 |
Chris@16 | 49 const value_type& operator[]( size_t i ) const |
Chris@16 | 50 { |
Chris@16 | 51 return m_data[ get_index( i ) ]; |
Chris@16 | 52 } |
Chris@16 | 53 |
Chris@16 | 54 void rotate( void ) |
Chris@16 | 55 { |
Chris@16 | 56 if( m_first == 0 ) |
Chris@16 | 57 m_first = dim-1; |
Chris@16 | 58 else |
Chris@16 | 59 --m_first; |
Chris@16 | 60 } |
Chris@16 | 61 |
Chris@16 | 62 protected: |
Chris@16 | 63 |
Chris@16 | 64 value_type m_data[N]; |
Chris@16 | 65 |
Chris@16 | 66 private: |
Chris@16 | 67 |
Chris@16 | 68 size_t get_index( size_t i ) const |
Chris@16 | 69 { |
Chris@16 | 70 return ( ( i + m_first ) % dim ); |
Chris@16 | 71 } |
Chris@16 | 72 |
Chris@16 | 73 size_t m_first; |
Chris@16 | 74 |
Chris@16 | 75 }; |
Chris@16 | 76 |
Chris@16 | 77 |
Chris@16 | 78 } // detail |
Chris@16 | 79 } // odeint |
Chris@16 | 80 } // numeric |
Chris@16 | 81 } // boost |
Chris@16 | 82 |
Chris@16 | 83 |
Chris@16 | 84 #endif // BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ROTATING_BUFFER_HPP_INCLUDED |