Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50346 - in sandbox/cluster/boost/algorithm/cluster: . detail
From: franklin.jonathan_at_[hidden]
Date: 2008-12-21 16:43:21


Author: jfranklin
Date: 2008-12-21 16:43:20 EST (Sun, 21 Dec 2008)
New Revision: 50346
URL: http://svn.boost.org/trac/boost/changeset/50346

Log:
Renaming/reformatting, etc. in order to make the code more internally consistent across the various headers, as well as preparing the k_means code for further boostification and unification of it's interface with dbscan.

Added:
   sandbox/cluster/boost/algorithm/cluster/detail/abs_diff.hpp (contents, props changed)
Text files modified:
   sandbox/cluster/boost/algorithm/cluster/cluster_data.hpp | 4
   sandbox/cluster/boost/algorithm/cluster/concept.hpp | 4
   sandbox/cluster/boost/algorithm/cluster/dbscan.hpp | 4
   sandbox/cluster/boost/algorithm/cluster/detail/lambda_result_of.hpp | 2
   sandbox/cluster/boost/algorithm/cluster/detail/naive_query.hpp | 4
   sandbox/cluster/boost/algorithm/cluster/dist_fun.hpp | 114 +++++-----
   sandbox/cluster/boost/algorithm/cluster/k_means.hpp | 402 +++++++++++++++++++++------------------
   7 files changed, 280 insertions(+), 254 deletions(-)

Modified: sandbox/cluster/boost/algorithm/cluster/cluster_data.hpp
==============================================================================
--- sandbox/cluster/boost/algorithm/cluster/cluster_data.hpp (original)
+++ sandbox/cluster/boost/algorithm/cluster/cluster_data.hpp 2008-12-21 16:43:20 EST (Sun, 21 Dec 2008)
@@ -3,7 +3,7 @@
 // Boost Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#if ! defined BOOST_ALGORITHM_CLUSTER_CLUSTER_DATA_HPP
+#if ! defined(BOOST_ALGORITHM_CLUSTER_CLUSTER_DATA_HPP)
 #define BOOST_ALGORITHM_CLUSTER_CLUSTER_DATA_HPP
 
 #include <boost/shared_ptr.hpp>
@@ -74,4 +74,4 @@
 
 } // End of namespace boost
 
-#endif // BOOST_ALGORITHM_CLUSTER_CLUSTER_DATA_HPP
+#endif

Modified: sandbox/cluster/boost/algorithm/cluster/concept.hpp
==============================================================================
--- sandbox/cluster/boost/algorithm/cluster/concept.hpp (original)
+++ sandbox/cluster/boost/algorithm/cluster/concept.hpp 2008-12-21 16:43:20 EST (Sun, 21 Dec 2008)
@@ -3,7 +3,7 @@
 // Boost Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#if ! defined BOOST_ALGORITHM_CLUSTER_CONCEPT_HPP
+#if ! defined(BOOST_ALGORITHM_CLUSTER_CONCEPT_HPP)
 #define BOOST_ALGORITHM_CLUSTER_CONCEPT_HPP
 
 #include <boost/concept_check.hpp>
@@ -35,4 +35,4 @@
 } // End of namespace algorithm;
 } // End of namespace boost;
 
-#endif // BOOST_ALGORITHM_CLUSTER_CONCEPT_HPP
+#endif

Modified: sandbox/cluster/boost/algorithm/cluster/dbscan.hpp
==============================================================================
--- sandbox/cluster/boost/algorithm/cluster/dbscan.hpp (original)
+++ sandbox/cluster/boost/algorithm/cluster/dbscan.hpp 2008-12-21 16:43:20 EST (Sun, 21 Dec 2008)
@@ -3,7 +3,7 @@
 // Boost Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#if ! defined BOOST_ALGORITHM_CLUSTER_DBSCAN_HPP
+#if ! defined(BOOST_ALGORITHM_CLUSTER_DBSCAN_HPP)
 #define BOOST_ALGORITHM_CLUSTER_DBSCAN_HPP
 
 #include <boost/algorithm/cluster/cluster_data.hpp>
@@ -151,4 +151,4 @@
 
 } // End of namespace boost
 
