sl@0: // -- numeric.hpp -- Boost Lambda Library ----------------------------------- sl@0: // Copyright (C) 2002 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) sl@0: // Copyright (C) 2002 Gary Powell (gwpowell@hotmail.com) sl@0: // sl@0: // Distributed under the Boost Software License, Version 1.0. (See sl@0: // accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: // sl@0: // For more information, see http://www.boost.org sl@0: sl@0: #ifndef BOOST_LAMBDA_NUMERIC_HPP sl@0: #define BOOST_LAMBDA_NUMERIC_HPP sl@0: sl@0: #include "boost/lambda/core.hpp" sl@0: sl@0: #include sl@0: sl@0: namespace boost { sl@0: namespace lambda { sl@0: sl@0: namespace ll { sl@0: sl@0: // accumulate --------------------------------- sl@0: sl@0: struct accumulate { sl@0: sl@0: template sl@0: struct sig { sl@0: typedef typename boost::remove_const< sl@0: typename boost::tuples::element<3, Args>::type sl@0: >::type type; sl@0: }; sl@0: sl@0: template sl@0: C sl@0: operator()(A a, B b, C c) const sl@0: { return ::std::accumulate(a, b, c); } sl@0: sl@0: template sl@0: C sl@0: operator()(A a, B b, C c, D d) const sl@0: { return ::std::accumulate(a, b, c, d); } sl@0: }; sl@0: sl@0: // inner_product --------------------------------- sl@0: sl@0: struct inner_product { sl@0: sl@0: template sl@0: struct sig { sl@0: typedef typename boost::remove_const< sl@0: typename boost::tuples::element<4, Args>::type sl@0: >::type type; sl@0: }; sl@0: sl@0: template sl@0: D sl@0: operator()(A a, B b, C c, D d) const sl@0: { return ::std::inner_product(a, b, c, d); } sl@0: sl@0: template sl@0: D sl@0: operator()(A a, B b, C c, D d, E e, F f) const sl@0: { return ::std::inner_product(a, b, c, d, e, f); } sl@0: }; sl@0: sl@0: sl@0: // partial_sum --------------------------------- sl@0: sl@0: struct partial_sum { sl@0: sl@0: template sl@0: struct sig { sl@0: typedef typename boost::remove_const< sl@0: typename boost::tuples::element<3, Args>::type sl@0: >::type type; sl@0: }; sl@0: sl@0: template sl@0: C sl@0: operator()(A a, B b, C c) const sl@0: { return ::std::partial_sum(a, b, c); } sl@0: sl@0: template sl@0: C sl@0: operator()(A a, B b, C c, D d) const sl@0: { return ::std::partial_sum(a, b, c, d); } sl@0: }; sl@0: sl@0: // adjacent_difference --------------------------------- sl@0: sl@0: struct adjacent_difference { sl@0: sl@0: template sl@0: struct sig { sl@0: typedef typename boost::remove_const< sl@0: typename boost::tuples::element<3, Args>::type sl@0: >::type type; sl@0: }; sl@0: sl@0: template sl@0: C sl@0: operator()(A a, B b, C c) const sl@0: { return ::std::adjacent_difference(a, b, c); } sl@0: sl@0: template sl@0: C sl@0: operator()(A a, B b, C c, D d) const sl@0: { return ::std::adjacent_difference(a, b, c, d); } sl@0: }; sl@0: sl@0: } // end of ll namespace sl@0: sl@0: } // end of lambda namespace sl@0: } // end of boost namespace sl@0: sl@0: sl@0: sl@0: #endif