primitives/algebra/ops/
wide_ops.rs1pub trait IntoWide<T = Self> {
4 fn to_wide(&self) -> T;
6
7 fn zero_wide() -> T;
9}
10
11pub trait ReduceWide<T = Self> {
13 fn reduce_mod_order(a: T) -> Self;
14}
15
16pub trait MulAccReduce<Lhs = Self, Rhs = Self>:
19 IntoWide<Self::WideType> + ReduceWide<Self::WideType>
20{
21 type WideType;
22
23 fn mul_acc(acc: &mut Self::WideType, a: Lhs, b: Rhs);
24
25 #[inline]
26 fn to_wide(&self) -> Self::WideType {
27 <Self as IntoWide<Self::WideType>>::to_wide(self)
28 }
29
30 #[inline]
31 fn zero_wide() -> Self::WideType {
32 <Self as IntoWide<Self::WideType>>::zero_wide()
33 }
34}
35
36pub trait AccReduce<T = Self>: ReduceWide<Self::WideType> + IntoWide<Self::WideType> {
39 type WideType;
40
41 fn acc(acc: &mut Self::WideType, a: T);
42
43 #[inline]
44 fn to_wide(&self) -> Self::WideType {
45 <Self as IntoWide<Self::WideType>>::to_wide(self)
46 }
47
48 #[inline]
49 fn zero_wide() -> Self::WideType {
50 <Self as IntoWide<Self::WideType>>::zero_wide()
51 }
52}