Expand description
§Standard Arithmetic Kernels Module - Scalar Fallback / Non-SIMD Implementations
Portable scalar implementations of arithmetic operations for compatibility and unaligned data.
Prefer dispatch.rs for easily handling the general case, otherwise you can use these inner functions directly (e.g., “dense_std”) vs. “maybe masked, maybe std”.
§Overview
- Scalar loops: Standard element-wise operations without vectorisation
- Fallback role: Used when SIMD alignment requirements aren’t met or SIMD is disabled
- Full compatibility: Works on any architecture regardless of SIMD support
- Null-aware: Supports Arrow-compatible null mask propagation
§Design Notes
- Intentionally avoids parallelisation to allow higher-level chunking strategies
- Wrapping arithmetic for integers to prevent overflow panics
- Division by zero handling: panics for integers, produces Inf/NaN for floats
Functions§
- float_
dense_ body_ std - Scalar floating-point arithmetic kernel for dense arrays (no nulls).
Division by zero produces Inf/NaN rather than panicking.
Power operations use logarithmic exponentiation:
exp(b * ln(a)). - float_
masked_ body_ std - Scalar floating-point arithmetic kernel with null mask support. Preserves IEEE 754 semantics: division by zero produces Inf/NaN, no panicking. Invalid inputs (mask=false) produce null outputs with zero values.
- fma_
dense_ body_ std - Dense fused multiply add (a * b + acc)
- fma_
masked_ body_ std - Fused multiply add (a * b + acc) with null mask
- int_
dense_ body_ std - Scalar integer arithmetic kernel for dense arrays (no nulls). Performs element-wise operations using wrapping arithmetic to prevent overflow panics. Panics on division/remainder by zero.
- int_
masked_ body_ std - Scalar integer arithmetic kernel with null mask support. Handles division by zero gracefully by marking results as null instead of panicking. Invalid inputs (mask=false) and zero division produce null outputs.