Module generic_traits

Module generic_traits 

Source
Expand description

Generic traits and type parameters for spatial algorithms

This module provides generic traits that enable spatial algorithms to work with different numeric types and array structures. This improves API flexibility and allows for better integration with the broader Rust ecosystem.

§Features

  • Generic numeric types: Support for f32, f64, and other numeric types
  • Array ecosystem integration: Work with ndarray, nalgebra, and other array types
  • Iterator support: Process data from various sources efficiently
  • Dimension awareness: Compile-time and runtime dimension checking
  • Memory efficiency: Zero-copy operations where possible

§Examples

use scirs2_spatial::generic_traits::{SpatialScalar};
use scirs2_core::ndarray::array;

// Generic distance calculation (simplified example)
fn calculate_distance<T>(p1: &[T], p2: &[T]) -> T
where
    T: SpatialScalar,
{
    // Generic implementation (simplified)
    T::zero()
}

// Works with different array types
let point1 = array![1.0f32, 2.0f32, 3.0f32];
let point2 = array![4.0f32, 5.0f32, 6.0f32];
let _result = calculate_distance(point1.as_slice().unwrap(), point2.as_slice().unwrap());

Modules§

ndarray_integration
Integration with ndarray
utils
Utility functions for generic spatial operations

Structs§

ChebyshevMetric
Chebyshev distance metric
EuclideanMetric
Euclidean distance metric
ManhattanMetric
Manhattan distance metric
Point
Generic point structure for spatial algorithms

Traits§

DistanceMetric
Trait for distance metrics
SpatialArray
Trait for collections of spatial points
SpatialPoint
Trait for types that can represent a point in space
SpatialScalar
Trait for scalar types that can be used in spatial computations