kdtree_simd/simd_euclidean/
f32x4.rs1use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
2
3define_ty!(F32x4, f32, f32, f32, f32);
4impl_minimal!(F32x4, f32, 4, x0, x1, x2, x3);
5
6impl F32x4 {
7 pub fn from_slice(slice: &[f32]) -> F32x4 {
8 assert!(slice.len() >= Self::lanes());
9 unsafe {
10 F32x4(
11 *slice.get_unchecked(0),
12 *slice.get_unchecked(1),
13 *slice.get_unchecked(2),
14 *slice.get_unchecked(3),
15 )
16 }
17 }
18
19 pub fn horizontal_add(self) -> f32 {
20 self.0 + self.1 + self.2 + self.3
21 }
22}
23
24impl_op4!(Mul, mul, F32x4, *);
25impl_op4!(assn MulAssign, mul_assign, F32x4, *=);
26impl_op4!(Div, div, F32x4, /);
27impl_op4!(assn DivAssign, div_assign, F32x4, /=);
28impl_op4!(Add, add, F32x4, +);
29impl_op4!(assn AddAssign, add_assign, F32x4, +=);
30impl_op4!(Sub, sub, F32x4, -);
31impl_op4!(assn SubAssign, sub_assign, F32x4, -=);
32
33impl_euclidean!(F32x4, f32);