scirs2_core/simd/
traits.rs

1//! SIMD trait definitions for type constraints
2//!
3//! This module defines the core `SimdOps` trait that enables SIMD operations
4//! on numeric types throughout the scirs2-core library.
5
6use num_traits::Float;
7use std::ops::{Add, Div, Mul, Sub};
8
9/// Trait for types that can be processed with SIMD operations
10///
11/// This trait provides the basic constraints required for types to participate
12/// in SIMD-accelerated numerical computations. Currently implemented for `f32` and `f64`.
13///
14/// # Examples
15///
16/// ```ignore
17/// use scirs2_core::simd::traits::SimdOps;
18///
19/// fn process_simd<T: SimdOps>(data: &[T]) {
20///     // SIMD operations can be safely performed on T
21/// }
22/// ```
23pub trait SimdOps:
24    Copy
25    + PartialOrd
26    + Add<Output = Self>
27    + Sub<Output = Self>
28    + Mul<Output = Self>
29    + Div<Output = Self>
30{
31}
32
33impl SimdOps for f32 {}
34impl SimdOps for f64 {}