Clusterer¶
-
template<std::size_t Ndim, std::floating_point DataType = float>
class Clusterer¶ The Clusterer class is the interface for running the clustering algorithm. It provides methods to set up the clustering parameters, initializes the internal buffers and runs the clustering algorithm on host or device points.
- Template Parameters:¶
Public Functions¶
-
Clusterer(value_type density_radius, value_type min_density, std::optional<value_type> outlier_distance = std::nullopt, std::optional<value_type> seeding_distance = std::nullopt, int pPBin = 128)¶
Constuct a Clusterer object.
- Parameters:¶
- value_type density_radius¶
Distance threshold for clustering.
- value_type min_density¶
Density threshold for clustering
- std::optional<value_type> outlier_distance = std::nullopt¶
Minimum distance between clusters. This parameter is optional and by default density_radius is used.
- std::optional<value_type> seeding_distance = std::nullopt¶
Distance threshold for seed points. This parameter is optional and by default dc is used.
- int pPBin = 128¶
Number of points per bin, used to determine the tile size
-
Clusterer(Queue &queue, value_type density_radius, value_type min_density, std::optional<value_type> outlier_distance = std::nullopt, std::optional<value_type> seeding_distance = std::nullopt, int pPBin = 128)¶
Constuct a Clusterer object.
- Parameters:¶
- Queue &queue¶
The queue to use for the device operations
- value_type density_radius¶
Distance threshold for clustering.
- value_type min_density¶
Density threshold for clustering
- std::optional<value_type> outlier_distance = std::nullopt¶
Minimum distance between clusters. This parameter is optional and by default density_radius is used.
- std::optional<value_type> seeding_distance = std::nullopt¶
Distance threshold for seed points. This parameter is optional and by default dc is used.
- int pPBin = 128¶
Number of points per bin, used to determine the tile size
-
void setParameters(value_type density_radius, value_type min_density, std::optional<value_type> outlier_distance = std::nullopt, std::optional<value_type> seeding_distance = std::nullopt, int pPBin = 128)¶
Set the parameters for the clustering algorithm.
- Parameters:¶
- value_type density_radius¶
Distance threshold for clustering
- value_type min_density¶
Density threshold for clustering
- std::optional<value_type> outlier_distance = std::nullopt¶
Minimum distance between clusters. This parameter is optional and by default density_radius is used.
- std::optional<value_type> seeding_distance = std::nullopt¶
Distance threshold for seed points. This parameter is optional and by default dc is used.
- int pPBin = 128¶
Number of points per bin, used to determine the tile size
-
template<std::floating_point InputType, concepts::convolutional_kernel Kernel = FlatKernel<>, concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>>
void make_clusters(Queue &queue, clue::PointsHost<Ndim, InputType> &h_points, const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}, const Kernel &kernel = FlatKernel<>{.5f}, std::size_t block_size = 256)¶ Construct the clusters from host points.
- Template Parameters:¶
- std::floating_point InputType¶
The data type of the input points, which must be a floating-point type. By default, it is set to
float.- concepts::convolutional_kernel Kernel = FlatKernel<>¶
The type of convolutional kernel to use
- concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>¶
The type of distance metric to use
- Parameters:¶
- Queue &queue¶
The queue to use for the device operations
- clue::PointsHost<Ndim, InputType> &h_points¶
Host points to cluster
- const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}¶
The distance metric to use for clustering, default is EuclideanMetric
- const Kernel &kernel = FlatKernel<>{.5f}¶
The convolutional kernel to use for computing the local densities, default is FlatKernel with height 0.5
- std::size_t block_size = 256¶
The size of the blocks to use for clustering, default is 256
-
template<std::floating_point InputType, concepts::convolutional_kernel Kernel = FlatKernel<>, concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>>
void make_clusters(clue::PointsHost<Ndim, InputType> &h_points, const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}, const Kernel &kernel = FlatKernel<>{.5f}, std::size_t block_size = 256)¶ Construct the clusters from host points.
Note
This method creates a temporary queue for the operations on the device
- Template Parameters:¶
- std::floating_point InputType¶
The data type of the input points, which must be a floating-point type. By default, it is set to
float.- concepts::convolutional_kernel Kernel = FlatKernel<>¶
The type of convolutional kernel to use
- concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>¶
The type of distance metric to use
- Parameters:¶
- clue::PointsHost<Ndim, InputType> &h_points¶
Host points to cluster
- const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}¶
The distance metric to use for clustering, default is EuclideanMetric
- const Kernel &kernel = FlatKernel<>{.5f}¶
The convolutional kernel to use for computing the local densities, default is FlatKernel with height 0.5
- std::size_t block_size = 256¶
The size of the blocks to use for clustering, default is 256
-
template<std::floating_point InputType, concepts::convolutional_kernel Kernel = FlatKernel<>, concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>>
void make_clusters(Queue &queue, clue::PointsHost<Ndim, InputType> &h_points, clue::PointsDevice<Ndim, value_type> &dev_points, const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}, const Kernel &kernel = FlatKernel<>{.5f}, std::size_t block_size = 256)¶ Construct the clusters from host and device points.
- Template Parameters:¶
- std::floating_point InputType¶
The data type of the input points, which must be a floating-point type. By default, it is set to
float.- concepts::convolutional_kernel Kernel = FlatKernel<>¶
The type of convolutional kernel to use
- concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>¶
The type of distance metric to use
- Parameters:¶
- Queue &queue¶
The queue to use for the device operations
- clue::PointsHost<Ndim, InputType> &h_points¶
Host points to cluster
- clue::PointsDevice<Ndim, value_type> &dev_points¶
Device points to cluster
- const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}¶
The distance metric to use for clustering, default is EuclideanMetric
- const Kernel &kernel = FlatKernel<>{.5f}¶
The convolutional kernel to use for computing the local densities, default is FlatKernel with height 0.5
- std::size_t block_size = 256¶
The size of the blocks to use for clustering, default is 256
-
template<std::floating_point InputType, concepts::convolutional_kernel Kernel = FlatKernel<>, concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>>
void make_clusters(Queue &queue, clue::PointsDevice<Ndim, InputType> &dev_points, const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}, const Kernel &kernel = FlatKernel<>{.5f}, std::size_t block_size = 256)¶ Construct the clusters from device points.
- Template Parameters:¶
- std::floating_point InputType¶
The data type of the input points, which must be a floating-point type. By default, it is set to
float.- concepts::convolutional_kernel Kernel = FlatKernel<>¶
The type of convolutional kernel to use
- concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>¶
The type of distance metric to use
- Parameters:¶
- Queue &queue¶
The queue to use for the device operations
- clue::PointsDevice<Ndim, InputType> &dev_points¶
Device points to cluster
- const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}¶
The distance metric to use for clustering, default is EuclideanMetric
- const Kernel &kernel = FlatKernel<>{.5f}¶
The convolutional kernel to use for computing the local densities, default is FlatKernel with height 0.5
- std::size_t block_size = 256¶
The size of the blocks to use for clustering, default is 256
-
template<std::floating_point InputType, concepts::convolutional_kernel Kernel = FlatKernel<>, concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>>
void make_clusters(Queue &queue, clue::PointsHost<Ndim, InputType> &h_points, clue::PointsDevice<Ndim, value_type> &dev_points, std::span<const uint32_t> batch_item_sizes, const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}, const Kernel &kernel = FlatKernel<>{.5f}, std::size_t block_size = 256)¶ Construct the clusters from batched host and device points.
Note
The total size of h_points and dev_points must be equal to the sum of batch_item_sizes
- Template Parameters:¶
- std::floating_point InputType¶
The data type of the input points, which must be a floating-point type. By default, it is set to
float.- concepts::convolutional_kernel Kernel = FlatKernel<>¶
The type of convolutional kernel to use
- concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>¶
The type of distance metric to use
- Parameters:¶
- Queue &queue¶
The queue to use for the device operations
- clue::PointsHost<Ndim, InputType> &h_points¶
Host points to cluster
- clue::PointsDevice<Ndim, value_type> &dev_points¶
Device points to cluster
- std::span<const uint32_t> batch_item_sizes¶
Sizes of each batch item
- const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}¶
The distance metric to use for clustering, default is EuclideanMetric
- const Kernel &kernel = FlatKernel<>{.5f}¶
The convolutional kernel to use for computing the local densities, default is FlatKernel with height 0.5
- std::size_t block_size = 256¶
The size of the blocks to use for clustering, default is 256
-
template<std::floating_point InputType, concepts::convolutional_kernel Kernel = FlatKernel<>, concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>>
void make_clusters(Queue &queue, clue::PointsDevice<Ndim, InputType> &dev_points, std::span<const uint32_t> batch_item_sizes, const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}, const Kernel &kernel = FlatKernel<>{.5f}, std::size_t block_size = 256)¶ Construct the clusters from batched device points.
Note
The total size of h_points and dev_points must be equal to the sum of batch_item_sizes
- Template Parameters:¶
- std::floating_point InputType¶
The data type of the input points, which must be a floating-point type. By default, it is set to
float.- concepts::convolutional_kernel Kernel = FlatKernel<>¶
The type of convolutional kernel to use
- concepts::distance_metric<Ndim> DistanceMetric = clue::EuclideanMetric<Ndim, value_type>¶
The type of distance metric to use
- Parameters:¶
- Queue &queue¶
The queue to use for the device operations
- clue::PointsDevice<Ndim, InputType> &dev_points¶
Device points to cluster
- std::span<const uint32_t> batch_item_sizes¶
Sizes of each batch item
- const DistanceMetric &metric = clue::EuclideanMetric<Ndim, value_type>{}¶
The distance metric to use for clustering, default is EuclideanMetric
- const Kernel &kernel = FlatKernel<>{.5f}¶
The convolutional kernel to use for computing the local densities, default is FlatKernel with height 0.5
- std::size_t block_size = 256¶
The size of the blocks to use for clustering, default is 256
-
template<std::ranges::contiguous_range TRange>
void setWrappedCoordinates(const TRange &wrapped_coordinates)¶ Specify which coordinates are periodic.
- Parameters:¶
- wrappedCoordinates
Array of wrapped coordinates, where 1 means periodic and 0 means non-periodic
-
template<std::integral... TArgs>
void setWrappedCoordinates(TArgs... wrapped_coordinates)¶ Specify which coordinates are periodic.
-
std::span<const int32_t> getSeeds() const¶
Get the list of seeds found in the last clustering run.
Note
The values of this array are overwritten at each clustering run
- Returns:¶
A span the the device array containing the seed indices
-
template<std::floating_point InputType>
AssociationMapHost getClusters(const clue::PointsHost<Ndim, InputType> &h_points)¶ Get the clusters from the host points.
-
template<std::floating_point InputType>
AssociationMap<Device> getClusters(Queue &queue, const clue::PointsDevice<Ndim, InputType> &d_points)¶ Get the clusters from the device points This function returns an associator object mapping the clusters to the points they contain.
-
template<std::floating_point InputType>
AssociationMapHost getSampleAssociations(Queue &queue, clue::PointsHost<Ndim, InputType> &h_points)¶ Get the sample-to-cluster associations for batched clustering.
-
template<std::floating_point InputType>
AssociationMap<Device> getSampleAssociations(Queue &queue, clue::PointsDevice<Ndim, InputType> &d_points)¶ Get the sample-to-cluster associations for batched clustering.