]> git.lizzy.rs Git - rust.git/commitdiff
add doctests for shuffle (#130)
authorMiguel Raz Guzmán Macedo <miguelraz@ciencias.unam.mx>
Fri, 11 Jun 2021 22:48:44 +0000 (17:48 -0500)
committerGitHub <noreply@github.com>
Fri, 11 Jun 2021 22:48:44 +0000 (15:48 -0700)
* add shuffle doctests/examples

crates/core_simd/src/permute.rs

index dd63c69c63db7d9e591445f1e8f9e6d43d265cc9..a64fdbc9dd0a5d98f901437e40f4659069e1f987 100644 (file)
@@ -9,6 +9,15 @@ impl $name<$n> {
             /// Some SIMD shuffle instructions can be quite slow, so avoiding them by loading data
             /// into the desired patterns in advance is preferred, but shuffles are still faster
             /// than storing and reloading from memory.
+            ///
+            /// ```
+            /// # use core_simd::*;
+            // let a = f32x4::from_array([1.0, 2.0, 3.0, 4.0]);
+            // let b = f32x4::from_array([5.0, 6.0, 7.0, 8.0]);
+            // const IDXS: [u32; 4] = [4,0,3,7];
+            // let c = f32x4::shuffle::<IDXS>(a,b);
+            // assert_eq!(f32x4::from_array([5.0, 1.0, 4.0, 8.0]), c);
+            /// ```
             #[inline]
             pub fn shuffle<const IDX: [u32; $n]>(self, second: Self) -> Self {
                 unsafe { crate::intrinsics::$fn(self, second, IDX) }