Skip to main content

dot

Function dot 

Source
pub fn dot(a: &[f32], b: &[f32]) -> f32
Expand description

Dot product of two vectors: Σ(a[i] * b[i]).

Returns 0.0 for empty vectors.

§SIMD Acceleration

Automatically dispatches to (in order of preference):

  • AVX-512 on x86_64 (runtime detection, n >= 64)
  • AVX2+FMA on x86_64 (runtime detection, n >= 16)
  • NEON on aarch64 (always available, n >= 16)
  • Portable fallback otherwise

§Debug Assertions

In debug builds, panics if vector lengths differ. In release builds, mismatched lengths silently use the shorter length (for performance).

§Example

use innr::dot;

let a = [1.0_f32, 2.0, 3.0];
let b = [4.0_f32, 5.0, 6.0];
assert!((dot(&a, &b) - 32.0).abs() < 1e-6);