From 8c4c4bc0c603bc4c0a2b900064cea45b3d07b9d3 Mon Sep 17 00:00:00 2001 From: Cesar199999 Date: Tue, 25 Jun 2024 16:12:24 +0200 Subject: [PATCH 1/2] Impl sub, mul and div for actual objects --- poly/src/polynomial/univariate/dense.rs | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/poly/src/polynomial/univariate/dense.rs b/poly/src/polynomial/univariate/dense.rs index 1df019d58..f9cec676f 100644 --- a/poly/src/polynomial/univariate/dense.rs +++ b/poly/src/polynomial/univariate/dense.rs @@ -487,6 +487,15 @@ impl<'a, 'b, F: Field> Sub<&'a DensePolynomial> for &'b DensePolynomial { } } +impl Sub> for DensePolynomial { + type Output = DensePolynomial; + + #[inline] + fn sub(self, other: DensePolynomial) -> DensePolynomial { + &self - &other + } +} + impl<'a, 'b, F: Field> Sub<&'a SparsePolynomial> for &'b DensePolynomial { type Output = DensePolynomial; @@ -584,6 +593,15 @@ impl<'a, 'b, F: Field> Div<&'a DensePolynomial> for &'b DensePolynomial { } } +impl Div> for DensePolynomial { + type Output = DensePolynomial; + + #[inline] + fn div(self, divisor: DensePolynomial) -> DensePolynomial { + &self / &divisor + } +} + impl<'b, F: Field> Mul for &'b DensePolynomial { type Output = DensePolynomial; @@ -620,6 +638,15 @@ impl<'a, 'b, F: FftField> Mul<&'a DensePolynomial> for &'b DensePolynomial } } +impl Mul> for DensePolynomial { + type Output = DensePolynomial; + + #[inline] + fn mul(self, other: DensePolynomial) -> DensePolynomial { + &self * &other + } +} + impl Zero for DensePolynomial { /// Returns the zero polynomial. fn zero() -> Self { From 399264ef54dea8893365dd7738ebd96d251756c5 Mon Sep 17 00:00:00 2001 From: Cesar199999 Date: Wed, 26 Jun 2024 09:33:01 +0200 Subject: [PATCH 2/2] Add non-reference scalar multiplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Antonio Mejías Gil --- poly/src/polynomial/univariate/dense.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/poly/src/polynomial/univariate/dense.rs b/poly/src/polynomial/univariate/dense.rs index f9cec676f..3dfd3dfeb 100644 --- a/poly/src/polynomial/univariate/dense.rs +++ b/poly/src/polynomial/univariate/dense.rs @@ -619,6 +619,15 @@ impl<'b, F: Field> Mul for &'b DensePolynomial { } } +impl Mul for DensePolynomial { + type Output = DensePolynomial; + + #[inline] + fn mul(self, elem: F) -> DensePolynomial { + &self * elem + } +} + /// Performs O(nlogn) multiplication of polynomials if F is smooth. impl<'a, 'b, F: FftField> Mul<&'a DensePolynomial> for &'b DensePolynomial { type Output = DensePolynomial;