KissFFT

class KissFFT(*args)

KissFFT implementation.

This is a wrapper on the KissFFT library and implements the FFT interface.

Methods

getClassName()

Accessor to the object's name.

getName()

Accessor to the object's name.

hasName()

Test if the object is named.

inverseTransform(*args)

Perform Inverse Fast Fourier Transform (IFFT).

setName(name)

Accessor to the object's name.

transform(*args)

Perform Fast Fourier Transform (FFT).

See also

FFT

Examples

Compute the discrete Fourier transform of a real sequence:

>>> import openturns as ot
>>> fft = ot.KissFFT()
>>> collection = ot.ComplexCollection([1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0])
>>> result = fft.transform(collection)
>>> print(result)
[(4,0),...]

The inverse transform recovers the original sequence up to the round-off errors:

>>> restored = fft.inverseTransform(result)
__init__(*args)
getClassName()

Accessor to the object’s name.

Returns:
class_namestr

The object class name (object.__class__.__name__).

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

inverseTransform(*args)

Perform Inverse Fast Fourier Transform (IFFT).

Parameters:
collectionComplexCollection or ScalarCollection, sequence of float

Data to transform.

dimensionsIndices, optional

Shape of the tensor for multidimensional IFFT. If provided, the data is interpreted as an N-dimensional tensor stored in column-major order. If omitted, a 1D IFFT is performed.

Returns:
collectionComplexCollection

The transformed data.

Notes

The 1D Inverse Fast Fourier Transform writes as:

{\rm y_k} = \sum_{n=0}^{N-1} \frac{1}{N} x_n exp(2 i \pi \frac{kn}{N})

where x denotes the data, of size N, to be transformed.

For multidimensional data, the IFFT is computed by applying 1D IFFT sequentially along each dimension, scaled by 1/\prod D_d.

Examples

>>> import openturns as ot
>>> fft = ot.FFT()
>>> collection = ot.ComplexCollection([1+1j,2-0.3j,5-.3j,6+1j,9+8j,16+8j,0.3])
>>> result = fft.inverseTransform(collection)
>>> data = ot.Point([1.0, 2.0, 3.0, 4.0])
>>> result = fft.inverseTransform(data, [4])
setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

transform(*args)

Perform Fast Fourier Transform (FFT).

Parameters:
collectionComplexCollection or ScalarCollection, sequence of float

Data to transform.

dimensionsIndices, optional

Shape of the tensor for multidimensional FFT. If provided, the data is interpreted as an N-dimensional tensor stored in column-major order. If omitted, a 1D FFT is performed.

Returns:
collectionComplexCollection

The data in Fourier domain.

Notes

The 1D Fast Fourier Transform writes as:

{\rm y_k} = \sum_{n=0}^{N-1} x_n exp(-2 i \pi \frac{kn}{N})

where x denotes the data to be transformed, of size N.

For multidimensional data, the FFT is computed by applying 1D FFT sequentially along each dimension. The data is stored in column-major (Fortran) order, where the first dimension varies fastest.

{\rm Y_{k_0,\ldots,k_{N-1}}} = \sum_{n_0=0}^{D_0-1}\cdots\sum_{n_{N-1}=0}^{D_{N-1}-1} X_{n_0,\ldots,n_{N-1}} \prod_{d=0}^{N-1} \exp\left(-2 i \pi \frac{k_d n_d}{D_d}\right)

Examples

>>> import openturns as ot
>>> fft = ot.FFT()
>>> result = fft.transform(ot.Normal(8).getRealization())
>>> # 2D transform (2x3 matrix)
>>> data = ot.Point([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
>>> result = fft.transform(data, [2, 3])