Skip to content

Commit

Permalink
Add multiplication function
Browse files Browse the repository at this point in the history
  • Loading branch information
WilfriedM01 committed Mar 18, 2024
1 parent 5453622 commit 2c53ece
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions baby-stark/src/polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,16 @@ impl Polynomial {
self.__add__(other.__neg__())
}

pub fn __mul__(self, other : Polynomial) -> Polynomial{
let field = self.coeficients.get(0).unwrap().field;
let zero = field.zero();
let mut coeffs = vec![zero; self.coeficients.len() + other.coeficients.len() - 1];
for i in 0..self.coeficients.len() {
for j in 0..other.coeficients.len() {
coeffs[i+j] = coeffs[i+j].__add__(self.coeficients[i].__mul__(other.coeficients[j]));
}
}
Polynomial::from(coeffs)
}

}

0 comments on commit 2c53ece

Please sign in to comment.