Skip to content

Commit

Permalink
Merge pull request #5 from kambereBr/add_polynomial_functions
Browse files Browse the repository at this point in the history
Add polynomial eq, neq, is_zero, and leading_coefficient functions
  • Loading branch information
elielnfinic authored Mar 19, 2024
2 parents a812fa7 + 963856b commit bccce60
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions baby-stark/src/polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,28 @@ 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)
}

pub fn __neq__(self, other : Polynomial) -> bool{
!self.__eq__(other)
}

pub fn is_zero(self) -> bool{
if self.degree() == -1 {
return true;
}
return false;
}

pub fn leading_coefficient(self){
self.coeficients[self.degree()]
}
}

0 comments on commit bccce60

Please sign in to comment.