use super::{SimdF32x4, SimdF32x8, SimdF64x4};
#[allow(dead_code)] #[derive(Clone, Copy)]
pub(crate) struct F64x4Scalar([f64; 4]);
impl SimdF64x4 for F64x4Scalar {
#[inline]
fn splat(x: f64) -> Self {
F64x4Scalar([x; 4])
}
#[inline]
fn load_unaligned(src: &[f64; 4]) -> Self {
F64x4Scalar(*src)
}
#[inline]
fn store_unaligned(self, dst: &mut [f64; 4]) {
*dst = self.0;
}
#[inline]
fn add(self, r: Self) -> Self {
F64x4Scalar([
self.0[0] + r.0[0],
self.0[1] + r.0[1],
self.0[2] + r.0[2],
self.0[3] + r.0[3],
])
}
#[inline]
fn sub(self, r: Self) -> Self {
F64x4Scalar([
self.0[0] - r.0[0],
self.0[1] - r.0[1],
self.0[2] - r.0[2],
self.0[3] - r.0[3],
])
}
#[inline]
fn mul(self, r: Self) -> Self {
F64x4Scalar([
self.0[0] * r.0[0],
self.0[1] * r.0[1],
self.0[2] * r.0[2],
self.0[3] * r.0[3],
])
}
#[inline]
fn horizontal_sum(self) -> f64 {
((self.0[0] + self.0[1]) + self.0[2]) + self.0[3]
}
}
#[allow(dead_code)] #[derive(Clone, Copy)]
pub(crate) struct F32x8Scalar([f32; 8]);
impl SimdF32x8 for F32x8Scalar {
#[inline]
fn splat(x: f32) -> Self {
F32x8Scalar([x; 8])
}
#[inline]
fn load_unaligned(src: &[f32; 8]) -> Self {
F32x8Scalar(*src)
}
#[inline]
fn store_unaligned(self, dst: &mut [f32; 8]) {
*dst = self.0;
}
#[inline]
fn add(self, r: Self) -> Self {
F32x8Scalar([
self.0[0] + r.0[0], self.0[1] + r.0[1],
self.0[2] + r.0[2], self.0[3] + r.0[3],
self.0[4] + r.0[4], self.0[5] + r.0[5],
self.0[6] + r.0[6], self.0[7] + r.0[7],
])
}
#[inline]
fn sub(self, r: Self) -> Self {
F32x8Scalar([
self.0[0] - r.0[0], self.0[1] - r.0[1],
self.0[2] - r.0[2], self.0[3] - r.0[3],
self.0[4] - r.0[4], self.0[5] - r.0[5],
self.0[6] - r.0[6], self.0[7] - r.0[7],
])
}
#[inline]
fn mul(self, r: Self) -> Self {
F32x8Scalar([
self.0[0] * r.0[0], self.0[1] * r.0[1],
self.0[2] * r.0[2], self.0[3] * r.0[3],
self.0[4] * r.0[4], self.0[5] * r.0[5],
self.0[6] * r.0[6], self.0[7] * r.0[7],
])
}
#[inline]
fn horizontal_sum(self) -> f32 {
let lo = (self.0[0] + self.0[1]) + (self.0[2] + self.0[3]);
let hi = (self.0[4] + self.0[5]) + (self.0[6] + self.0[7]);
lo + hi
}
}
#[allow(dead_code)] #[derive(Clone, Copy)]
pub(crate) struct F32x4Scalar([f32; 4]);
impl SimdF32x4 for F32x4Scalar {
#[inline]
fn splat(x: f32) -> Self {
F32x4Scalar([x; 4])
}
#[inline]
fn load_unaligned(src: &[f32; 4]) -> Self {
F32x4Scalar(*src)
}
#[inline]
fn store_unaligned(self, dst: &mut [f32; 4]) {
*dst = self.0;
}
#[inline]
fn add(self, r: Self) -> Self {
F32x4Scalar([
self.0[0] + r.0[0], self.0[1] + r.0[1],
self.0[2] + r.0[2], self.0[3] + r.0[3],
])
}
#[inline]
fn sub(self, r: Self) -> Self {
F32x4Scalar([
self.0[0] - r.0[0], self.0[1] - r.0[1],
self.0[2] - r.0[2], self.0[3] - r.0[3],
])
}
#[inline]
fn mul(self, r: Self) -> Self {
F32x4Scalar([
self.0[0] * r.0[0], self.0[1] * r.0[1],
self.0[2] * r.0[2], self.0[3] * r.0[3],
])
}
#[inline]
fn horizontal_sum(self) -> f32 {
((self.0[0] + self.0[1]) + self.0[2]) + self.0[3]
}
}