Docs
Loading...
Searching...
No Matches
Datax.hpp
Go to the documentation of this file.
1
14
15#pragma once
16
17#include "ClusterInfo.hpp"
18#include "Data.hpp"
19#include <memory>
20
30class Datax : public Data {
31
32protected:
33 std::vector<std::shared_ptr<ClusterInfo>> cluster_info;
34
35 void compact_cluster(int old_cluster);
36
37public:
38 Datax(const utils_params &p, std::vector<std::shared_ptr<ClusterInfo>> ci,
39 const Eigen::VectorXi &initial_allocations = Eigen::VectorXi())
40 : Data(p, initial_allocations), cluster_info(std::move(ci)) {}
41
48 void set_allocation(int index, int cluster) override;
49
55 void set_allocations(const Eigen::VectorXi &new_allocations) override;
56
67 void
68 restore_state(Eigen::VectorXi &old_allocations,
69 std::unordered_map<int, std::vector<int>> &old_cluster_members,
70 int old_K) override;
71
72 virtual ~Datax() = default;
73};
Abstract base class for managing cluster information and caches.
Data structure for managing point distances and cluster allocations.
Data(const utils_params &p, const Eigen::VectorXi &initial_allocations=Eigen::VectorXi())
Constructs a Data object with a distance matrix.
Definition Data.cpp:10
const utils_params & p
Reference to model parameters.
Definition Data.hpp:28
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.
Definition Datax.cpp:84
Datax(const utils_params &p, std::vector< std::shared_ptr< ClusterInfo > > ci, const Eigen::VectorXi &initial_allocations=Eigen::VectorXi())
Definition Datax.hpp:38
void set_allocation(int index, int cluster) override
Assigns a point to a cluster.
Definition Datax.cpp:58
void compact_cluster(int old_cluster)
Definition Datax.cpp:9
void set_allocations(const Eigen::VectorXi &new_allocations) override
Sets all cluster allocations at once.
Definition Datax.cpp:77
virtual ~Datax()=default
std::vector< std::shared_ptr< ClusterInfo > > cluster_info
Definition Datax.hpp:33
Parameter struct for utility parameters and data structures.
Definition utils-params.hpp:17