Rfft

A class for calculating real discrete fourier transform. The methods of this class use split format for complex data. This means that complex data set is represented as two arrays - one for the real part and one for the imaginary part. An instance of this class can only be used for transforms of one particular size. The template parameter is the floating point type that the methods of the class will operate on.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Aliases

alignment
alias alignment = Fft!(T).alignment

An alias for Fft!T.alignment

allocate
alias allocate = Fft!(T).allocate

An alias for Fft!T.allocate

deallocate
alias deallocate = Fft!(T).deallocate

An alias for Fft!T.deallocate

scale
alias scale = Fft!(T).scale

An alias for Fft!T.scale

Functions

initialize
void initialize(size_t n)

The Rfft constructor. The parameter is the size of data sets that rfft will operate on. I will refer to this number as n in the rest of the documentation for this class. All tables used in rfft are calculated in the constructor.

irfft
void irfft(T[] data)

Calculates the inverse of rfft, scaled by n (You can use scale to normalize the result). Before the method is called, data should contain a complex sequence in the same format as the result of rfft. It is assumed that the input sequence is a discrete fourier transform of a real valued sequence, so the elements of the input sequence not stored in data can be calculated from DFT(f)i = DFT(f)[n - i]*. When the method completes, the array contains the real part of the inverse discrete fourier transform. The imaginary part is known to be equal to 0.

rfft
void rfft(T[] data)

Calculates discrete fourier transform of the real valued sequence in data. The method operates in place. When the method completes, data contains the result. First n / 2 + 1 elements contain the real part of the result and the rest contains the imaginary part. Imaginary parts at position 0 and n / 2 are known to be equal to 0 and are not stored, so the content of data looks like this:

Examples

1 import std.stdio, std.conv, std.exception;
2 import pfft.pfft;
3 
4 void main(string[] args)
5 {
6     auto n = to!int(args[1]);
7     enforce((n & (n-1)) == 0, "N must be a power of two.");
8 
9     alias Rfft!float F;
10 
11     F f;
12     f.initialize(n);
13 
14     auto data = F.allocate(n);
15 
16     foreach(ref e; data)
17         readf("%s\n", &e);
18 
19     f.rfft(data);
20 
21     foreach(i; 0 .. n / 2 + 1)
22         writefln("%s\t%s", data[i], (i == 0 || i == n / 2) ? 0 : data[i]);
23 }

Meta