use std::ops::{Add, AddAssign, Div, Mul, Sub, SubAssign}; use std::simd::prelude::*; #[derive(Copy, Clone, Eq, PartialEq, Debug, Default)] #[allow(non_camel_case_types)] pub struct u32xN(pub Simd); impl Add for u32xN { type Output = Self; fn add(self, rhs: Self) -> Self::Output { Self(self.0 + rhs.0) } } impl Sub for u32xN { type Output = Self; fn sub(self, rhs: Self) -> Self::Output { Self(self.0 - rhs.0) } } impl AddAssign for u32xN { fn add_assign(&mut self, rhs: Self) { self.0 += rhs.0; } } impl SubAssign for u32xN { fn sub_assign(&mut self, rhs: Self) { self.0 -= rhs.0; } } impl Mul for u32xN { type Output = Self; fn mul(self, rhs: usize) -> Self::Output { Self(self.0 * Simd::::splat(rhs as u32)) } } impl Div for u32xN { type Output = Self; fn div(self, rhs: usize) -> Self::Output { Self(Simd::::from_array( self.0.to_array().map(|e| (e as usize / rhs) as u32), )) } }