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

~this
~this()
Undocumented in 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:

Mixins

__anonymous
mixin Import!T
Undocumented in source.

Properties

complex
complex [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

_complex
Fft!T _complex;
Undocumented in source.
itable
impl.ITable itable;
Undocumented in source.
log2n
int log2n;
Undocumented in source.
rtable
impl.RTable rtable;
Undocumented in source.

Examples

import std.stdio, std.conv, std.exception;
import pfft.pfft;

void main(string[] args)
{
    auto n = to!int(args[1]);
    enforce((n & (n-1)) == 0, "N must be a power of two.");

    alias Rfft!float F;

    F f;
    f.initialize(n);

    auto data = F.allocate(n);

    foreach(ref e; data)
        readf("%s\n", &e);

    f.rfft(data);

    foreach(i; 0 .. n / 2 + 1)
        writefln("%s\t%s", data[i], (i == 0 || i == n / 2) ? 0 : data[i]);
}

Meta