Rename sum, product to horizontal_{sum,product}
This commit is contained in:
parent
01d78aa21a
commit
828b274ae7
2 changed files with 12 additions and 12 deletions
|
@ -6,13 +6,13 @@ macro_rules! impl_integer_reductions {
|
|||
{
|
||||
/// Horizontal wrapping add. Returns the sum of the lanes of the vector, with wrapping addition.
|
||||
#[inline]
|
||||
pub fn wrapping_sum(self) -> $scalar {
|
||||
pub fn horizontal_wrapping_sum(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_add_ordered(self, 0) }
|
||||
}
|
||||
|
||||
/// Horizontal wrapping multiply. Returns the product of the lanes of the vector, with wrapping multiplication.
|
||||
#[inline]
|
||||
pub fn wrapping_product(self) -> $scalar {
|
||||
pub fn horizontal_wrapping_product(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_mul_ordered(self, 1) }
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ macro_rules! impl_float_reductions {
|
|||
|
||||
/// Horizontal add. Returns the sum of the lanes of the vector.
|
||||
#[inline]
|
||||
pub fn sum(self) -> $scalar {
|
||||
pub fn horizontal_sum(self) -> $scalar {
|
||||
// LLVM sum is inaccurate on i586
|
||||
if cfg!(all(target_arch = "x86", not(target_feature = "sse2"))) {
|
||||
self.as_slice().iter().sum()
|
||||
|
@ -72,7 +72,7 @@ macro_rules! impl_float_reductions {
|
|||
|
||||
/// Horizontal multiply. Returns the product of the lanes of the vector.
|
||||
#[inline]
|
||||
pub fn product(self) -> $scalar {
|
||||
pub fn horizontal_product(self) -> $scalar {
|
||||
// LLVM product is inaccurate on i586
|
||||
if cfg!(all(target_arch = "x86", not(target_feature = "sse2"))) {
|
||||
self.as_slice().iter().product()
|
||||
|
|
|
@ -140,20 +140,20 @@ macro_rules! impl_binary_checked_op_test {
|
|||
macro_rules! impl_common_integer_tests {
|
||||
{ $vector:ident, $scalar:ident } => {
|
||||
test_helpers::test_lanes! {
|
||||
fn wrapping_sum<const LANES: usize>() {
|
||||
fn horizontal_wrapping_sum<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
test_helpers::prop_assert_biteq! (
|
||||
$vector::<LANES>::from_array(x).wrapping_sum(),
|
||||
$vector::<LANES>::from_array(x).horizontal_wrapping_sum(),
|
||||
x.iter().copied().fold(0 as $scalar, $scalar::wrapping_add),
|
||||
);
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
fn wrapping_product<const LANES: usize>() {
|
||||
fn horizontal_wrapping_product<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
test_helpers::prop_assert_biteq! (
|
||||
$vector::<LANES>::from_array(x).wrapping_product(),
|
||||
$vector::<LANES>::from_array(x).horizontal_wrapping_product(),
|
||||
x.iter().copied().fold(1 as $scalar, $scalar::wrapping_mul),
|
||||
);
|
||||
Ok(())
|
||||
|
@ -479,20 +479,20 @@ macro_rules! impl_float_tests {
|
|||
).unwrap();
|
||||
}
|
||||
|
||||
fn sum<const LANES: usize>() {
|
||||
fn horizontal_sum<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
test_helpers::prop_assert_biteq! (
|
||||
Vector::<LANES>::from_array(x).sum(),
|
||||
Vector::<LANES>::from_array(x).horizontal_sum(),
|
||||
x.iter().sum(),
|
||||
);
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
fn product<const LANES: usize>() {
|
||||
fn horizontal_product<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
test_helpers::prop_assert_biteq! (
|
||||
Vector::<LANES>::from_array(x).product(),
|
||||
Vector::<LANES>::from_array(x).horizontal_product(),
|
||||
x.iter().product(),
|
||||
);
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue