binius_field/arch/portable/
packed_2.rs1use super::{
4 packed::{impl_broadcast, impl_ops_for_zero_height, PackedPrimitiveType},
5 packed_arithmetic::TowerConstants,
6 reuse_multiply_arithmetic::Alpha,
7};
8use crate::{
9 arch::{PackedStrategy, PairwiseStrategy, PairwiseTableStrategy, ReuseMultiplyStrategy},
10 arithmetic_traits::{
11 impl_invert_with, impl_mul_alpha_with, impl_mul_with, impl_square_with,
12 impl_transformation_with_strategy,
13 },
14 underlier::{UnderlierType, U2},
15 BinaryField1b, BinaryField2b,
16};
17
18pub type PackedBinaryField2x1b = PackedPrimitiveType<U2, BinaryField1b>;
20pub type PackedBinaryField1x2b = PackedPrimitiveType<U2, BinaryField2b>;
21
22impl_broadcast!(U2, BinaryField1b);
24impl_broadcast!(U2, BinaryField2b);
25
26impl_ops_for_zero_height!(PackedBinaryField2x1b);
28
29impl TowerConstants<U2> for BinaryField1b {
31 const ALPHAS_ODD: U2 = U2::new(<Self as TowerConstants<u8>>::ALPHAS_ODD);
32}
33impl TowerConstants<U2> for BinaryField2b {
34 const ALPHAS_ODD: U2 = U2::new(<Self as TowerConstants<u8>>::ALPHAS_ODD);
35}
36
37impl_mul_with!(PackedBinaryField1x2b @ PairwiseTableStrategy);
39
40impl_square_with!(PackedBinaryField1x2b @ ReuseMultiplyStrategy);
42
43impl_invert_with!(PackedBinaryField1x2b @ PairwiseTableStrategy);
45
46impl_mul_alpha_with!(PackedBinaryField1x2b @ ReuseMultiplyStrategy);
48
49impl Alpha for PackedBinaryField1x2b {
50 #[inline]
51 fn alpha() -> Self {
52 Self::from_underlier(U2::new_unchecked(0x02))
53 }
54}
55
56impl_transformation_with_strategy!(PackedBinaryField2x1b, PackedStrategy);
58impl_transformation_with_strategy!(PackedBinaryField1x2b, PairwiseStrategy);