digitalmars.D.learn - fft and isPowerOf2?
- Andre Pany (43/43) May 17 2018 Hi,
- kdevel (3/7) May 17 2018 There is a mathematical background which is well explained here:
- Andre Pany (4/11) May 17 2018 Thanks a lot for the details link.
Hi, this applications throws an error in std.numeric (Line 2826). => assert(isPowerOf2(range.length)); ----------- module std.numeric void fftImplPureReal(Ret, R)(R range, Ret buf) const in { assert(range.length >= 4); assert(isPowerOf2(range.length)); } ----------- The application is rewritten from python (numpy). How can I workaround this issue? Isn't it possible to give an arbitrary length of data to fft like in numpy? import std.numeric; import std.datetime.stopwatch; import std.stdio: writeln; import std.random; import std.array : array; import std.range : generate, takeExactly; void fourierTest(int samplingRate) { auto sw = StopWatch(AutoStart.yes); foreach(n; 0..60 * 24) { sw.stop(); double[] x = generate!(() => uniform01).takeExactly(samplingRate * 60).array; sw.start(); writeln(x); auto y = fft(x); } sw.stop(); writeln("microseconds: ", sw.peek.total!"usecs"); } void main() { fourierTest(50); } Kind regards André
May 17 2018
On Thursday, 17 May 2018 at 12:34:25 UTC, Andre Pany wrote:this applications throws an error in std.numeric (Line 2826). => assert(isPowerOf2(range.length));Isn't it possible to give an arbitrary length of data to fft like in numpy?There is a mathematical background which is well explained here: https://math.stackexchange.com/questions/77118/non-power-of-2-ffts#77152
May 17 2018
On Thursday, 17 May 2018 at 13:36:39 UTC, kdevel wrote:On Thursday, 17 May 2018 at 12:34:25 UTC, Andre Pany wrote:Thanks a lot for the details link. Kind regards Andréthis applications throws an error in std.numeric (Line 2826). => assert(isPowerOf2(range.length));Isn't it possible to give an arbitrary length of data to fft like in numpy?There is a mathematical background which is well explained here: https://math.stackexchange.com/questions/77118/non-power-of-2-ffts#77152
May 17 2018