2021-06-13 12:52:44 -05:00
|
|
|
macro_rules! impl_traits {
|
2021-06-21 16:08:26 -05:00
|
|
|
{ $type:ident } => {
|
2021-06-13 12:52:44 -05:00
|
|
|
impl<const LANES: usize> core::iter::Sum<Self> for crate::$type<LANES>
|
|
|
|
where
|
2021-06-24 22:34:10 -05:00
|
|
|
Self: crate::Vector,
|
2021-06-13 12:52:44 -05:00
|
|
|
{
|
|
|
|
fn sum<I: core::iter::Iterator<Item = Self>>(iter: I) -> Self {
|
|
|
|
iter.fold(Default::default(), core::ops::Add::add)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<const LANES: usize> core::iter::Product<Self> for crate::$type<LANES>
|
|
|
|
where
|
2021-06-24 22:34:10 -05:00
|
|
|
Self: crate::Vector,
|
2021-06-13 12:52:44 -05:00
|
|
|
{
|
|
|
|
fn product<I: core::iter::Iterator<Item = Self>>(iter: I) -> Self {
|
|
|
|
iter.fold(Default::default(), core::ops::Mul::mul)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-13 13:00:47 -05:00
|
|
|
impl<'a, const LANES: usize> core::iter::Sum<&'a Self> for crate::$type<LANES>
|
|
|
|
where
|
2021-06-24 22:34:10 -05:00
|
|
|
Self: crate::Vector,
|
2021-06-13 13:00:47 -05:00
|
|
|
{
|
|
|
|
fn sum<I: core::iter::Iterator<Item = &'a Self>>(iter: I) -> Self {
|
|
|
|
iter.fold(Default::default(), core::ops::Add::add)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, const LANES: usize> core::iter::Product<&'a Self> for crate::$type<LANES>
|
|
|
|
where
|
2021-06-24 22:34:10 -05:00
|
|
|
Self: crate::Vector,
|
2021-06-13 13:00:47 -05:00
|
|
|
{
|
|
|
|
fn product<I: core::iter::Iterator<Item = &'a Self>>(iter: I) -> Self {
|
|
|
|
iter.fold(Default::default(), core::ops::Mul::mul)
|
|
|
|
}
|
|
|
|
}
|
2021-06-13 12:52:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-21 16:08:26 -05:00
|
|
|
impl_traits! { SimdF32 }
|
|
|
|
impl_traits! { SimdF64 }
|
|
|
|
impl_traits! { SimdU8 }
|
|
|
|
impl_traits! { SimdU16 }
|
|
|
|
impl_traits! { SimdU32 }
|
|
|
|
impl_traits! { SimdU64 }
|
|
|
|
impl_traits! { SimdUsize }
|
|
|
|
impl_traits! { SimdI8 }
|
|
|
|
impl_traits! { SimdI16 }
|
|
|
|
impl_traits! { SimdI32 }
|
|
|
|
impl_traits! { SimdI64 }
|
|
|
|
impl_traits! { SimdIsize }
|