Module generic_algorithms

Module generic_algorithms 

Source
Expand description

Generic implementations of spatial algorithms

This module provides generic implementations of common spatial algorithms that can work with different numeric types and point representations. These algorithms leverage the traits defined in the generic_traits module to provide flexible, reusable implementations.

§Features

  • Generic KD-Tree: Works with any SpatialPoint implementation
  • Generic distance calculations: Support for different metrics and types
  • Generic convex hull: Templated hull algorithms
  • Generic clustering: K-means and other clustering algorithms
  • Type safety: Compile-time dimension and type checking where possible

§Examples

use scirs2_spatial::generic_algorithms::{GenericKDTree, GenericDistanceMatrix};
use scirs2_spatial::generic_traits::{Point, EuclideanMetric};

// Create points with different numeric types
let points_f32 = vec![
    Point::new_2d(1.0f32, 2.0f32),
    Point::new_2d(3.0f32, 4.0f32),
];

let points_f64 = vec![
    Point::new_2d(1.0f64, 2.0f64),
    Point::new_2d(3.0f64, 4.0f64),
];

// Both work with the same algorithm
let kdtree_f32 = GenericKDTree::new(&points_f32);
let kdtree_f64 = GenericKDTree::new(&points_f64);

Structs§

DBSCANResult
Result of DBSCAN clustering
GMMResult
Result of GMM fitting
GenericConvexHull
Generic convex hull computation using Graham scan
GenericDBSCAN
Generic DBSCAN clustering implementation
GenericDistanceMatrix
Generic distance matrix computation with SIMD optimizations
GenericGMM
Generic Gaussian Mixture Model clustering
GenericKDTree
Generic KD-Tree implementation with memory optimizations
GenericKMeans
Generic K-means clustering implementation
KMeansResult
Result of K-means clustering