|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51173 - sandbox/miscellanea_algorithm/boost/algorithm
From: erwann.rogard_at_[hidden]
Date: 2009-02-10 03:51:52
Author: e_r
Date: 2009-02-10 03:51:51 EST (Tue, 10 Feb 2009)
New Revision: 51173
URL: http://svn.boost.org/trac/boost/changeset/51173
Log:
adding l2_norm_squared.hpp to misc*algorithm
Added:
sandbox/miscellanea_algorithm/boost/algorithm/l2_norm_squared.hpp (contents, props changed)
Added: sandbox/miscellanea_algorithm/boost/algorithm/l2_norm_squared.hpp
==============================================================================
--- (empty file)
+++ sandbox/miscellanea_algorithm/boost/algorithm/l2_norm_squared.hpp 2009-02-10 03:51:51 EST (Tue, 10 Feb 2009)
@@ -0,0 +1,34 @@
+#ifndef BOOST_ALGORITHM_L2_NORM_SQUARED_HPP_ER_2009
+#define BOOST_ALGORITHM_L2_NORM_SQUARED_HPP_ER_2009
+#include <numeric>
+#include <boost/range.hpp>
+#include <boost/range/value_type.hpp>
+
+namespace boost{
+
+class l2_norm_squared{
+ public:
+ l2_norm_squared(){}
+ template<typename R0>
+ typename range_value<R0>::type
+ operator()(const R0& r0)const{
+ typedef typename range_value<R0>::type result_type;
+ return std::accumulate(
+ boost::begin(r0),
+ boost::end(r0),
+ (result_type)(0),
+ bin_op<result_type>()
+ );
+ };
+
+ private:
+
+ template<typename T>
+ struct bin_op{
+ bin_op(){}
+ T operator()(T x,T y)const{ return x + y*y; }
+ };
+};
+
+}
+#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk