File indexing completed on 2025-01-18 09:39:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_LAMBDA_NUMERIC_HPP
0012 #define BOOST_LAMBDA_NUMERIC_HPP
0013
0014 #include "boost/lambda/core.hpp"
0015
0016 #include <numeric>
0017
0018 namespace boost {
0019 namespace lambda {
0020
0021 namespace ll {
0022
0023
0024
0025 struct accumulate {
0026
0027 template <class Args>
0028 struct sig {
0029 typedef typename boost::remove_const<
0030 typename boost::tuples::element<3, Args>::type
0031 >::type type;
0032 };
0033
0034 template <class A, class B, class C>
0035 C
0036 operator()(A a, B b, C c) const
0037 { return ::std::accumulate(a, b, c); }
0038
0039 template <class A, class B, class C, class D>
0040 C
0041 operator()(A a, B b, C c, D d) const
0042 { return ::std::accumulate(a, b, c, d); }
0043 };
0044
0045
0046
0047 struct inner_product {
0048
0049 template <class Args>
0050 struct sig {
0051 typedef typename boost::remove_const<
0052 typename boost::tuples::element<4, Args>::type
0053 >::type type;
0054 };
0055
0056 template <class A, class B, class C, class D>
0057 D
0058 operator()(A a, B b, C c, D d) const
0059 { return ::std::inner_product(a, b, c, d); }
0060
0061 template <class A, class B, class C, class D, class E, class F>
0062 D
0063 operator()(A a, B b, C c, D d, E e, F f) const
0064 { return ::std::inner_product(a, b, c, d, e, f); }
0065 };
0066
0067
0068
0069
0070 struct partial_sum {
0071
0072 template <class Args>
0073 struct sig {
0074 typedef typename boost::remove_const<
0075 typename boost::tuples::element<3, Args>::type
0076 >::type type;
0077 };
0078
0079 template <class A, class B, class C>
0080 C
0081 operator()(A a, B b, C c) const
0082 { return ::std::partial_sum(a, b, c); }
0083
0084 template <class A, class B, class C, class D>
0085 C
0086 operator()(A a, B b, C c, D d) const
0087 { return ::std::partial_sum(a, b, c, d); }
0088 };
0089
0090
0091
0092 struct adjacent_difference {
0093
0094 template <class Args>
0095 struct sig {
0096 typedef typename boost::remove_const<
0097 typename boost::tuples::element<3, Args>::type
0098 >::type type;
0099 };
0100
0101 template <class A, class B, class C>
0102 C
0103 operator()(A a, B b, C c) const
0104 { return ::std::adjacent_difference(a, b, c); }
0105
0106 template <class A, class B, class C, class D>
0107 C
0108 operator()(A a, B b, C c, D d) const
0109 { return ::std::adjacent_difference(a, b, c, d); }
0110 };
0111
0112 }
0113
0114 }
0115 }
0116
0117
0118
0119 #endif