diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2019-02-16 14:36:01 +0530 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2019-02-19 12:35:25 +0100 |
commit | 32d9f7a632e1df1b6d5ac32a88b2b88c042e91ff (patch) | |
tree | a03bf35abebbacb94bc986a6aa60c8ef486a7c76 /formula/source | |
parent | abd6f2a38506f512d4846cf43a9fc9576d96ceb3 (diff) |
tdf#74664 : Adds FOURIER() formula
FOURIER(Array, GroupedByColumns, Inverse, Polar)
is a matrix formula that computes discrete Fourier transform[DFT]
of input array(first argument) via a radix-2, decimation-in-time
fast Fourier transform algorithm.
Unit test for this is coming up in a new commit.
The data in input array(first argument) can be :-
1) grouped by columns (needs to be indicated by flag GroupedByColumns = TRUE)
In this case the array can contain 1 or 2 columns, where the first column
contains the real part of input series and second column if present contains
the imaginary part of the input series. If there is only 1 column, the input
series is treated as purely real. If the number of rows is not a power of 2,
zeroes are appended to the input series internally to make the series length
equal to the next nearest power of 2.
2) grouped by rows (needs to be indicated by flag GroupedByColumns = FALSE)
In this case the array can contain 1 or 2 rows, where the first row
contains the real part of input series and second row if present contains
the imaginary part of the input series. If there is only 1 row, the input
series is treated as purely real. If the number of columns is not a power of 2,
zeroes are appended to the input series internally to make the series length
equal to the next nearest power of 2.
The third argument "Inverse" is a boolean flag to indicate whether an inverse
DFT needs to be computed. This argument is optional and the default value is
FALSE.
The fourth argument Polar is a boolean flag to indicate whether the final output
needs to be in polar coordinates. This argument is optional and the default value
is FALSE.
The result of DFT consists of two columns - first column contains the real parts (or
the magnitudes if Polar=TRUE) and second column contains the imaginary parts (or
the phases if Polar=TRUE).
Implementation:
A fairly straighforward non-recursive implementation of radix-2 FFT algorithm is
written from scratch.
Reference:
Heckbert, P., 1995. Fourier transforms and the fast Fourier transform (FFT) algorithm.
Computer Graphics, 2, pp.15-463.
The normalization factor used in DFT / and inverse DFT in this implementation matches that
of fft() and ifft() functions of Matlab/Octave. It also matches the one used in Wikipedia
article on DFT: https://en.wikipedia.org/wiki/Discrete_Fourier_transform.
Change-Id: If4a40a6ef62bce1f03c589ae5357b2049f66fe64
Reviewed-on: https://gerrit.libreoffice.org/67938
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'formula/source')
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index f243aab357f7..930774023ace 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -1051,6 +1051,7 @@ bool FormulaCompiler::IsMatrixFunction( OpCode eOpCode ) case ocMatInv : case ocMatrixUnit : case ocModalValue_Multi : + case ocFourier : return true; default: { |