entrenar/optim/simd/axpy.rs
1//! Fused AXPY operation (KAIZEN-026)
2//!
3//! Single-pass y = a*x + y with zero temporary allocations.
4
5/// AXPY operation: y = a*x + y
6///
7/// Single-pass fused loop, auto-vectorized by the compiler.
8///
9/// # Arguments
10/// * `a` - Scalar coefficient
11/// * `x` - Input vector (typically gradient or momentum)
12/// * `y` - Output vector (updated in-place)
13pub fn simd_axpy(a: f32, x: &[f32], y: &mut [f32]) {
14 assert_eq!(x.len(), y.len(), "Vector lengths must match");
15
16 for i in 0..x.len() {
17 y[i] += a * x[i];
18 }
19}