Chris@102: /* Chris@102: [auto_generated] Chris@102: boost/numeric/odeint/external/compute/compute_algebra.hpp Chris@102: Chris@102: [begin_description] Chris@102: An algebra for Boost.Compute vectors. Chris@102: [end_description] Chris@102: Chris@102: Copyright 2009-2011 Karsten Ahnert Chris@102: Copyright 2009-2011 Mario Mulansky Chris@102: Chris@102: Distributed under the Boost Software License, Version 1.0. Chris@102: (See accompanying file LICENSE_1_0.txt or Chris@102: copy at http://www.boost.org/LICENSE_1_0.txt) Chris@102: */ Chris@102: Chris@102: Chris@102: #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_HPP_DEFINED Chris@102: #define BOOST_NUMERIC_ODEINT_EXTERNAL_COMPUTE_COMPUTE_ALGEBRA_HPP_DEFINED Chris@102: Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost { Chris@102: namespace numeric { Chris@102: namespace odeint { Chris@102: Chris@102: struct compute_algebra Chris@102: { Chris@102: Chris@102: #define BOOST_ODEINT_COMPUTE_STATE_PARAM(z, n, unused) \ Chris@102: StateType ## n &s ## n, Chris@102: Chris@102: #define BOOST_ODEINT_COMPUTE_ALGEBRA(z, n, unused) \ Chris@102: template< BOOST_PP_ENUM_PARAMS(n, class StateType), class Operation > \ Chris@102: static void for_each ## n( \ Chris@102: BOOST_PP_REPEAT(n, BOOST_ODEINT_COMPUTE_STATE_PARAM, ~) \ Chris@102: Operation op \ Chris@102: ) \ Chris@102: { \ Chris@102: op( BOOST_PP_ENUM_PARAMS(n, s) ); \ Chris@102: } Chris@102: Chris@102: BOOST_PP_REPEAT_FROM_TO(3, 9, BOOST_ODEINT_COMPUTE_ALGEBRA, ~) Chris@102: Chris@102: #undef BOOST_ODEINT_COMPUTE_ALGEBRA Chris@102: #undef BOOST_ODEINT_COMPUTE_STATE_PARAM Chris@102: Chris@102: template < class S > Chris@102: static typename S::value_type norm_inf( const S &s ) { Chris@102: typedef typename S::value_type value_type; Chris@102: Chris@102: BOOST_COMPUTE_FUNCTION(value_type, max_abs, (value_type, value_type), Chris@102: { Chris@102: return max(_1, fabs(_2)); Chris@102: }); Chris@102: Chris@102: return boost::compute::accumulate(s.begin(), s.end(), value_type(), max_abs); Chris@102: } Chris@102: }; Chris@102: } // odeint Chris@102: } // numeric Chris@102: } // boost Chris@102: Chris@102: #endif