Skip to content

Commit

Permalink
Impl sub, mul and div for actual objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Cesar199999 committed Jun 25, 2024
1 parent 5a781ae commit 8c4c4bc
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions poly/src/polynomial/univariate/dense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,15 @@ impl<'a, 'b, F: Field> Sub<&'a DensePolynomial<F>> for &'b DensePolynomial<F> {
}
}

impl<F: Field> Sub<DensePolynomial<F>> for DensePolynomial<F> {
type Output = DensePolynomial<F>;

#[inline]
fn sub(self, other: DensePolynomial<F>) -> DensePolynomial<F> {
&self - &other
}
}

impl<'a, 'b, F: Field> Sub<&'a SparsePolynomial<F>> for &'b DensePolynomial<F> {
type Output = DensePolynomial<F>;

Expand Down Expand Up @@ -584,6 +593,15 @@ impl<'a, 'b, F: Field> Div<&'a DensePolynomial<F>> for &'b DensePolynomial<F> {
}
}

impl<F: Field> Div<DensePolynomial<F>> for DensePolynomial<F> {
type Output = DensePolynomial<F>;

#[inline]
fn div(self, divisor: DensePolynomial<F>) -> DensePolynomial<F> {
&self / &divisor
}
}

impl<'b, F: Field> Mul<F> for &'b DensePolynomial<F> {
type Output = DensePolynomial<F>;

Expand Down Expand Up @@ -620,6 +638,15 @@ impl<'a, 'b, F: FftField> Mul<&'a DensePolynomial<F>> for &'b DensePolynomial<F>
}
}

impl<F: FftField> Mul<DensePolynomial<F>> for DensePolynomial<F> {
type Output = DensePolynomial<F>;

#[inline]
fn mul(self, other: DensePolynomial<F>) -> DensePolynomial<F> {
&self * &other
}
}

impl<F: Field> Zero for DensePolynomial<F> {
/// Returns the zero polynomial.
fn zero() -> Self {
Expand Down

0 comments on commit 8c4c4bc

Please sign in to comment.