FOURIER : use Bluestein's algorithm for N != 2^k
commit15e89e7cc93a82e5f129a86644531e1e6627a1cf
authorDennis Francis <dennis.francis@collabora.com>
Thu, 28 Feb 2019 03:15:13 +0000 (28 08:45 +0530)
committerDennis Francis <dennis.francis@collabora.com>
Sun, 3 Mar 2019 15:15:44 +0000 (3 16:15 +0100)
tree86127a6adffc5d610ecab28d78ccd2217354f36b
parent4037d4416c9a567e5af8c4e3473d0cef8c261a60
FOURIER : use Bluestein's algorithm for N != 2^k

For inputs that are not an even power of 2, use
Bluestein's algorithm[1] to match the output of
fft()/ifft() in Octave/Matlab() in those cases.
This algorithm is slower than radix-2 FFT algorithm
but still has the asymptotic time complexity of
O(N lg(N)).

This patch also introduces considerable speedup in case
of real valued inputs. DFT of a real valued input of
length N can be computed using any DFT algorithm with
a N/2 length complex valued input, provided we do some
pre and post processing[2].

All implementations in this patch are written from scratch
using the below theory references.

[1] https://en.wikipedia.org/wiki/Chirp_Z-transform#Bluestein.27s_algorithm
[2] Jones, K., 2010. Fast Solutions to Real-Data Discrete Fourier Transform.
    In The Regularized Fast Hartley Transform (pp. 15-25). Springer, Dordrecht.

---------------------------
Below are some perf measurements for various input cases :-

Timing numbers are only for the DFT computation part and does not include
the time for writing data to the spreadsheet model. We don't use threading
yet, so these are numbers for just one cpu-core.

Exact Powers of 2
=================

Real Input size,Time (ms)
32768,2
65536,4
262144,21
1048576,185

Complex Input size, Time(ms)
32768,2
65536,5
262144,30
1048576,400

Even non-powers of 2 : 2^k - 2
================================

Real Input size,Time (ms)
32766,8
65534,20
262142,105
1048574,1440

Complex Input size, Time(ms)
32766,15
65534,36
262142,313
1048574,3332

Odd non-powers of 2 : 2^k - 1
================================

Real Input size,Time (ms)
32767,16
65535,39
262143,313
1048575,2729

Complex Input size, Time(ms)
32767,16
65535,38
262143,309
1048575,2703

Change-Id: Iccc31455e526ee5e6d18c20812dfa53defcf869f
Reviewed-on: https://gerrit.libreoffice.org/68639
Tested-by: Jenkins
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
sc/source/core/tool/interpr3.cxx