@@ -31,11 +31,24 @@ macro_rules! impl_shuffle_lane {
31
31
32
32
/// Interleave two vectors.
33
33
///
34
- /// The even lanes of the first result contain the lower half of `self`, and the odd
35
- /// lanes contain the lower half of `other`.
34
+ /// Produces two vectors with lanes taken alternately from `self` and `other`.
36
35
///
37
- /// The even lanes of the second result contain the upper half of `self`, and the odd
38
- /// lanes contain the upper half of `other`.
36
+ /// The first result contains the first `LANES / 2` lanes from `self` and `other`,
37
+ /// alternating, starting with the first lane of `self`.
38
+ ///
39
+ /// The second result contains the last `LANES / 2` lanes from `self` and `other`,
40
+ /// alternating, starting with the lane `LANES / 2` from the start of `self`.
41
+ ///
42
+ /// This particular permutation is efficient on many architectures.
43
+ ///
44
+ /// ```
45
+ /// # use core_simd::SimdU32;
46
+ /// let a = SimdU32::from_array([0, 1, 2, 3]);
47
+ /// let b = SimdU32::from_array([4, 5, 6, 7]);
48
+ /// let (x, y) = a.interleave(b);
49
+ /// assert_eq!(x.to_array(), [0, 4, 1, 5]);
50
+ /// assert_eq!(y.to_array(), [2, 6, 3, 7]);
51
+ /// ```
39
52
#[ inline]
40
53
pub fn interleave( self , other: Self ) -> ( Self , Self ) {
41
54
const fn lo( ) -> [ u32 ; $n] {
@@ -71,9 +84,22 @@ macro_rules! impl_shuffle_lane {
71
84
72
85
/// Deinterleave two vectors.
73
86
///
74
- /// The first result contains the even lanes of `self` and then `other`, concatenated.
87
+ /// The first result takes every other lane of `self` and then `other`, starting with
88
+ /// the first lane.
89
+ ///
90
+ /// The second result takes every other lane of `self` and then `other`, starting with
91
+ /// the second lane.
92
+ ///
93
+ /// This particular permutation is efficient on many architectures.
75
94
///
76
- /// The second result contains the odd lanes of `self` and then `other`, concatenated.
95
+ /// ```
96
+ /// # use core_simd::SimdU32;
97
+ /// let a = SimdU32::from_array([0, 4, 1, 5]);
98
+ /// let b = SimdU32::from_array([2, 6, 3, 7]);
99
+ /// let (x, y) = a.deinterleave(b);
100
+ /// assert_eq!(x.to_array(), [0, 1, 2, 3]);
101
+ /// assert_eq!(y.to_array(), [4, 5, 6, 7]);
102
+ /// ```
77
103
#[ inline]
78
104
pub fn deinterleave( self , other: Self ) -> ( Self , Self ) {
79
105
const fn even( ) -> [ u32 ; $n] {
0 commit comments