Last active
October 11, 2019 04:59
-
-
Save jniemann66/00b05e12603abd4ed64a6a51769a359c to your computer and use it in GitHub Desktop.
fft size selector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pick a good fft size for fftw (of the form 2^a * 3^b * 5^c * 7^d * [1|11|13] ) | |
int selectFFTSize(int n) | |
{ | |
int s = 1; | |
for(int ef : {1, 11, 13}) { | |
for(int d = 1 ; d <= n; d *= 7) { | |
for(int c = 1; c <= n; c *= 5) { | |
for(int b = 1; b <= n; b *= 3) { | |
for(int a = 1; a <= n; a *= 2) { | |
int t = a * b * c * d * ef; | |
if(t > n) { | |
break; | |
} | |
s = std::max(s, t); | |
} | |
} | |
} | |
} | |
} | |
return s; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int fftsize = selectFFTSize(2 * (desiredSpectrumSize - 1)); | |
int actualSpectrumSize = static_cast<int>(floor(fftsize / 2)) + 1; |
Author
jniemann66
commented
Oct 11, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment