KissFFT¶
- class KissFFT(*args)¶
KissFFT implementation.
This is a wrapper on the KissFFT library and implements the
FFTinterface.Methods
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
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:
- collection
ComplexCollectionorScalarCollection, sequence of float Data to transform.
- dimensions
Indices, 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.
- collection
- Returns:
- collection
ComplexCollection The transformed data.
- collection
Notes
The 1D Inverse Fast Fourier Transform writes as:
where
denotes the data, of size
, to be transformed.
For multidimensional data, the IFFT is computed by applying 1D IFFT sequentially along each dimension, scaled by
.
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:
- collection
ComplexCollectionorScalarCollection, sequence of float Data to transform.
- dimensions
Indices, 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.
- collection
- Returns:
- collection
ComplexCollection The data in Fourier domain.
- collection
Notes
The 1D Fast Fourier Transform writes as:
where
denotes the data to be transformed, of size
.
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.
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])
OpenTURNS