Cache for spatial model with spatial covariates.
More...
#include <spatial_cache.hpp>
|
| | SpatialCache (const Eigen::VectorXi &allocations_ref, const Eigen::MatrixXi &W) |
| void | set_allocation (int index, int cluster, int old_cluster) override |
| | Assigns a point to a cluster.
|
| void | set_allocation_ptr (const Eigen::VectorXi *new_allocations) |
| ClusterStats | get_cluster_stats (int cluster) const |
| | Get cluster statistics for a specific cluster.
|
| const ClusterStats & | get_cluster_stats_ref (int cluster) const |
| | Get cluster statistics reference for a specific cluster.
|
| void | recompute (const int K, const Eigen::VectorXi &allocations_in) override |
| | Recomputes all cluster information from current allocations.
|
| void | move_cluster_info (int from_cluster, int to_cluster) override |
| | Moves cluster information from one cluster to another.
|
| void | remove_info (int cluster) override |
| | Removes information related to a specific cluster.
|
| | ClusterInfo ()=default |
| virtual | ~ClusterInfo ()=default |
Cache for spatial model with spatial covariates.
This class maintains cluster statistics for a spatial model that includes spatial covariates.
◆ SpatialCache()
| SpatialCache::SpatialCache |
( |
const Eigen::VectorXi & | allocations_ref, |
|
|
const Eigen::MatrixXi & | W ) |
|
inline |
◆ get_cluster_stats()
| ClusterStats SpatialCache::get_cluster_stats |
( |
int | cluster | ) |
const |
|
inline |
Get cluster statistics for a specific cluster.
- Parameters
-
| cluster | Index of the cluster |
- Returns
- ClusterStats struct
◆ get_cluster_stats_ref()
| const ClusterStats & SpatialCache::get_cluster_stats_ref |
( |
int | cluster | ) |
const |
|
inline |
Get cluster statistics reference for a specific cluster.
- Parameters
-
| cluster | Index of the cluster |
- Returns
- Const reference to ClusterStats struct
◆ move_cluster_info()
| void SpatialCache::move_cluster_info |
( |
int | from_cluster, |
|
|
int | to_cluster ) |
|
inlineoverridevirtual |
Moves cluster information from one cluster to another.
- Parameters
-
| from_cluster | Index of the source cluster |
| to_cluster | Index of the target cluster |
Implements ClusterInfo.
◆ neighbor_cache_compute()
| void SpatialCache::neighbor_cache_compute |
( |
| ) |
|
|
private |
Precomputes and stores neighbor indices for all observations.
This method initializes neighbor_cache by extracting non-zero entries from each row of the adjacency matrix W. Called once during construction to enable O(neighbors) instead of O(N) lookup time.
◆ recompute()
| void SpatialCache::recompute |
( |
const int | K, |
|
|
const Eigen::VectorXi & | allocations_in ) |
|
overridevirtual |
Recomputes all cluster information from current allocations.
- Parameters
-
| K | Current number of clusters |
| allocations_in | Current allocations vector |
Implements ClusterInfo.
◆ remove_info()
| void SpatialCache::remove_info |
( |
int | cluster | ) |
|
|
inlineoverridevirtual |
Removes information related to a specific cluster.
- Parameters
-
| cluster | Index of the cluster to remove |
Implements ClusterInfo.
◆ set_allocation()
| void SpatialCache::set_allocation |
( |
int | index, |
|
|
int | cluster, |
|
|
int | old_cluster ) |
|
overridevirtual |
Assigns a point to a cluster.
- Parameters
-
| index | Index of the point to reassign |
| cluster | Target cluster index (K for new cluster, -1 for unallocated) |
| old_cluster | Previous cluster index of the point |
- Exceptions
-
| std::out_of_range | if index or cluster is invalid |
Implements ClusterInfo.
◆ set_allocation_ptr()
| void SpatialCache::set_allocation_ptr |
( |
const Eigen::VectorXi * | new_allocations | ) |
|
|
inline |
◆ allocations_ptr
| Eigen::VectorXi* SpatialCache::allocations_ptr |
|
private |
◆ cluster_stats
◆ neighbor_cache
| std::vector<std::vector<int> > SpatialCache::neighbor_cache |
| const Eigen::MatrixXi SpatialCache::W |
The documentation for this class was generated from the following files: