Skip to content

Commit 273bf21

Browse files
davxyweikengchen
andauthored
Infallible div vanishing poly (#850)
Co-authored-by: Weikeng Chen <w.k@berkeley.edu>
1 parent dcf73a5 commit 273bf21

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

poly/src/polynomial/univariate/dense.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ impl<F: FftField> DensePolynomial<F> {
170170
pub fn divide_by_vanishing_poly<D: EvaluationDomain<F>>(
171171
&self,
172172
domain: D,
173-
) -> Option<(DensePolynomial<F>, DensePolynomial<F>)> {
173+
) -> (DensePolynomial<F>, DensePolynomial<F>) {
174174
let domain_size = domain.size();
175175

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

212212
let quotient = DensePolynomial::<F>::from_coefficients_vec(quotient_vec);
213213
let remainder = DensePolynomial::<F>::from_coefficients_vec(remainder_vec);
214-
Some((quotient, remainder))
214+
(quotient, remainder)
215215
}
216216
}
217217
}
@@ -936,7 +936,7 @@ mod tests {
936936
let domain = GeneralEvaluationDomain::new(1 << size).unwrap();
937937
for degree in 0..12 {
938938
let p = DensePolynomial::<Fr>::rand(degree * 100, rng);
939-
let (quotient, remainder) = p.divide_by_vanishing_poly(domain).unwrap();
939+
let (quotient, remainder) = p.divide_by_vanishing_poly(domain);
940940
let p_recovered = quotient.mul_by_vanishing_poly(domain) + remainder;
941941
assert_eq!(p, p_recovered);
942942
}

poly/src/polynomial/univariate/sparse.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,7 @@ mod tests {
538538

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

551550
// Consistency check that the dense polynomials interpolation is correct.
552551
let (_q, r) = (dense_poly.clone() + -dense_evals.interpolate())
553-
.divide_by_vanishing_poly(domain)
554-
.unwrap();
552+
.divide_by_vanishing_poly(domain);
555553
assert_eq!(
556554
r,
557555
DensePolynomial::<Fr>::zero(),

0 commit comments

Comments
 (0)