IMP  2.0.0
The Integrative Modeling Platform
PartitionalClusteringWithCenter.h
Go to the documentation of this file.
1 /**
2  * \file IMP/statistics/PartitionalClusteringWithCenter.h
3  * \brief Cluster sets of points.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPSTATISTICS_PARTITIONAL_CLUSTERING_WITH_CENTER_H
10 #define IMPSTATISTICS_PARTITIONAL_CLUSTERING_WITH_CENTER_H
11 
12 #include <IMP/statistics/statistics_config.h>
13 #include "PartitionalClustering.h"
15 
16 IMPSTATISTICS_BEGIN_NAMESPACE
17 /** In addition to the information in the Clustering base class,
18  PartitionalClusteringWithCenter stores a cluster center for
19  each cluster.
20  The cluster center is a point in the space defined by the
21  embedding.
22 
23  The representative for each cluster is the member whose
24  location in the embedding is closest to the cluster center.
25 */
26 class IMPSTATISTICSEXPORT PartitionalClusteringWithCenter:
27  public PartitionalClustering {
28  IMP::base::Vector<Ints> clusters_;
29  Ints reps_;
30  algebra::VectorKDs centers_;
31 public:
32 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
33  template <int D>
35  IMP::base::Vector<Ints> &clusters,
36  const IMP::base::Vector<algebra::VectorD<D> > &centers,
37  const Ints &reps):
38  PartitionalClustering("k-means"),
39  clusters_(clusters),
40  reps_(reps),
41  centers_(reps.size()){
42  for (unsigned int i=0; i< centers_.size(); ++i) {
43  centers_[i]= algebra::VectorKD(centers[i].coordinates_begin(),
44  centers[i].coordinates_end());
45  }
46  }
47 #endif
48  const algebra::VectorKD& get_cluster_center(unsigned int i) const {
49  return centers_[i];
50  }
51  IMP_PARTITIONAL_CLUSTERING(PartitionalClusteringWithCenter);
52 };
53 
54 IMPSTATISTICS_END_NAMESPACE
55 
56 #endif /* IMPSTATISTICS_PARTITIONAL_CLUSTERING_WITH_CENTER_H */