FFT interface
Detailed Description
This package is intended to calculate one-dimensional real or complex FFTs with high accuracy and good efficiency even for lengths containing large prime factors. The code is written in C, but a Fortran wrapper exists as well.
Before any FFT is executed, a plan must be generated for it. Plan creation is designed to be fast, so that there is no significant overhead if the plan is only used once or a few times.
The main component of the code is based on Paul N. Swarztrauber's FFTPACK in the double precision incarnation by Hugh C. Pumphrey (http://www.netlib.org/fftpack/dp.tgz).
I replaced the iterative sine and cosine calculations in radfg() and radbg() by an exact calculation, which slightly improves the transform accuracy for real FFTs with lengths containing large prime factors.
Since FFTPACK becomes quite slow for FFT lengths with large prime factors (in the worst case of prime lengths it reaches
complexity), I implemented Bluestein's algorithm, which computes a FFT of length
by several FFTs of length
and a convolution. Since
can be chosen to be highly composite, this algorithm is more efficient if
has large prime factors. The longer FFTs themselves are then computed using the FFTPACK routines. Bluestein's algorithm was implemented according to the description on Wikipedia (http://en.wikipedia.org/wiki/Bluestein%27s_FFT_algorithm).
Thread-safety: All routines can be called concurrently; all information needed by ls_fft
is stored in the plan variable. However, using the same plan variable on multiple threads simultaneously is not supported and will lead to data corruption.
Typedef Documentation
The opaque handle type for complex-FFT plans.
Definition at line 86 of file ls_fft.h.
The opaque handle type for real-FFT plans.
Definition at line 111 of file ls_fft.h.
Function Documentation
Returns a plan for a complex FFT with length elements.
Definition at line 37 of file ls_fft.c.
Constructs a copy of plan.
Definition at line 57 of file ls_fft.c.
Destroys a plan for a complex FFT.
Definition at line 69 of file ls_fft.c.
void complex_plan_forward |
( |
complex_plan |
plan, |
|
|
double * |
data | |
|
) |
| | |
Computes a complex forward FFT on data, using plan. Data has the form r0, i0, r1, i1, ..., r[length-1], i[length-1]
.
Definition at line 75 of file ls_fft.c.
void complex_plan_backward |
( |
complex_plan |
plan, |
|
|
double * |
data | |
|
) |
| | |
Computes a complex backward FFT on data, using plan. Data has the form r0, i0, r1, i1, ..., r[length-1], i[length-1]
.
Definition at line 83 of file ls_fft.c.
Returns a plan for a real FFT with length elements.
Definition at line 92 of file ls_fft.c.
Constructs a copy of plan.
Definition at line 112 of file ls_fft.c.
Destroys a plan for a real FFT.
Definition at line 124 of file ls_fft.c.
void real_plan_forward_fftpack |
( |
real_plan |
plan, |
|
|
double * |
data | |
|
) |
| | |
Computes a real forward FFT on data, using plan and assuming the FFTPACK storage scheme:
- on entry, data has the form
r0, r1, ..., r[length-1]
; - on exit, it has the form
r0, r1, i1, r2, i2, ...
(a total of length values).
Definition at line 130 of file ls_fft.c.
void real_plan_backward_fftpack |
( |
real_plan |
plan, |
|
|
double * |
data | |
|
) |
| | |
Computes a real backward FFT on data, using plan and assuming the FFTPACK storage scheme:
- on entry, data has the form
r0, r1, i1, r2, i2, ...
(a total of length values); - on exit, it has the form
r0, r1, ..., r[length-1]
.
Definition at line 189 of file ls_fft.c.
void real_plan_forward_fftw |
( |
real_plan |
plan, |
|
|
double * |
data | |
|
) |
| | |
Computes a real forward FFT on data, using plan and assuming the FFTW halfcomplex storage scheme:
- on entry, data has the form
r0, r1, ..., r[length-1]
; - on exit, it has the form
r0, r1, r2, ..., i2, i1
.
Definition at line 183 of file ls_fft.c.
void real_plan_backward_fftw |
( |
real_plan |
plan, |
|
|
double * |
data | |
|
) |
| | |
Computes a real backward FFT on data, using plan and assuming the FFTW halfcomplex storage scheme:
- on entry, data has the form
r0, r1, r2, ..., i2, i1
. - on exit, it has the form
r0, r1, ..., r[length-1]
.
Definition at line 214 of file ls_fft.c.
void real_plan_forward_c |
( |
real_plan |
plan, |
|
|
double * |
data | |
|
) |
| | |
Computes a real forward FFT on data, using plan and assuming a full-complex storage scheme:
- on entry, data has the form
r0, [ignored], r1, [ignored], ..., r[length-1], [ignored]
; - on exit, it has the form
r0, i0, r1, i1, ..., r[length-1], i[length-1]
.
Definition at line 220 of file ls_fft.c.
void real_plan_backward_c |
( |
real_plan |
plan, |
|
|
double * |
data | |
|
) |
| | |
Computes a real backward FFT on data, using plan and assuming a full-complex storage scheme:
- on entry, data has the form
r0, i0, r1, i1, ..., r[length-1], i[length-1]
; - on exit, it has the form
r0, 0, r1, 0, ..., r[length-1], 0
.
Definition at line 258 of file ls_fft.c.