First public contribution.
1 // -- numeric.hpp -- Boost Lambda Library -----------------------------------
2 // Copyright (C) 2002 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
3 // Copyright (C) 2002 Gary Powell (gwpowell@hotmail.com)
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org
11 #ifndef BOOST_LAMBDA_NUMERIC_HPP
12 #define BOOST_LAMBDA_NUMERIC_HPP
14 #include "boost/lambda/core.hpp"
23 // accumulate ---------------------------------
29 typedef typename boost::remove_const<
30 typename boost::tuples::element<3, Args>::type
34 template <class A, class B, class C>
36 operator()(A a, B b, C c) const
37 { return ::std::accumulate(a, b, c); }
39 template <class A, class B, class C, class D>
41 operator()(A a, B b, C c, D d) const
42 { return ::std::accumulate(a, b, c, d); }
45 // inner_product ---------------------------------
47 struct inner_product {
51 typedef typename boost::remove_const<
52 typename boost::tuples::element<4, Args>::type
56 template <class A, class B, class C, class D>
58 operator()(A a, B b, C c, D d) const
59 { return ::std::inner_product(a, b, c, d); }
61 template <class A, class B, class C, class D, class E, class F>
63 operator()(A a, B b, C c, D d, E e, F f) const
64 { return ::std::inner_product(a, b, c, d, e, f); }
68 // partial_sum ---------------------------------
74 typedef typename boost::remove_const<
75 typename boost::tuples::element<3, Args>::type
79 template <class A, class B, class C>
81 operator()(A a, B b, C c) const
82 { return ::std::partial_sum(a, b, c); }
84 template <class A, class B, class C, class D>
86 operator()(A a, B b, C c, D d) const
87 { return ::std::partial_sum(a, b, c, d); }
90 // adjacent_difference ---------------------------------
92 struct adjacent_difference {
96 typedef typename boost::remove_const<
97 typename boost::tuples::element<3, Args>::type
101 template <class A, class B, class C>
103 operator()(A a, B b, C c) const
104 { return ::std::adjacent_difference(a, b, c); }
106 template <class A, class B, class C, class D>
108 operator()(A a, B b, C c, D d) const
109 { return ::std::adjacent_difference(a, b, c, d); }
112 } // end of ll namespace
114 } // end of lambda namespace
115 } // end of boost namespace