binius_field/arch/portable/
packed_4.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, PairwiseRecursiveStrategy, PairwiseStrategy, 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, U4},
15 BinaryField1b, BinaryField2b, BinaryField4b,
16};
17
18pub type PackedBinaryField4x1b = PackedPrimitiveType<U4, BinaryField1b>;
20pub type PackedBinaryField2x2b = PackedPrimitiveType<U4, BinaryField2b>;
21pub type PackedBinaryField1x4b = PackedPrimitiveType<U4, BinaryField4b>;
22
23impl_broadcast!(U4, BinaryField1b);
25impl_broadcast!(U4, BinaryField2b);
26impl_broadcast!(U4, BinaryField4b);
27
28impl_ops_for_zero_height!(PackedBinaryField4x1b);
30
31impl TowerConstants<U4> for BinaryField1b {
33 const ALPHAS_ODD: U4 = U4::new(<Self as TowerConstants<u8>>::ALPHAS_ODD);
34}
35impl TowerConstants<U4> for BinaryField2b {
36 const ALPHAS_ODD: U4 = U4::new(<Self as TowerConstants<u8>>::ALPHAS_ODD);
37}
38impl TowerConstants<U4> for BinaryField4b {
39 const ALPHAS_ODD: U4 = U4::new(<Self as TowerConstants<u8>>::ALPHAS_ODD);
40}
41
42impl_mul_with!(PackedBinaryField2x2b @ PackedStrategy);
44impl_mul_with!(PackedBinaryField1x4b @ PackedStrategy);
45
46impl_square_with!(PackedBinaryField2x2b @ PackedStrategy);
48impl_square_with!(PackedBinaryField1x4b @ ReuseMultiplyStrategy);
49
50impl_invert_with!(PackedBinaryField2x2b @ PairwiseRecursiveStrategy);
52impl_invert_with!(PackedBinaryField1x4b @ PairwiseRecursiveStrategy);
53
54impl_mul_alpha_with!(PackedBinaryField2x2b @ PackedStrategy);
56impl_mul_alpha_with!(PackedBinaryField1x4b @ ReuseMultiplyStrategy);
57
58impl Alpha for PackedBinaryField1x4b {
59 #[inline]
60 fn alpha() -> Self {
61 Self::from_underlier(U4::new_unchecked(0x04))
62 }
63}
64
65impl_transformation_with_strategy!(PackedBinaryField4x1b, PackedStrategy);
67impl_transformation_with_strategy!(PackedBinaryField2x2b, PackedStrategy);
68impl_transformation_with_strategy!(PackedBinaryField1x4b, PairwiseStrategy);