1 use crate::simd::{LaneCount, Simd, SupportedLaneCount};
7 macro_rules! impl_traits {
9 impl<const LANES: usize> Sum<Self> for Simd<$type, LANES>
11 LaneCount<LANES>: SupportedLaneCount,
13 fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
14 iter.fold(Simd::splat(0 as $type), Add::add)
18 impl<const LANES: usize> Product<Self> for Simd<$type, LANES>
20 LaneCount<LANES>: SupportedLaneCount,
22 fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
23 iter.fold(Simd::splat(1 as $type), Mul::mul)
27 impl<'a, const LANES: usize> Sum<&'a Self> for Simd<$type, LANES>
29 LaneCount<LANES>: SupportedLaneCount,
31 fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self {
32 iter.fold(Simd::splat(0 as $type), Add::add)
36 impl<'a, const LANES: usize> Product<&'a Self> for Simd<$type, LANES>
38 LaneCount<LANES>: SupportedLaneCount,
40 fn product<I: Iterator<Item = &'a Self>>(iter: I) -> Self {
41 iter.fold(Simd::splat(1 as $type), Mul::mul)
53 impl_traits! { usize }
58 impl_traits! { isize }