mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-04-20 03:03:25 -04:00
Implement Neg for FieldElement. (#2252)
This commit is contained in:
@@ -368,6 +368,17 @@ impl std::ops::Sub for FieldElement {{
|
||||
Self(IntType::try_from(((self.0 as DoubleIntType) + (MODULUS as DoubleIntType) - (b.0 as DoubleIntType)) % (MODULUS as DoubleIntType)).unwrap())
|
||||
}}
|
||||
}}
|
||||
impl std::ops::Neg for FieldElement {{
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn neg(self) -> Self {{
|
||||
if self.0 == 0 {{
|
||||
self
|
||||
}} else {{
|
||||
Self(MODULUS - self.0)
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
impl std::ops::Mul<FieldElement> for FieldElement {{
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
|
||||
Reference in New Issue
Block a user