Skip to content

Commit

Permalink
Implement Neg for FieldElement. (#2252)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth authored Dec 18, 2024
1 parent c8dcd07 commit a3d9f38
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions executor/src/witgen/jit/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit a3d9f38

Please sign in to comment.