pub fn cmp_numeric<T: Numeric + Copy + 'static>(
lhs: &[T],
rhs: &[T],
mask: Option<&Bitmask>,
op: ComparisonOperator,
) -> Result<BooleanArray<()>, KernelError>Expand description
Unified numeric comparison dispatch with optional null mask support.
High-performance generic comparison function that dispatches to type-specific SIMD implementations based on runtime type identification. Supports all numeric types with optional null mask filtering and comprehensive error handling for mismatched lengths and unsupported types.
§Type Parameters
T: Numeric type implementingNumeric + Copy + 'static(i32, i64, u32, u64, f32, f64)
§Parameters
lhs: Left-hand side numeric slice for comparisonrhs: Right-hand side numeric slice for comparisonmask: Optional validity mask applied after comparison (AND operation)op: Comparison operator to apply (Equals, NotEquals, LessThan, etc.)
§Returns
Result<BooleanArray<()>, KernelError> containing comparison results or error details.
§Dispatch Strategy
Uses TypeId runtime checking to dispatch to optimal type-specific implementations:
i32/u32: 32-bit integer SIMD kernels with W32 lane configurationi64/u64: 64-bit integer SIMD kernels with W64 lane configurationf32/f64: IEEE 754 floating-point SIMD kernels with specialised NaN handling
§Error Conditions
KernelError::LengthMismatch: Input slices have different lengthsKernelError::InvalidArguments: Unsupported numeric type (unreachable in practice)
§Performance Benefits
- Zero-cost dispatch: Type resolution optimised away at compile time for monomorphic usage
- SIMD acceleration: Delegates to vectorised implementations for maximum throughput
- Memory efficiency: Optional mask processing avoids unnecessary allocations
§Example Usage
ⓘ
use simd_kernels::kernels::comparison::{cmp_numeric, ComparisonOperator};
let lhs = &[1i32, 2, 3, 4];
let rhs = &[1i32, 1, 4, 3];
let result = cmp_numeric(lhs, rhs, None, ComparisonOperator::Equals)?;
// Result: [true, false, false, false]