- Notifications
You must be signed in to change notification settings - Fork31
Description
The currentpolynomial multiplication has a runtime of O(n^2). This is fine for some cases (especially lower degree polynomials), but is suboptimal, as it is relatively easy to reduce the runtime using aFast Fourier Transformation to O(n log n). This would be a considerable speedup for higher degree polynomials.
I think it would be best to perhaps use the currrent algorithm for polynomials of low degree, as it is undoubtedly faster for these kinds, but for higher degree polynomials switch to the more complex, but asymptotically faster FFT. The switching point should of course be determined by the implementation details.
If this is something worth considering, I think there would be three ways to go about using this method:
- Use an existing FFT crate which is significantly faster than what would be used in this crate, which in turn significantly improve the runtime of many things using polynomials.
- Create a custom implementation of the FFT algorithm. This would mean that the crate has less dependencies, and would therefore be more portable.
- You could also possibly use a feature flag to indicate use of an external FFT library, which would include the best of both worlds: It would allow for people who need an efficient implementation to use the external library for the multiplication, and those who care more about portability to use the slower version.
If you think that the second option sounds appealing, I would be willing to write an implementation of the algorithm.