Cluster centroids

Provides functions for computing the centroids of clusters.

Authors

Simone Balducci, Felice Pantaleo, Marco Rovere, Wahid Redjeb, Aurora Perego, Francesco Giacomini

namespace clue

Typedefs

template<std::size_t Ndim, std::floating_point TData = float>
using Centroid = std::array<TData, Ndim>

Type alias for a centroid in Ndim dimensions.

Template Parameters:
std::size_t Ndim

The number of dimensions of the centroids

std::floating_point TData = float

The data type for the centroid coordinates

template<std::size_t Ndim, std::floating_point TData = float>
using Centroids = std::vector<Centroid<Ndim, TData>>

Type alias for a collection of centroids in Ndim dimensions.

Template Parameters:
std::size_t Ndim

The number of dimensions of the Centroids

std::floating_point TData = float

The data type for the centroid coordinates

Functions

template<std::size_t Ndim, std::floating_point TData = float>
inline Centroid<Ndim, TData> cluster_centroid(const clue::PointsHost<Ndim, TData> &points, std::size_t cluster_id)

Compute the centroid of a specific cluster from the given Points.

Template Parameters:
std::size_t Ndim

The number of dimensions of the points

std::floating_point TData = float

The data type for the point coordinates

Parameters:
const clue::PointsHost<Ndim, TData> &points

The PointsHost object containing the points

std::size_t cluster_id

The ID of the cluster for which to compute the centroid

Returns:

The centroid of the specified cluster as an array of floating points

template<std::size_t Ndim, std::floating_point TData = float>
inline Centroids<Ndim, TData> cluster_centroids(const clue::PointsHost<Ndim, TData> &points)

Compute the centroids of all clusters from the given Points.

Template Parameters:
std::size_t Ndim

The number of dimensions of the points

std::floating_point TData = float

The data type for the point coordinates

Parameters:
const clue::PointsHost<Ndim, TData> &points

The PointsHost object containing the points

Returns:

A vector of centroids, one for each cluster