Skip to content

Commit

Permalink
Merge branch 'master' into fft_extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratyush committed Aug 26, 2024
2 parents 9a9b132 + 273bf21 commit 582c0f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions poly/src/polynomial/univariate/dense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ impl<F: FftField> DensePolynomial<F> {
pub fn divide_by_vanishing_poly<D: EvaluationDomain<F>>(
&self,
domain: D,
) -> Option<(DensePolynomial<F>, DensePolynomial<F>)> {
) -> (DensePolynomial<F>, DensePolynomial<F>) {
let domain_size = domain.size();

if self.coeffs.len() < domain_size {
// If degree(self) < len(Domain), then the quotient is zero, and the entire polynomial is the remainder
Some((DensePolynomial::<F>::zero(), self.clone()))
(DensePolynomial::<F>::zero(), self.clone())
} else {
// Compute the quotient
//
Expand Down Expand Up @@ -211,7 +211,7 @@ impl<F: FftField> DensePolynomial<F> {

let quotient = DensePolynomial::<F>::from_coefficients_vec(quotient_vec);
let remainder = DensePolynomial::<F>::from_coefficients_vec(remainder_vec);
Some((quotient, remainder))
(quotient, remainder)
}
}
}
Expand Down Expand Up @@ -936,7 +936,7 @@ mod tests {
let domain = GeneralEvaluationDomain::new(1 << size).unwrap();
for degree in 0..12 {
let p = DensePolynomial::<Fr>::rand(degree * 100, rng);
let (quotient, remainder) = p.divide_by_vanishing_poly(domain).unwrap();
let (quotient, remainder) = p.divide_by_vanishing_poly(domain);
let p_recovered = quotient.mul_by_vanishing_poly(domain) + remainder;
assert_eq!(p, p_recovered);
}
Expand Down
6 changes: 2 additions & 4 deletions poly/src/polynomial/univariate/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,7 @@ mod tests {

// Test interpolation works, by checking that interpolated polynomial agrees with the original on the domain
let (_q, r) = (dense_poly.clone() + -sparse_evals.interpolate())
.divide_by_vanishing_poly(domain)
.unwrap();
.divide_by_vanishing_poly(domain);
assert_eq!(
r,
DensePolynomial::<Fr>::zero(),
Expand All @@ -550,8 +549,7 @@ mod tests {

// Consistency check that the dense polynomials interpolation is correct.
let (_q, r) = (dense_poly.clone() + -dense_evals.interpolate())
.divide_by_vanishing_poly(domain)
.unwrap();
.divide_by_vanishing_poly(domain);
assert_eq!(
r,
DensePolynomial::<Fr>::zero(),
Expand Down

0 comments on commit 582c0f3

Please sign in to comment.