-#endif // BOOST_ALGORITHM_CLUSTER_DBSCAN_HPP
+#endif

Added: sandbox/cluster/boost/algorithm/cluster/detail/abs_diff.hpp
==============================================================================
--- (empty file)
+++ sandbox/cluster/boost/algorithm/cluster/detail/abs_diff.hpp 2008-12-21 16:43:20 EST (Sun, 21 Dec 2008)
@@ -0,0 +1,27 @@
+#if ! defined(BOOST_ALGORITHM_CLUSTER_DETAIL_ABS_DIFF_HPP)
+#define BOOST_ALGORITHM_CLUSTER_DETAIL_ABS_DIFF_HPP
+
+namespace boost
+{
+namespace algorithm
+{
+namespace cluster
+{
+namespace detail
+{
+
+template<typename T>
+struct abs_diff : std::binary_function<T, T, T>
+{
+ T operator ()(T const & t1, T const & t2) const
+ {
+ return (t1 < t2) ? t2 - t1 : t1 - t2;
+ }
+};
+
+} // End of namespace detail.
+} // End of namespace cluster.
+} // End of namespace algorithm.
+} // End of namespace boost.
+
+#endif

Modified: sandbox/cluster/boost/algorithm/cluster/detail/lambda_result_of.hpp
==============================================================================
--- sandbox/cluster/boost/algorithm/cluster/detail/lambda_result_of.hpp (original)
+++ sandbox/cluster/boost/algorithm/cluster/detail/lambda_result_of.hpp 2008-12-21 16:43:20 EST (Sun, 21 Dec 2008)
@@ -28,7 +28,7 @@
 #include <boost/tuple/tuple.hpp>
 
 
-#if !defined(BOOST_LAMBDA_RESULT_OF_MAX_ARITY)
+#if ! defined(BOOST_LAMBDA_RESULT_OF_MAX_ARITY)
 #define BOOST_LAMBDA_RESULT_OF_MAX_ARITY 3
 #endif
 

Modified: sandbox/cluster/boost/algorithm/cluster/detail/naive_query.hpp
==============================================================================
--- sandbox/cluster/boost/algorithm/cluster/detail/naive_query.hpp (original)
+++ sandbox/cluster/boost/algorithm/cluster/detail/naive_query.hpp 2008-12-21 16:43:20 EST (Sun, 21 Dec 2008)
@@ -3,7 +3,7 @@
 // Boost Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#if ! defined BOOST_ALGORITHM_CLUSTER_DETAIL_NAIVE_QUERY_HPP
+#if ! defined(BOOST_ALGORITHM_CLUSTER_DETAIL_NAIVE_QUERY_HPP)
 #define BOOST_ALGORITHM_CLUSTER_DETAIL_NAIVE_QUERY_HPP
 
 #include <boost/algorithm/cluster/cluster_data.hpp>
@@ -47,4 +47,4 @@
 } // End of namespace algorithm
 } // End of namespace boost
 
-#endif // BOOST_ALGORITHM_CLUSTER_DETAIL_NAIVE_QUERY_HPP
+#endif

Modified: sandbox/cluster/boost/algorithm/cluster/dist_fun.hpp
==============================================================================
--- sandbox/cluster/boost/algorithm/cluster/dist_fun.hpp (original)
+++ sandbox/cluster/boost/algorithm/cluster/dist_fun.hpp 2008-12-21 16:43:20 EST (Sun, 21 Dec 2008)
@@ -1,4 +1,4 @@
-#ifndef BOOST_ALGORITHM_CLUSTER_DIST_FUN_HPP
+#if ! defined(BOOST_ALGORITHM_CLUSTER_DIST_FUN_HPP)
 #define BOOST_ALGORITHM_CLUSTER_DIST_FUN_HPP
 
 // (C) Copyright Anders Sundman 2008.
@@ -9,83 +9,79 @@
 #include <functional>
 #include <cmath>
 
-#include "boost/fusion/adapted.hpp"
-#include "boost/fusion/algorithm.hpp"
-#include "boost/lambda/lambda.hpp"
-#include "boost/bind.hpp"
+#include <boost/fusion/adapted.hpp>
+#include <boost/fusion/algorithm.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/bind.hpp>
 
 // This file is currently required to get Fusion and Lambda to
 // work together.
