Improve function names and docs
This commit is contained in:
parent
e2fa502617
commit
e127586709
2 changed files with 35 additions and 32 deletions
|
|
@ -4,45 +4,48 @@ macro_rules! impl_integer_reductions {
|
|||
where
|
||||
Self: crate::LanesAtMost32
|
||||
{
|
||||
/// Produces the sum of the lanes of the vector, with wrapping addition.
|
||||
/// Horizontal wrapping add. Computes the sum of the lanes of the vector, with wrapping addition.
|
||||
#[inline]
|
||||
pub fn wrapping_sum(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_add_ordered(self, 0) }
|
||||
}
|
||||
|
||||
/// Produces the sum of the lanes of the vector, with wrapping multiplication.
|
||||
/// Horizontal wrapping multiply. Computes the product of the lanes of the vector, with wrapping multiplication.
|
||||
#[inline]
|
||||
pub fn wrapping_product(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_mul_ordered(self, 1) }
|
||||
}
|
||||
|
||||
/// Sequentially performs bitwise "and" between the lanes of the vector.
|
||||
/// Horizontal bitwise "and". Computes the cumulative bitwise "and" across the lanes of
|
||||
/// the vector.
|
||||
#[inline]
|
||||
pub fn and_lanes(self) -> $scalar {
|
||||
pub fn horizontal_and(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_and(self) }
|
||||
}
|
||||
|
||||
/// Sequentially performs bitwise "or" between the lanes of the vector.
|
||||
/// Horizontal bitwise "or". Computes the cumulative bitwise "or" across the lanes of
|
||||
/// the vector.
|
||||
#[inline]
|
||||
pub fn or_lanes(self) -> $scalar {
|
||||
pub fn horizontal_or(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_or(self) }
|
||||
}
|
||||
|
||||
/// Sequentially performs bitwise "xor" between the lanes of the vector.
|
||||
/// Horizontal bitwise "xor". Computes the cumulative bitwise "xor" across the lanes of
|
||||
/// the vector.
|
||||
#[inline]
|
||||
pub fn xor_lanes(self) -> $scalar {
|
||||
pub fn horizontal_xor(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_xor(self) }
|
||||
}
|
||||
|
||||
/// Returns the maximum lane in the vector.
|
||||
/// Horizontal maximum. Computes the maximum lane in the vector.
|
||||
#[inline]
|
||||
pub fn max_lane(self) -> $scalar {
|
||||
pub fn horizontal_max(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_max(self) }
|
||||
}
|
||||
|
||||
/// Returns the minimum lane in the vector.
|
||||
/// Horizontal minimum. Computes the minimum lane in the vector.
|
||||
#[inline]
|
||||
pub fn min_lane(self) -> $scalar {
|
||||
pub fn horizontal_min(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_min(self) }
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +59,7 @@ macro_rules! impl_float_reductions {
|
|||
Self: crate::LanesAtMost32
|
||||
{
|
||||
|
||||
/// Produces the sum of the lanes of the vector.
|
||||
/// Horizontal add. Computes the sum of the lanes of the vector.
|
||||
#[inline]
|
||||
pub fn sum(self) -> $scalar {
|
||||
// LLVM sum is inaccurate on i586
|
||||
|
|
@ -67,7 +70,7 @@ macro_rules! impl_float_reductions {
|
|||
}
|
||||
}
|
||||
|
||||
/// Produces the sum of the lanes of the vector.
|
||||
/// Horizontal multiply. Computes the sum of the lanes of the vector.
|
||||
#[inline]
|
||||
pub fn product(self) -> $scalar {
|
||||
// LLVM product is inaccurate on i586
|
||||
|
|
@ -78,21 +81,21 @@ macro_rules! impl_float_reductions {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the maximum lane in the vector.
|
||||
/// Horizontal maximum. Computes the maximum lane in the vector.
|
||||
///
|
||||
/// Returns values based on equality, so a vector containing both `0.` and `-0.` may
|
||||
/// return either. This function will not return `NaN` unless all lanes are `NaN`.
|
||||
#[inline]
|
||||
pub fn max_lane(self) -> $scalar {
|
||||
pub fn horizontal_max(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_max(self) }
|
||||
}
|
||||
|
||||
/// Returns the minimum lane in the vector.
|
||||
/// Horizontal minimum. Computes the minimum lane in the vector.
|
||||
///
|
||||
/// Returns values based on equality, so a vector containing both `0.` and `-0.` may
|
||||
/// return either. This function will not return `NaN` unless all lanes are `NaN`.
|
||||
#[inline]
|
||||
pub fn min_lane(self) -> $scalar {
|
||||
pub fn horizontal_min(self) -> $scalar {
|
||||
unsafe { crate::intrinsics::simd_reduce_min(self) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,50 +160,50 @@ macro_rules! impl_common_integer_tests {
|
|||
});
|
||||
}
|
||||
|
||||
fn and_lanes<const LANES: usize>() {
|
||||
fn horizontal_and<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
test_helpers::prop_assert_biteq! (
|
||||
$vector::<LANES>::from_array(x).and_lanes(),
|
||||
$vector::<LANES>::from_array(x).horizontal_and(),
|
||||
x.iter().copied().fold(-1i8 as $scalar, <$scalar as core::ops::BitAnd>::bitand),
|
||||
);
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
fn or_lanes<const LANES: usize>() {
|
||||
fn horizontal_or<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
test_helpers::prop_assert_biteq! (
|
||||
$vector::<LANES>::from_array(x).or_lanes(),
|
||||
$vector::<LANES>::from_array(x).horizontal_or(),
|
||||
x.iter().copied().fold(0 as $scalar, <$scalar as core::ops::BitOr>::bitor),
|
||||
);
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
fn xor_lanes<const LANES: usize>() {
|
||||
fn horizontal_xor<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
test_helpers::prop_assert_biteq! (
|
||||
$vector::<LANES>::from_array(x).xor_lanes(),
|
||||
$vector::<LANES>::from_array(x).horizontal_xor(),
|
||||
x.iter().copied().fold(0 as $scalar, <$scalar as core::ops::BitXor>::bitxor),
|
||||
);
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
fn max_lane<const LANES: usize>() {
|
||||
fn horizontal_max<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
test_helpers::prop_assert_biteq! (
|
||||
$vector::<LANES>::from_array(x).max_lane(),
|
||||
$vector::<LANES>::from_array(x).horizontal_max(),
|
||||
x.iter().copied().max().unwrap(),
|
||||
);
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
fn min_lane<const LANES: usize>() {
|
||||
fn horizontal_min<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
test_helpers::prop_assert_biteq! (
|
||||
$vector::<LANES>::from_array(x).min_lane(),
|
||||
$vector::<LANES>::from_array(x).horizontal_min(),
|
||||
x.iter().copied().min().unwrap(),
|
||||
);
|
||||
Ok(())
|
||||
|
|
@ -499,9 +499,9 @@ macro_rules! impl_float_tests {
|
|||
});
|
||||
}
|
||||
|
||||
fn max_lane<const LANES: usize>() {
|
||||
fn horizontal_max<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
let vmax = Vector::<LANES>::from_array(x).max_lane();
|
||||
let vmax = Vector::<LANES>::from_array(x).horizontal_max();
|
||||
let smax = x.iter().copied().fold(Scalar::NAN, Scalar::max);
|
||||
// 0 and -0 are treated the same
|
||||
if !(x.contains(&0.) && x.contains(&-0.) && vmax.abs() == 0. && smax.abs() == 0.) {
|
||||
|
|
@ -511,9 +511,9 @@ macro_rules! impl_float_tests {
|
|||
});
|
||||
}
|
||||
|
||||
fn min_lane<const LANES: usize>() {
|
||||
fn horizontal_min<const LANES: usize>() {
|
||||
test_helpers::test_1(&|x| {
|
||||
let vmax = Vector::<LANES>::from_array(x).min_lane();
|
||||
let vmax = Vector::<LANES>::from_array(x).horizontal_min();
|
||||
let smax = x.iter().copied().fold(Scalar::NAN, Scalar::min);
|
||||
// 0 and -0 are treated the same
|
||||
if !(x.contains(&0.) && x.contains(&-0.) && vmax.abs() == 0. && smax.abs() == 0.) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue