fft and isPowerOf2?

Andre Pany andre at s-e-a-p.de
Thu May 17 12:34:25 UTC 2018


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é


More information about the Digitalmars-d-learn mailing list