sporco.fft

Variants of the Fast Fourier Transform and associated functions.

Functions

complex_dtype(dtype)

Construct the corresponding complex dtype for a given real dtype.

real_dtype(dtype)

Construct the corresponding real dtype for a given complex dtype.

dctii(x[, axes])

Multi-dimensional DCT-II.

idctii(x[, axes])

Multi-dimensional inverse DCT-II.

fftconv(a, b[, axes, origin])

Multi-dimensional convolution via the Discrete Fourier Transform.

fl2norm2(xf[, axis])

Compute the squared \(\ell_2\) norm in the DFT domain.

rfl2norm2(xf, xs[, axis])

Compute the squared \(\ell_2\) norm in the real DFT domain.


Function Descriptions

sporco.fft.complex_dtype(dtype)[source]

Construct the corresponding complex dtype for a given real dtype.

Construct the corresponding complex dtype for a given real dtype, e.g. the complex dtype corresponding to np.float32 is np.complex64.

Parameters:
dtypedtype

A real dtype, e.g. np.float32, np.float64

Returns:
dtype

The complex dtype corresponding to the input dtype

sporco.fft.real_dtype(dtype)[source]

Construct the corresponding real dtype for a given complex dtype.

Construct the corresponding real dtype for a given complex dtype, e.g. the real dtype corresponding to np.complex64 is np.float32.

Parameters:
dtypedtype

A complex dtype, e.g. np.complex64, np.complex128

Returns:
dtype

The real dtype corresponding to the input dtype

sporco.fft.dctii(x, axes=None)[source]

Multi-dimensional DCT-II.

Compute a multi-dimensional DCT-II over specified array axes. This function is implemented by calling the one-dimensional DCT-II scipy.fftpack.dct with normalization mode ‘ortho’ for each of the specified axes.

Parameters:
aarray_like

Input array

axessequence of ints, optional (default None)

Axes over which to compute the DCT-II.

Returns:
ndarray

DCT-II of input array

sporco.fft.idctii(x, axes=None)[source]

Multi-dimensional inverse DCT-II.

Compute a multi-dimensional inverse DCT-II over specified array axes. This function is implemented by calling the one-dimensional inverse DCT-II scipy.fftpack.idct with normalization mode ‘ortho’ for each of the specified axes.

Parameters:
aarray_like

Input array

axessequence of ints, optional (default None)

Axes over which to compute the inverse DCT-II.

Returns:
ndarray

Inverse DCT-II of input array

sporco.fft.fftconv(a, b, axes=None, origin=None)[source]

Multi-dimensional convolution via the Discrete Fourier Transform.

Compute a multi-dimensional convolution via the Discrete Fourier Transform. Note that the output has a phase shift relative to the output of scipy.ndimage.convolve with the default origin parameter.

Parameters:
aarray_like

Input array

barray_like

Input array

axessequence of ints or None optional (default None)

Axes on which to perform convolution. The default of None selects all axes of a

originsequence of ints or None optional (default None)

Indices of centre of a filter. The default of None corresponds to a centre at 0 on all axes of a

Returns:
ndarray

Convolution of input arrays, a and b, along specified axes

sporco.fft.fl2norm2(xf, axis=(0, 1))[source]

Compute the squared \(\ell_2\) norm in the DFT domain.

Compute the squared \(\ell_2\) norm in the DFT domain, taking into account the unnormalised DFT scaling, i.e. given the DFT of a multi-dimensional array computed via fftn, return the squared \(\ell_2\) norm of the original array.

Parameters:
xfarray_like

Input array

axissequence of ints, optional (default (0,1))

Axes on which the input is in the frequency domain

Returns:
float

\(\|\mathbf{x}\|_2^2\) where the input array is the result of applying fftn to the specified axes of multi-dimensional array \(\mathbf{x}\)

sporco.fft.rfl2norm2(xf, xs, axis=(0, 1))[source]

Compute the squared \(\ell_2\) norm in the real DFT domain.

Compute the squared \(\ell_2\) norm in the DFT domain, taking into account the unnormalised DFT scaling, i.e. given the DFT of a multi-dimensional array computed via rfftn, return the squared \(\ell_2\) norm of the original array.

Parameters:
xfarray_like

Input array

xssequence of ints

Shape of original array to which rfftn was applied to obtain the input array

axissequence of ints, optional (default (0,1))

Axes on which the input is in the frequency domain

Returns:
float

\(\|\mathbf{x}\|_2^2\) where the input array is the result of applying rfftn to the specified axes of multi-dimensional array \(\mathbf{x}\)