Boost logo

Boost-Commit :

From: sundman.anders_at_[hidden]
Date: 2008-05-16 12:46:08


Author: asundman
Date: 2008-05-16 12:46:08 EDT (Fri, 16 May 2008)
New Revision: 45430
URL: http://svn.boost.org/trac/boost/changeset/45430

Log:
Added a function for euclid_dist. Will currently only work with tuples/pairs/arrays etc. that contain elements convertible to double.
Added:
   sandbox/cluster/boost/algorithm/cluster/dist_func.hpp (contents, props changed)

Added: sandbox/cluster/boost/algorithm/cluster/dist_func.hpp
==============================================================================
--- (empty file)
+++ sandbox/cluster/boost/algorithm/cluster/dist_func.hpp 2008-05-16 12:46:08 EDT (Fri, 16 May 2008)
@@ -0,0 +1,41 @@
+#ifndef BOOST_ALGORITHM_CLUSTER_DIST_FUNC_HPP
+#define BOOST_ALGORITHM_CLUSTER_DIST_FUNC_HPP
+
+// (C) Copyright Anders Sundman 2008.
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <functional>
+#include <cmath>
+
+#include "boost/fusion/adapted.hpp"
+#include "boost/fusion/algorithm.hpp"
+
+#include "boost/bind.hpp"
+
+namespace boost { namespace algorithm { namespace cluster {
+
+template<typename T1, typename T2>
+double euclid_dist( const T1 & t1, const T2 & t2)
+{
+ return std::sqrt
+ (
+ boost::fusion::fold
+ (
+ boost::fusion::transform
+ (
+ boost::fusion::transform
+ (
+ t1, t2, std::minus<double>()
+ ),
+ boost::bind(std::multiplies<double>(), _1, _1)
+ ),
+ 0., std::plus<double>()
+ )
+ );
+}
+
+}}}
+
+#endif
\ No newline at end of file


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