]> git.lizzy.rs Git - rust.git/commitdiff
Improve function names and docs
authorCaleb Zulawski <caleb.zulawski@gmail.com>
Sun, 11 Apr 2021 14:59:05 +0000 (10:59 -0400)
committerCaleb Zulawski <caleb.zulawski@gmail.com>
Sun, 11 Apr 2021 14:59:05 +0000 (10:59 -0400)
crates/core_simd/src/reduction.rs
crates/core_simd/tests/ops_macros.rs

index a2b652189c84af0489504966580a100846c27d33..e728f8ad82a90a3827539a07c08a76003862660c 100644 (file)
@@ -4,45 +4,48 @@ impl<const LANES: usize> crate::$name<LANES>
         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 @@ impl<const LANES: usize> crate::$name<LANES>
             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 @@ pub fn sum(self) -> $scalar {
                 }
             }
 
-            /// 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 @@ pub fn product(self) -> $scalar {
                 }
             }
 
-            /// 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) }
             }
         }
index 59e923ac5c14ee29759559b66638cca78d26f877..7ce85b77254af65ce585652db39304a831d93c0e 100644 (file)
@@ -160,50 +160,50 @@ fn wrapping_product<const LANES: usize>() {
                 });
             }
 
-            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 @@ fn product<const LANES: usize>() {
                     });
                 }
 
-                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 @@ fn max_lane<const LANES: usize>() {
                     });
                 }
 
-                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.) {