-#include "detail/lambda_result_of.hpp"
+#include <boost/algorithm/cluster/detail/lambda_result_of.hpp>
+#include <boost/algorithm/cluster/detail/abs_diff.hpp>
 
 
-namespace boost { namespace algorithm { namespace cluster {
+namespace boost
+{
+namespace algorithm
+{
+namespace cluster
+{
 
+// 2-norm.
 template<typename T1, typename T2>
-double euclid_dist( const T1 & t1, const T2 & t2)
+double euclid_dist(T1 const & t1, T2 const & 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>()
- )
- );
+ 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>()
+ )
+ );
 }
 
+// 2-norm.
 template<typename T1, typename T2>
-double euclid_dist_pretty( const T1 & t1, const T2 & t2)
+double euclid_dist_pretty(T1 const & t1, T2 const & t2)
 {
- using namespace boost::lambda;
- return std::sqrt
- (
- static_cast<double>(
- boost::fusion::fold
- (
- boost::fusion::transform
- (
- t1, t2, (_1 * _1)(_1 - _2)
- ),
- 0, _1 + _2
- )
- )
- );
+ using namespace boost::lambda;
+ return std::sqrt
+ (
+ static_cast<double>
+ (
+ boost::fusion::fold
+ (
+ boost::fusion::transform(t1, t2, (_1 * _1)(_1 - _2)),
+ 0,
+ _1 + _2
+ )
+ )
+ );
 }
 
-namespace impl {
- template<typename T>
- struct absdiff : std::binary_function<T, T, T>
- {
- T operator ()(const T & t1, const T & t2) const
- {
- return t1 < t2 ? t2 - t1 : t1 - t2;
- }
- };
-}
 
+// 1-norm.
 template<typename T1, typename T2>
-double manhattan_dist( const T1 & t1, const T2 & t2)
+double manhattan_dist(T1 const & t1, T2 const & t2)
 {
- using namespace boost::lambda;
+ using namespace boost::lambda;
     
- return boost::fusion::fold
- (
- boost::fusion::transform
- (
- t1, t2, impl::absdiff<double>()
- ),
- 0, _1 + _2
- );
+ return boost::fusion::fold
+ (
+ boost::fusion::transform(t1, t2, detail::abs_diff<double>()),
+ 0,
+ _1 + _2
+ );
 }
 
-}}}
+} // End of namespace cluster.
+} // End of namespace algorithm.
+} // End of namespace boost.
 
 #endif

Modified: sandbox/cluster/boost/algorithm/cluster/k_means.hpp
==============================================================================
--- sandbox/cluster/boost/algorithm/cluster/k_means.hpp (original)
+++ sandbox/cluster/boost/algorithm/cluster/k_means.hpp 2008-12-21 16:43:20 EST (Sun, 21 Dec 2008)
@@ -1,195 +1,225 @@
-/*****
-** References
-** - J. MacQueen, "Some methods for classification and analysis
-** of multivariate observations", Fifth Berkeley Symposium on
-** Math Statistics and Probability, 281-297, 1967.
-** - I.S. Dhillon and D.S. Modha, "A data-clustering algorithm
-** on distributed memory multiprocessors",
-** Large-Scale Parallel Data Mining, 245-260, 1999.
-** Yuanming Chen, 2008-05-08
-*/
+/*
+ * References
+ * - J. MacQueen, "Some methods for classification and analysis
+ * of multivariate observations", Fifth Berkeley Symposium on
+ * Math Statistics and Probability, 281-297, 1967.
+ * - I.S. Dhillon and D.S. Modha, "A data-clustering algorithm
+ * on distributed memory multiprocessors",
+ * Large-Scale Parallel Data Mining, 245-260, 1999.
+ * Yuanming Chen, 2008-05-08
+ */
 
-#ifndef BOOST_ALGORITHM_CLUSTER_K_MEANS_HPP
+#if ! defined(BOOST_ALGORITHM_CLUSTER_K_MEANS_HPP)
 #define BOOST_ALGORITHM_CLUSTER_K_MEANS_HPP
 
+#include <cassert>
 #include <cmath>
 #include <float.h>
-//#include "common.hpp"
-#include <vector>
 #include <list>
-#include <cassert>
+#include <vector>
+
+namespace boost
+{
+namespace algorithm
+{
+namespace cluster
+{
+namespace detail
+{
+
+// The original C function
+template<typename AttributeType, typename differenceType>
+int *k_means(AttributeType **data,
+ int n,
+ int m,
+ int k,
+ differenceType eps,
+ AttributeType **centroids)
+{
+ // Output cluster label for each data point.
+ int *labels = (int*)calloc(n, sizeof(int));
+
+ int h, i, j; // loop counters, of course :)
+ // size of each cluster.
+ int *counts = (int*)calloc(k, sizeof(int));
+ // sum of squared euclidean distance.
+ AttributeType old_error, error = FLT_MAX;
+ AttributeType **c = (centroids) ?
+ centroids :
+ (AttributeType**)calloc(k, sizeof(AttributeType*));
+ // temp centroids.
+ AttributeType **c1 = (AttributeType**)calloc(k, sizeof(AttributeType*));
+
+ //assert(data && k > 0 && k <= n && m > 0 && t >= 0); // for debugging.
+
+ // initialization
+ for (h = i = 0; i < k; h += n / k, i++)
+ {
+ c1[i] = (AttributeType*)calloc(m, sizeof(AttributeType));
+ if (!centroids)
+ {
+ c[i] = (AttributeType*)calloc(m, sizeof(AttributeType));
+ }
+ /* pick k points as initial centroids */
+ for (j = m; j-- > 0; c[i][j] = data[h][j]);
+ }
+
+ // main loop
+ do
+ {
+ // save error from last step.
+ old_error = error, error = 0;
+
+ // clear old counts and temp centroids.
+ for (i = 0; i < k; counts[i++] = 0)
+ {
+ for (j = 0; j < m; c1[i][j++] = 0);
+ }
+
+ for (h = 0; h < n; h++)
+ {
+ // identify the closest cluster.
+ AttributeType min_distance = FLT_MAX;
+ for (i = 0; i < k; i++)
+ {
+ AttributeType distance = 0;
+ for (j = m; j-- > 0; distance += pow(data[h][j] - c[i][j], 2));
+ if (distance < min_distance)
+ {
+ labels[h] = i;
+ min_distance = distance;
+ }
+ }
+ // update size and temp centroid of the destination cluster.
+ for (j = m; j-- > 0; c1[labels[h]][j] += data[h][j]);
+ counts[labels[h]]++;
+ // update standard error.
+ error += min_distance;
+ }
+
+ for (i = 0; i < k; i++)
+ {
+ // update all centroids.
+ for (j = 0; j < m; j++)
+ {
+ c[i][j] = (counts[i]) ? c1[i][j] / counts[i] : c1[i][j];
+ }
+ }
+
+ } while (fabs(error - old_error) > eps);
+
+ // housekeeping.
+ for (i = 0; i < k; ++i)
+ {
+ if (! centroids)
+ free(c[i]);
+ free(c1[i]);
+ }
+
+ if (! centroids)
+ free(c);
+ free(c1);
+
+ free(counts);
+
+ return labels;
+} // k_means
+
+} // End of namespace detail.
+
+template<typename PointType>
+struct KMeansCluster {
+ PointType centroid;
+ std::vector<int> points; //The indice of points are stored here
+};
+
+template <typename KMeansCluster>
+struct KMeansClustering {
+ typedef std::vector< KMeansCluster > type;
+ type clusters;
+};
+
+/**
+ * @param first Iterator for the first data point.
+ * @param last Iterator for the last data point.
+ * @param k The number of clusters.
+ * @param eps The epsilon value for the k-means algorithm.
+ * @return A clustering of the input data.
+ */
+template <typename NTupleIter>
+KMeansClustering<KMeansCluster<typename NTupleIter::value_type> >
+k_means(NTupleIter first,
+ NTupleIter last,
+ unsigned k,
+ typename NTupleIter::difference_type const & eps)
+{
+ typedef typename NTupleIter::difference_type DistanceType;
+ typedef typename NTupleIter::value_type PointType;
+ // For the c funtion test, AttributeType will be a double.
+ typedef typename PointType::value_type AttributeType;
+ // knumOfPoints is the n variable in the C function.
+ const DistanceType knumOfPoints = last - first;
+ // knDimension is the m variable in the C function
+ const std::size_t knDimension = PointType::size();
+
+ AttributeType** ppData = new AttributeType* [knumOfPoints];
+ AttributeType** centroids = new AttributeType* [k];
+ // Pre-allocate the result array.
+ for(std::size_t nCentroid = 0; nCentroid < k; nCentroid++)
+ {
+ centroids[nCentroid] = new AttributeType[knDimension];
+ }
+
+ int nIndex = 0;
+ for(NTupleIter iter = first; iter != last; iter++, nIndex++)
+ {
+ PointType& pt= *iter; //A point TODO: Make this const?
+ ppData[nIndex] = new AttributeType[knDimension];
+ for(unsigned int nAttribute = 0; nAttribute < knDimension; nAttribute++)
+ {
+ ppData[nIndex][nAttribute] = pt[nAttribute];
+ }
+ }
+
+ int* labels = detail::k_means(ppData,
+ (int) knumOfPoints,
+ (int) knDimension,
+ k,
+ eps,
+ centroids);
+
+ typedef KMeansCluster<PointType> KMeansClusterType;
+ KMeansClustering< KMeansClusterType > clustering;
+ for(std::size_t nCentroid = 0; nCentroid < k; nCentroid++)
+ {
+
+ KMeansClusterType cluster;
+ PointType centroid;
+ for(unsigned int nAttribute = 0; nAttribute < knDimension; nAttribute++)
+ {
+ centroid[nAttribute] = centroids[nCentroid][nAttribute];
+ }
+ cluster.centroid = centroid;
+ clustering.clusters.push_back(cluster);
+ delete[] centroids[nCentroid];
+ }
+
+ for(int nPoint = 0; nPoint < knumOfPoints; nPoint++)
+ {
+ int nCentroidIndex = labels[nPoint];
+ clustering.clusters[nCentroidIndex].points.push_back(nPoint);
+ delete[] ppData[nPoint];
+ }
+
+ delete[] centroids;
+ delete[] ppData;
+ delete[] labels;
+
+ return clustering;
+} // k_means
 
-namespace boost {
- namespace algorithm {
- namespace cluster {
- namespace detail {
- template<typename AttributeType, typename differenceType>
- //The original C function
- int *k_means(AttributeType **data, int n, int m, int k, differenceType eps, AttributeType **centroids)
- {
- /* output cluster label for each data point */
- int *labels = (int*)calloc(n, sizeof(int));
-
- int h, i, j; /* loop counters, of course :) */
- int *counts = (int*)calloc(k, sizeof(int)); /* size of each cluster */
- AttributeType old_error, error = FLT_MAX; /* sum of squared euclidean distance */
- AttributeType **c = centroids ? centroids : (AttributeType**)calloc(k, sizeof(AttributeType*));
- AttributeType **c1 = (AttributeType**)calloc(k, sizeof(AttributeType*)); /* temp centroids */
-
- //assert(data && k > 0 && k <= n && m > 0 && t >= 0); /* for debugging */
-
- /****
- ** initialization */
-
- for (h = i = 0; i < k; h += n / k, i++) {
- c1[i] = (AttributeType*)calloc(m, sizeof(AttributeType));
- if (!centroids) {
- c[i] = (AttributeType*)calloc(m, sizeof(AttributeType));
- }
- /* pick k points as initial centroids */
- for (j = m; j-- > 0; c[i][j] = data[h][j]);
- }
-
- /****
- ** main loop */
-
- do {
- /* save error from last step */
- old_error = error, error = 0;
-
- /* clear old counts and temp centroids */
- for (i = 0; i < k; counts[i++] = 0) {
- for (j = 0; j < m; c1[i][j++] = 0);
- }
-
- for (h = 0; h < n; h++) {
- /* identify the closest cluster */
- AttributeType min_distance = FLT_MAX;
- for (i = 0; i < k; i++) {
- AttributeType distance = 0;
- for (j = m; j-- > 0; distance += pow(data[h][j] - c[i][j], 2));
- if (distance < min_distance) {
- labels[h] = i;
- min_distance = distance;
- }
- }
- /* update size and temp centroid of the destination cluster */
- for (j = m; j-- > 0; c1[labels[h]][j] += data[h][j]);
- counts[labels[h]]++;
- /* update standard error */
- error += min_distance;
- }
-
- for (i = 0; i < k; i++) { /* update all centroids */
- for (j = 0; j < m; j++) {
- c[i][j] = counts[i] ? c1[i][j] / counts[i] : c1[i][j];
- }
- }
-
- } while (fabs(error - old_error) > eps);
-
- /****
- ** housekeeping */
-
- for (i = 0; i < k; i++) {
- if (!centroids) {
- free(c[i]);
- }
- free(c1[i]);
- }
-
- if (!centroids) {
- free(c);
- }
- free(c1);
-
- free(counts);
-
- return labels;
- }
- } //End of details namespace
-
- template<typename PointType>
- struct KMeansCluster {
- PointType centroid;
- std::vector<int> points; //The indice of points are stored here
- };
-
- template <typename KMeansCluster>
- struct KMeansClustering {
- typedef std::vector< KMeansCluster > type;
- type clusters;
- };
-
- /**
- * @param first: the first data point's iterator
- * @param last: the last data point's iterator
- * @param k: the k value for the k-mean algorithm
- * @return collections of clusters
- */
- template <typename NTupleIter>
- typename KMeansClustering< typename KMeansCluster<typename NTupleIter::value_type> >
- k_means(NTupleIter first, NTupleIter last, unsigned k,
- typename NTupleIter::difference_type const & eps)
- {
- typedef NTupleIter::difference_type DistanceType;
- typedef NTupleIter::value_type PointType;
- typedef PointType::value_type AttributeType; //For the c funtion test, it will be a double type
- const DistanceType knumOfPoints = last - first; //The n variable in the C function
- const std::size_t knDimension = PointType::size(); //The m variable in the C function
-
- AttributeType** ppData = new AttributeType* [knumOfPoints];
- AttributeType** centroids = new AttributeType* [k];
- //Pre-allocate the result array
- for(std::size_t nCentroid = 0; nCentroid < k; nCentroid++)
- {
- centroids[nCentroid] = new AttributeType[knDimension];
- }
-
- int nIndex = 0;
- for(NTupleIter iter = first; iter != last; iter++, nIndex++)
- {
- PointType& pt= *iter; //A point
- ppData[nIndex] = new AttributeType[knDimension];
- for(unsigned int nAttribute = 0; nAttribute < knDimension; nAttribute++)
- {
- ppData[nIndex][nAttribute] = pt[nAttribute];
- }
- }
-
- int* labels = detail::k_means(ppData, (int) knumOfPoints, (int) knDimension, k, eps, centroids);
-
- typedef KMeansCluster<PointType> KMeansClusterType;
- KMeansClustering< KMeansClusterType > clustering;
- for(std::size_t nCentroid = 0; nCentroid < k; nCentroid++)
- {
-
- KMeansClusterType cluster;
- PointType centroid;
- for(unsigned int nAttribute = 0; nAttribute < knDimension; nAttribute++)
- {
- centroid[nAttribute] = centroids[nCentroid][nAttribute];
- }
- cluster.centroid = centroid;
- clustering.clusters.push_back(cluster);
- delete[] centroids[nCentroid];
- }
-
- for(int nPoint = 0; nPoint < knumOfPoints; nPoint++)
- {
- int nCentroidIndex = labels[nPoint];
- clustering.clusters[nCentroidIndex].points.push_back(nPoint);
- delete[] ppData[nPoint];
- }
-
- delete[] centroids;
- delete[] ppData;
- delete[] labels;
-
- return clustering;
- }
- } //End of cluster namespace
- } //End of algorithm namespace
+} //End of cluster namespace
+} //End of algorithm namespace
 } //End of boost namespace
 
-#endif // BOOST_ALGORITHM_CLUSTER_K_MEANS_HPP
+#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