47 const Eigen::MatrixXi
W;
49 SpatialCache(
const Eigen::VectorXi &allocations_ref,
const Eigen::MatrixXi &
W)
52 const int K = allocations_ref.maxCoeff() + 1;
54 recompute(K > 0 ? K : 0, allocations_ref);
64 void set_allocation(
int index,
int cluster,
int old_cluster)
override;
89 void recompute(
const int K,
const Eigen::VectorXi &allocations_in)
override;
Abstract base class for managing cluster information and caches.
std::vector< std::vector< int > > neighbor_cache
Definition spatial_cache.hpp:31
SpatialCache(const Eigen::VectorXi &allocations_ref, const Eigen::MatrixXi &W)
Definition spatial_cache.hpp:49
void neighbor_cache_compute()
Precomputes and stores neighbor indices for all observations.
Definition spatial_cache.cpp:8
ClusterStats get_cluster_stats(int cluster) const
Get cluster statistics for a specific cluster.
Definition spatial_cache.hpp:75
const ClusterStats & get_cluster_stats_ref(int cluster) const
Get cluster statistics reference for a specific cluster.
Definition spatial_cache.hpp:82
std::vector< ClusterStats > cluster_stats
Definition spatial_cache.hpp:34
void set_allocation_ptr(const Eigen::VectorXi *new_allocations)
Definition spatial_cache.hpp:66
void move_cluster_info(int from_cluster, int to_cluster) override
Moves cluster information from one cluster to another.
Definition spatial_cache.hpp:96
void recompute(const int K, const Eigen::VectorXi &allocations_in) override
Recomputes all cluster information from current allocations.
Definition spatial_cache.cpp:25
void remove_info(int cluster) override
Removes information related to a specific cluster.
Definition spatial_cache.hpp:104
void set_allocation(int index, int cluster, int old_cluster) override
Assigns a point to a cluster.
Definition spatial_cache.cpp:45
Eigen::VectorXi * allocations_ptr
Definition spatial_cache.hpp:35
const Eigen::MatrixXi W
Definition spatial_cache.hpp:47
Structure to hold statistics for each cluster.
Definition spatial_cache.hpp:27
int spatial_sum
Definition spatial_cache.hpp:28