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 ValueType = float>
using Centroid = std::array<ValueType, 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 ValueType = float

The data type for the centroid coordinates

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

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 ValueType = float

The data type for the centroid coordinates

Functions

template<std::size_t Ndim, std::floating_point ValueType = float>
inline Centroid<Ndim, ValueType> cluster_centroid(const clue::PointsHost<Ndim, ValueType> &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 ValueType = float

The data type for the point coordinates

Parameters:
const clue::PointsHost<Ndim, ValueType> &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 ValueType = float>
inline Centroid<Ndim, ValueType> weighted_cluster_centroid(const clue::PointsHost<Ndim, ValueType> &points, std::size_t cluster_id)

Compute the weighted 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 ValueType = float

The data type for the point coordinates and weights

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

The PointsHost object containing the points

std::size_t cluster_id

The ID of the cluster for which to compute the weighted centroid

Returns:

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

template<std::size_t Ndim, std::floating_point ValueType = float>
inline Centroids<Ndim, ValueType> cluster_centroids(const clue::PointsHost<Ndim, ValueType> &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 ValueType = float

The data type for the point coordinates

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

The PointsHost object containing the points

Returns:

A vector of centroids, one for each cluster

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

Compute the weighted centroids of all clusters from the given Points.

Template Parameters:
std::size_t Ndim

The number of dimensions of the points

std::floating_point ValueType = float

The data type for the point coordinates and weights

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

The PointsHost object containing the points

Returns:

A vector of weighted centroids, one for each cluster