spatialrust_gpu/kernels/
euclidean_cluster.rs1use spatialrust_core::{SpatialError, SpatialResult, TransferStats};
2
3pub use spatialrust_search::euclidean_cluster_roots as euclidean_cluster_roots_grid;
4
5pub fn euclidean_cluster_roots_gpu_with_receipt(
10 runtime: &crate::runtime::WgpuRuntime,
11 x: &[f32],
12 y: &[f32],
13 z: &[f32],
14 cluster_tolerance: f32,
15) -> SpatialResult<(Vec<u32>, TransferStats)> {
16 if x.len() != y.len() || x.len() != z.len() {
17 return Err(SpatialError::InvalidArgument("xyz arrays must have equal length".to_owned()));
18 }
19 if cluster_tolerance <= 0.0 || cluster_tolerance.is_nan() {
20 return Err(SpatialError::InvalidArgument("cluster_tolerance must be positive".to_owned()));
21 }
22 if x.is_empty() {
23 return Ok((Vec::new(), TransferStats::default()));
24 }
25
26 super::cluster_union::run(runtime, x, y, z, cluster_tolerance)
27}
28
29pub fn euclidean_cluster_roots_gpu(
32 runtime: &crate::runtime::WgpuRuntime,
33 x: &[f32],
34 y: &[f32],
35 z: &[f32],
36 cluster_tolerance: f32,
37) -> SpatialResult<Vec<u32>> {
38 euclidean_cluster_roots_gpu_with_receipt(runtime, x, y, z, cluster_tolerance)
39 .map(|(roots, _)| roots)
40}