From 43baa04fd5c6ad1237a7c0e4ec6a0bcaf74f0c60 Mon Sep 17 00:00:00 2001 From: Bruno Kambere Date: Mon, 18 Mar 2024 21:05:31 +0200 Subject: [PATCH 1/4] Add __eq__ method to Polynomial class --- baby-stark/src/polynomial.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/baby-stark/src/polynomial.rs b/baby-stark/src/polynomial.rs index da6184f..410f235 100644 --- a/baby-stark/src/polynomial.rs +++ b/baby-stark/src/polynomial.rs @@ -56,5 +56,15 @@ impl Polynomial { } + pub fn __eq__(self, other : Polynomial) -> bool{ + if self.degree() != other.degree() { + return false; + } + if self.degree() == -1 { + return true; + } + self.coeficients.iter().zip(other.coeficients.iter()).all(|(a, b)| a == b) + } + } From f82c4f19ec06ac9964f32151772a154726144851 Mon Sep 17 00:00:00 2001 From: Bruno Kambere Date: Mon, 18 Mar 2024 21:05:48 +0200 Subject: [PATCH 2/4] Add inequality method to Polynomial --- baby-stark/src/polynomial.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/baby-stark/src/polynomial.rs b/baby-stark/src/polynomial.rs index 410f235..89b5023 100644 --- a/baby-stark/src/polynomial.rs +++ b/baby-stark/src/polynomial.rs @@ -66,5 +66,11 @@ impl Polynomial { self.coeficients.iter().zip(other.coeficients.iter()).all(|(a, b)| a == b) } + pub fn __neq__(self, other : Polynomial) -> bool{ + !self.__eq__(other) + } + + + } From 1ab514056e9e407f1a6842773c8cb18651ea4d3e Mon Sep 17 00:00:00 2001 From: Bruno Kambere Date: Mon, 18 Mar 2024 21:06:08 +0200 Subject: [PATCH 3/4] Add is_zero method to Polynomial --- baby-stark/src/polynomial.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/baby-stark/src/polynomial.rs b/baby-stark/src/polynomial.rs index 89b5023..99d5148 100644 --- a/baby-stark/src/polynomial.rs +++ b/baby-stark/src/polynomial.rs @@ -70,6 +70,14 @@ impl Polynomial { !self.__eq__(other) } + pub fn __is_zero__(self) -> bool{ + if self.degree() == -1 { + return true; + } + return false; + } + + From 963856bdfd779594cfe39df903d0b069699526db Mon Sep 17 00:00:00 2001 From: Bruno Kambere Date: Mon, 18 Mar 2024 21:06:31 +0200 Subject: [PATCH 4/4] Add leading_coefficient method in Polynomial --- baby-stark/src/polynomial.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/baby-stark/src/polynomial.rs b/baby-stark/src/polynomial.rs index 99d5148..a79eeda 100644 --- a/baby-stark/src/polynomial.rs +++ b/baby-stark/src/polynomial.rs @@ -70,15 +70,14 @@ impl Polynomial { !self.__eq__(other) } - pub fn __is_zero__(self) -> bool{ + pub fn is_zero(self) -> bool{ if self.degree() == -1 { return true; } return false; } - - - - + pub fn leading_coefficient(self){ + self.coeficients[self.degree()] + } }