binius_field/arch/portable/
underlier_constants.rs1use super::packed_arithmetic::{
4 interleave_mask_even, interleave_mask_odd, UnderlierWithBitConstants,
5};
6use crate::underlier::{UnderlierType, U1, U2, U4};
7
8impl UnderlierWithBitConstants for U1 {
9 const INTERLEAVE_EVEN_MASK: &'static [Self] = &[];
10
11 const INTERLEAVE_ODD_MASK: &'static [Self] = &[];
12}
13
14impl UnderlierWithBitConstants for U2 {
15 const INTERLEAVE_EVEN_MASK: &'static [Self] = &[Self::new(interleave_mask_even!(u8, 0))];
16
17 const INTERLEAVE_ODD_MASK: &'static [Self] = &[Self::new(interleave_mask_odd!(u8, 0))];
18}
19
20impl UnderlierWithBitConstants for U4 {
21 const INTERLEAVE_EVEN_MASK: &'static [Self] = &[
22 Self::new(interleave_mask_even!(u8, 0)),
23 Self::new(interleave_mask_even!(u8, 1)),
24 ];
25
26 const INTERLEAVE_ODD_MASK: &'static [Self] = &[
27 Self::new(interleave_mask_odd!(u8, 0)),
28 Self::new(interleave_mask_odd!(u8, 1)),
29 ];
30}
31
32impl UnderlierWithBitConstants for u8 {
33 const INTERLEAVE_EVEN_MASK: &'static [Self] = &[
34 interleave_mask_even!(Self, 0),
35 interleave_mask_even!(Self, 1),
36 interleave_mask_even!(Self, 2),
37 ];
38
39 const INTERLEAVE_ODD_MASK: &'static [Self] = &[
40 interleave_mask_odd!(Self, 0),
41 interleave_mask_odd!(Self, 1),
42 interleave_mask_odd!(Self, 2),
43 ];
44}
45
46impl UnderlierWithBitConstants for u16 {
47 const INTERLEAVE_EVEN_MASK: &'static [Self] = &[
48 interleave_mask_even!(Self, 0),
49 interleave_mask_even!(Self, 1),
50 interleave_mask_even!(Self, 2),
51 interleave_mask_even!(Self, 3),
52 ];
53
54 const INTERLEAVE_ODD_MASK: &'static [Self] = &[
55 interleave_mask_odd!(Self, 0),
56 interleave_mask_odd!(Self, 1),
57 interleave_mask_odd!(Self, 2),
58 interleave_mask_odd!(Self, 3),
59 ];
60}
61
62impl UnderlierWithBitConstants for u32 {
63 const INTERLEAVE_EVEN_MASK: &'static [Self] = &[
64 interleave_mask_even!(Self, 0),
65 interleave_mask_even!(Self, 1),
66 interleave_mask_even!(Self, 2),
67 interleave_mask_even!(Self, 3),
68 interleave_mask_even!(Self, 4),
69 ];
70
71 const INTERLEAVE_ODD_MASK: &'static [Self] = &[
72 interleave_mask_odd!(Self, 0),
73 interleave_mask_odd!(Self, 1),
74 interleave_mask_odd!(Self, 2),
75 interleave_mask_odd!(Self, 3),
76 interleave_mask_odd!(Self, 4),
77 ];
78}
79
80impl UnderlierWithBitConstants for u64 {
81 const INTERLEAVE_EVEN_MASK: &'static [Self] = &[
82 interleave_mask_even!(Self, 0),
83 interleave_mask_even!(Self, 1),
84 interleave_mask_even!(Self, 2),
85 interleave_mask_even!(Self, 3),
86 interleave_mask_even!(Self, 4),
87 interleave_mask_even!(Self, 5),
88 ];
89
90 const INTERLEAVE_ODD_MASK: &'static [Self] = &[
91 interleave_mask_odd!(Self, 0),
92 interleave_mask_odd!(Self, 1),
93 interleave_mask_odd!(Self, 2),
94 interleave_mask_odd!(Self, 3),
95 interleave_mask_odd!(Self, 4),
96 interleave_mask_odd!(Self, 5),
97 ];
98}
99
100impl UnderlierWithBitConstants for u128 {
101 const INTERLEAVE_EVEN_MASK: &'static [Self] = &[
102 interleave_mask_even!(Self, 0),
103 interleave_mask_even!(Self, 1),
104 interleave_mask_even!(Self, 2),
105 interleave_mask_even!(Self, 3),
106 interleave_mask_even!(Self, 4),
107 interleave_mask_even!(Self, 5),
108 interleave_mask_even!(Self, 6),
109 ];
110
111 const INTERLEAVE_ODD_MASK: &'static [Self] = &[
112 interleave_mask_odd!(Self, 0),
113 interleave_mask_odd!(Self, 1),
114 interleave_mask_odd!(Self, 2),
115 interleave_mask_odd!(Self, 3),
116 interleave_mask_odd!(Self, 4),
117 interleave_mask_odd!(Self, 5),
118 interleave_mask_odd!(Self, 6),
119 ];
120}