use fearless_simd::{Level, dispatch, f32x4, f32x16, f64x2, prelude::*};
#[inline(always)] fn apply_gain<S: Simd, V: SimdFloat<S>>(samples: V, gain: V::Element) -> V {
samples * gain
}
fn main() {
let level = Level::new();
dispatch!(level, simd => {
let samples = f32x4::from_slice(simd, &[0.1, -0.2, 0.3, -0.4]);
let output = apply_gain(samples, 0.5);
println!("f32x4: {output:?}");
let samples = f32x16::from_slice(
simd,
&[
0.1, -0.2, 0.3, -0.4, 0.5, -0.6, 0.7, -0.8,
0.9, -1.0, 1.1, -1.2, 1.3, -1.4, 1.5, -1.6,
],
);
let output = apply_gain(samples, 0.5);
println!("f32x16: {output:?}");
let samples = f64x2::from_slice(simd, &[0.1, -0.2]);
let output = apply_gain(samples, 0.5);
println!("f64x2: {output:?}");
});
}