Skip to content

Commit 2ad4d1d

Browse files
committed
chore: impl suggestion
1 parent d3e5e18 commit 2ad4d1d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

crates/math/benches/polynomials/polynomial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn polynomial_benchmarks(c: &mut Criterion) {
5151
group.bench_function("fast_mul big poly", |bench| {
5252
bench.iter(|| {
5353
black_box(&x_poly)
54-
.fast_multiplication::<Degree2ExtensionField>(black_box(&y_poly))
54+
.fast_fft_multiplication::<Degree2ExtensionField>(black_box(&y_poly))
5555
.unwrap()
5656
});
5757
});

crates/math/src/fft/polynomial.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ impl<E: IsField> Polynomial<FieldElement<E>> {
100100
Ok(scaled.scale(&offset.inv().unwrap()))
101101
}
102102

103-
pub fn fast_multiplication<F: IsFFTField + IsSubFieldOf<E>>(
103+
/// Multiplies two polynomials using FFT.
104+
/// It's faster than naive multiplication when the degree of the polynomials is large enough (>=2**6).
105+
/// This works best with polynomials whose highest degree is equal to a power of 2 - 1.
106+
/// Will return an error if the degree of the resulting polynomial is greater than 2**63.
107+
pub fn fast_fft_multiplication<F: IsFFTField + IsSubFieldOf<E>>(
104108
&self,
105109
other: &Self,
106110
) -> Result<Self, FFTError> {
@@ -330,7 +334,7 @@ mod tests {
330334

331335
#[test]
332336
fn test_fft_multiplication_works(poly in poly(7), other in poly(7)) {
333-
prop_assert_eq!(poly.fast_multiplication::<F>(&other).unwrap(), poly * other);
337+
prop_assert_eq!(poly.fast_fft_multiplication::<F>(&other).unwrap(), poly * other);
334338
}
335339
}
336340

@@ -430,7 +434,7 @@ mod tests {
430434

431435
#[test]
432436
fn test_fft_multiplication_works(poly in poly(7), other in poly(7)) {
433-
prop_assert_eq!(poly.fast_multiplication::<F>(&other).unwrap(), poly * other);
437+
prop_assert_eq!(poly.fast_fft_multiplication::<F>(&other).unwrap(), poly * other);
434438
}
435439
}
436440
}

0 commit comments

Comments
 (0)