Thesis docs
Loading...
Searching...
No Matches
Data Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Data()

Data::Data ( const Eigen::MatrixXd & distances,
const Eigen::VectorXi & initial_allocations = Eigen::VectorXi() )

Constructs a Data object with a distance matrix.

Parameters
distancesSquare matrix of pairwise distances between points
initial_allocationsOptional initial cluster assignments (default: all in one cluster)
Exceptions
std::invalid_argumentif distance matrix is not square

Member Function Documentation

◆ get_allocations()

const Eigen::VectorXi & Data::get_allocations ( ) const
inline

Gets the cluster allocations vector.

Returns
Reference to the allocations vector

◆ get_cluster_assignment()

int Data::get_cluster_assignment ( int index) const
inline

Gets the cluster assignment of a specific point.

Parameters
indexIndex of the point
Returns
Cluster index the point is assigned to
Exceptions
std::out_of_rangeif index is out of bounds

◆ get_cluster_assignments()

Eigen::VectorXi Data::get_cluster_assignments ( int cluster) const

Gets all point indices assigned to a specific cluster.

Parameters
clusterIndex of the cluster
Returns
Vector of point indices in the cluster
Exceptions
std::out_of_rangeif cluster index is invalid

◆ get_cluster_size()

int Data::get_cluster_size ( unsigned cluster_index) const
inline

Gets the size of a specific cluster.

Parameters
cluster_indexIndex of the cluster
Returns
Number of points in the cluster (0 if cluster doesn't exist)

◆ get_distance()

double Data::get_distance ( int i,
int j ) const

Gets the distance between two points.

Parameters
iIndex of first point
jIndex of second point
Returns
Distance between points i and j

◆ get_K()

int Data::get_K ( ) const
inline

Gets the current number of clusters.

Returns
Number of clusters

◆ get_n()

int Data::get_n ( ) const
inline

Gets the total number of points.

Returns
Number of points

◆ set_allocation()

void Data::set_allocation ( int index,
int cluster )

Assigns a point to a cluster.

Parameters
indexIndex of the point to reassign
clusterTarget cluster index (K for new cluster, -1 for unallocated)
Exceptions
std::out_of_rangeif index or cluster is invalid

◆ set_allocations()

void Data::set_allocations ( const Eigen::VectorXi & new_allocations)

Sets all cluster allocations at once.

Parameters
new_allocationsVector of cluster assignments for all points
Exceptions
std::invalid_argumentif vector size doesn't match number of points

The documentation for this class was generated from the following files: