Thesis docs
|
Manages distance matrices and cluster allocations for points. More...
#include <Data.hpp>
Public Member Functions | |
Data (const Eigen::MatrixXd &distances, const Eigen::VectorXi &initial_allocations=Eigen::VectorXi()) | |
Constructs a Data object with a distance matrix. | |
double | get_distance (int i, int j) const |
Gets the distance between two points. | |
int | get_n () const |
Gets the total number of points. | |
int | get_K () const |
Gets the current number of clusters. | |
const Eigen::VectorXi & | get_allocations () const |
Gets the cluster allocations vector. | |
int | get_cluster_size (unsigned cluster_index) const |
Gets the size of a specific cluster. | |
int | get_cluster_assignment (int index) const |
Gets the cluster assignment of a specific point. | |
Eigen::VectorXi | get_cluster_assignments (int cluster) const |
Gets all point indices assigned to a specific cluster. | |
void | set_allocation (int index, int cluster) |
Assigns a point to a cluster. | |
void | set_allocations (const Eigen::VectorXi &new_allocations) |
Sets all cluster allocations at once. | |
Manages distance matrices and cluster allocations for points.
This class stores a distance matrix between points and tracks their cluster assignments. It provides methods to query distances, manage cluster allocations, and maintain cluster membership information.
Data::Data | ( | const Eigen::MatrixXd & | distances, |
const Eigen::VectorXi & | initial_allocations = Eigen::VectorXi() ) |
Constructs a Data object with a distance matrix.
distances | Square matrix of pairwise distances between points |
initial_allocations | Optional initial cluster assignments (default: all in one cluster) |
std::invalid_argument | if distance matrix is not square |
|
inline |
Gets the cluster allocations vector.
|
inline |
Gets the cluster assignment of a specific point.
index | Index of the point |
std::out_of_range | if index is out of bounds |
Eigen::VectorXi Data::get_cluster_assignments | ( | int | cluster | ) | const |
Gets all point indices assigned to a specific cluster.
cluster | Index of the cluster |
std::out_of_range | if cluster index is invalid |
|
inline |
Gets the size of a specific cluster.
cluster_index | Index of the cluster |
double Data::get_distance | ( | int | i, |
int | j ) const |
Gets the distance between two points.
i | Index of first point |
j | Index of second point |
|
inline |
Gets the current number of clusters.
|
inline |
Gets the total number of points.
void Data::set_allocation | ( | int | index, |
int | cluster ) |
Assigns a point to a cluster.
index | Index of the point to reassign |
cluster | Target cluster index (K for new cluster, -1 for unallocated) |
std::out_of_range | if index or cluster is invalid |
void Data::set_allocations | ( | const Eigen::VectorXi & | new_allocations | ) |
Sets all cluster allocations at once.
new_allocations | Vector of cluster assignments for all points |
std::invalid_argument | if vector size doesn't match number of points |