liamappelbe / fftea

A simple and efficient FFT implementation for Dart
Apache License 2.0
63 stars 1 forks source link

`primePaddingHeuristic` is inefficient #35

Closed liamappelbe closed 1 year ago

liamappelbe commented 1 year ago

primePaddingHeuristic is built on largestPrimeFactor, but that function is overkill. We don't care what the largest prime factor is, just whether it's larger than 5. Write a new function that returns a bool of whether the number's largest prime factor is larger than some threshold: largestPrimeFactorIsLargerThan(n, p). This function can bail early if it divides out all the prime factors below that limit, but the number still hasn't been reduced to 1.