diff --git a/image_analysis/indexing/FFTIndexer.cpp b/image_analysis/indexing/FFTIndexer.cpp index cd76beb53..e895689b4 100644 --- a/image_analysis/indexing/FFTIndexer.cpp +++ b/image_analysis/indexing/FFTIndexer.cpp @@ -35,7 +35,18 @@ FFTIndexer::FFTIndexer(const IndexingSettings &settings) const float one_over_d_max = 1.0f / settings.GetFFT_HighResolution_A(); histogram_spacing = 1.0f / (2.0f * max_length_A); + // Then zero-padded a little further, to the next length whose prime factors are all 2, 3, 5 or 7: + // the default (500 A, 2 A) is 3142 = 2 x 1571, which both FFT libraries can only do the slow way. histogram_size = std::ceil(oversampling * one_over_d_max / histogram_spacing); + for (bool smooth = false; !smooth; ) { + int64_t v = histogram_size; + for (int p : {2, 3, 5, 7}) + while (v % p == 0) + v /= p; + smooth = (v == 1); + if (!smooth) + ++histogram_size; + } input_size = histogram_size * nDirections; output_size = (histogram_size / 2 + 1) * nDirections;