STORMM Source Documentation
Loading...
Searching...
No Matches
cluster_manager.h
1// -*-c++-*-
2#ifndef STORMM_CLUSTER_MANAGER_H
3#define STORMM_CLUSTER_MANAGER_H
4
5#include <vector>
6#include "copyright.h"
7#include "Accelerator/hybrid.h"
8#include "Constants/hpc_bounds.h"
9#include "Synthesis/condensate.h"
10#include "Synthesis/phasespace_synthesis.h"
11#include "Trajectory/coordinateframe.h"
12#include "Trajectory/coordinate_series.h"
13#include "Trajectory/phasespace.h"
14#include "rounding.h"
15
16namespace stormm {
17namespace stmath {
18
19using card::Hybrid;
20using card::HybridKind;
21using card::HybridTargetLevel;
22using synthesis::Condensate;
23using synthesis::PhaseSpaceSynthesis;
24using trajectory::CoordinateFrame;
25using trajectory::PhaseSpace;
26using trajectory::CoordinateSeries;
27
32template <typename Tcalc>
34public:
35
37 ClusterManagerKit(size_t data_points_in, int clusters_in, int* cls_homes_in,
38 size_t* cls_membership_in, size_t* cls_bounds_in, size_t* cls_primes_in,
39 Tcalc* cls_rmsd_in, Tcalc* centroid_dist_in);
40
44 ClusterManagerKit(const ClusterManagerKit &original) = default;
45 ClusterManagerKit(ClusterManagerKit &&original) = default;
47
48 const size_t data_points;
49 const int clusters;
50 int* cls_homes;
53 size_t* cls_bounds;
54 size_t* cls_primes;
55 Tcalc* cls_rmsd;
58};
59
61template <typename Tdata, typename Tcalc>
63public:
64
67 explicit ClusterManager(size_t data_point_count_in = 0, int cluster_count_in = 1,
68 int attempt_count_in = 0);
69
80 ClusterManager& operator=(const ClusterManager &original);
81 ClusterManager& operator=(ClusterManager &&original);
83
85 size_t getDataPointCount() const;
86
88 int getClusterCount() const;
89
92 int getAttemptCount() const;
93
97 int getClusterHome(size_t point_index) const;
98
102 size_t getClusterSize(int cluster_index) const;
103
107 size_t getClusterPrime(int cluster_index) const;
108
112 std::vector<size_t> getClusterMembers(int cluster_index) const;
113
117 const Tdata& getClusterCentroid(int cluster_index) const;
118
120 const std::vector<Tdata>& getClusterCentroids() const;
121
130 const ClusterManagerKit<Tcalc> data(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
131 ClusterManagerKit<Tcalc> data(HybridTargetLevel tier = HybridTargetLevel::HOST);
133
138 void resize(size_t data_point_count_in, int cluster_count_in);
139
143 void setAttemptCount(int attempt_count_in);
144
149 void setCentroid(int cluster_index, const Tdata value);
150
151private:
152 size_t data_point_count;
153 int cluster_count;
154 int attempt_count;
156 Hybrid<int> cluster_homes;
157 Hybrid<size_t> cluster_membership;
159 Hybrid<size_t> cluster_bounds;
160 Hybrid<size_t> cluster_primes;
162 Hybrid<Tcalc> cluster_rmsd;
166 Hybrid<Tcalc> centroid_distances;
169 Hybrid<size_t> sizet_data;
171 Hybrid<Tcalc> real_data;
173 std::vector<Tdata> centroids;
187
190 void allocate();
191
195 void validateClusterIndex(int cluster_index) const;
196};
197
198} // namespace stmath
199} // namespace stormm
200
201#include "cluster_manager.tpp"
202
203#endif
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202
const ClusterManagerKit< Tcalc > data(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the abstract.
const std::vector< Tdata > & getClusterCentroids() const
Get a const references to the vector of centroids for all clusters.
void resize(size_t data_point_count_in, int cluster_count_in)
Set the number of clusters and data points.
ClusterManager(const ClusterManager &original)
The copy and move constructors, as well as copy and move assignment operators, must be explicitly ins...
int getClusterHome(size_t point_index) const
Get the cluster to which a specific data point belongs.
int getAttemptCount() const
Get the number of attempts made to cluster the data resulting in the reported arrangement.
int getClusterCount() const
Get the number of clusters.
const Tdata & getClusterCentroid(int cluster_index) const
Get the centroid for a particular cluster.
size_t getClusterSize(int cluster_index) const
Get the size of a cluster.
void setCentroid(int cluster_index, const Tdata value)
Set the value of one cluster's centroid.
size_t getClusterPrime(int cluster_index) const
Get the cluster member nearest the cluster centroid.
void setAttemptCount(int attempt_count_in)
Set the number of attempts.
size_t getDataPointCount() const
Get the number of data points.
ClusterManager(size_t data_point_count_in=0, int cluster_count_in=1, int attempt_count_in=0)
The constructor accepts a number of data points and a number of clusters, as well as the number of se...
std::vector< size_t > getClusterMembers(int cluster_index) const
Get all members of a cluster.
An abstract of the cluster manager suitable for rapid access and modification in the C++ layer,...
Definition cluster_manager.h:33
size_t * cls_membership
Concatenated lists of the data points each cluster comprises.
Definition cluster_manager.h:52
ClusterManagerKit(size_t data_points_in, int clusters_in, int *cls_homes_in, size_t *cls_membership_in, size_t *cls_bounds_in, size_t *cls_primes_in, Tcalc *cls_rmsd_in, Tcalc *centroid_dist_in)
The constructor takes arguments for every member variable.
int * cls_homes
Definition cluster_manager.h:50
const int clusters
The number of clusters into which data points are grouped.
Definition cluster_manager.h:49
const size_t data_points
The number of data points in the entire set.
Definition cluster_manager.h:48
size_t * cls_bounds
Bounds array on cls_membership.
Definition cluster_manager.h:53
size_t * cls_primes
Members of each cluster nearest the cluster's centroid.
Definition cluster_manager.h:54
Tcalc * centroid_dist
Distance of each data point to its cluster's centroid.
Definition cluster_manager.h:57
ClusterManagerKit(const ClusterManagerKit &original)=default
The const sizing elements mean that the default copy and move assignment operators will be implicitly...
Tcalc * cls_rmsd
Definition cluster_manager.h:55