Docs
Loading...
Searching...
No Matches
Datax Class Reference

Data container with integrated cluster information management. More...

#include <Datax.hpp>

Inheritance diagram for Datax:
Data

Public Member Functions

 Datax (const Params &p, std::vector< std::shared_ptr< ClusterInfo > > ci, const Eigen::VectorXi &initial_allocations=Eigen::VectorXi())
void set_allocation (int index, int cluster) override
 Assigns a point to a cluster.
void set_allocations (const Eigen::VectorXi &new_allocations) override
 Sets all cluster allocations at once.
void restore_state (Eigen::VectorXi &old_allocations, std::unordered_map< int, std::vector< int > > &old_cluster_members, int old_K) override
 Restores allocations, cluster memberships, and cluster count from a saved state.
virtual ~Datax ()=default
Public Member Functions inherited from Data
 Data (const Params &p, const Eigen::VectorXi &initial_allocations=Eigen::VectorXi())
 Constructs a Data object with a distance matrix.
virtual ~Data ()=default
double get_distance (int i, int j) const
 Getters.
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.
Eigen::Map< const Eigen::VectorXi > get_cluster_assignments_ref (int cluster) const
 Gets all point indices assigned to a specific cluster (map form).
std::unordered_map< int, std::vector< int > > get_cluster_map_copy () const
 Gets the full mapping of clusters to their member points.
const std::unordered_map< int, std::vector< int > > & get_cluster_map () const
 Gets the full mapping of clusters to their member points.

Protected Member Functions

void compact_cluster (int old_cluster)
Protected Member Functions inherited from Data
void compact_cluster (int old_cluster)
 Removes an empty cluster and compacts cluster indices.
void set_allocation_wo_compaction (int index, int cluster)
 Assigns a point to a cluster without compaction.

Protected Attributes

std::vector< std::shared_ptr< ClusterInfo > > cluster_info
Protected Attributes inherited from Data
const Paramsparams
 Reference to model parameters.
Eigen::VectorXi allocations
 Cluster allocation for each point.
int K
 Current number of clusters.
std::unordered_map< int, std::vector< int > > cluster_members
 Maps cluster indices to vectors of point indices in that cluster.

Detailed Description

Data container with integrated cluster information management.

This class extends the base Data class to include a vector of ClusterInfo objects that can provide additional cluster-related computations or caching. It maintains synchronization between data allocations and cluster information.

Constructor & Destructor Documentation

◆ Datax()

Datax::Datax ( const Params & p,
std::vector< std::shared_ptr< ClusterInfo > > ci,
const Eigen::VectorXi & initial_allocations = Eigen::VectorXi() )
inline

◆ ~Datax()

virtual Datax::~Datax ( )
virtualdefault

Member Function Documentation

◆ compact_cluster()

void Datax::compact_cluster ( int old_cluster)
protected

◆ restore_state()

void Datax::restore_state ( Eigen::VectorXi & old_allocations,
std::unordered_map< int, std::vector< int > > & old_cluster_members,
int old_K )
overridevirtual

Restores allocations, cluster memberships, and cluster count from a saved state.

Parameters
old_allocationsVector holding the saved allocations (swapped into place)
old_cluster_membersMap of saved cluster memberships (swapped into place)
old_KNumber of clusters in the saved state

Reimplemented from Data.

◆ set_allocation()

void Datax::set_allocation ( int index,
int cluster )
overridevirtual

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

Reimplemented from Data.

◆ set_allocations()

void Datax::set_allocations ( const Eigen::VectorXi & new_allocations)
overridevirtual

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

Reimplemented from Data.

Member Data Documentation

◆ cluster_info

std::vector<std::shared_ptr<ClusterInfo> > Datax::cluster_info
protected

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