pylops_mpi.signalprocessing.MPIFFTND#

class pylops_mpi.signalprocessing.MPIFFTND(dims, axes=(0, 1, 2), sampling=1.0, norm='none', real=False, ifftshift_before=False, fftshift_after=False, dtype='complex128', base_comm=<mpi4py.MPI.Intracomm object>)[source]#

N-dimensional Fast-Fourier Transform.

Apply N-dimensional Fast-Fourier Transform (FFT) to any n axes of a multidimensional array.

When using real=True, the result of the forward is also multiplied by \(\sqrt{2}\) for all frequency bins except zero and Nyquist along the last axes, and the input of the adjoint is multiplied by \(1 / \sqrt{2}\) for the same frequencies.

For a real valued input signal, it is advised to use the flag real=True as it stores the values of the Fourier transform of the last axis in axes at positive frequencies only as values at negative frequencies are simply their complex conjugates.

Parameters:
dimstuple

Number of samples for each dimension

axestuple, optional

Axes (or axis) along which FFTND is applied

samplingtuple or float, optional

Sampling steps for each direction. When supplied a single value, it is used for all directions.

norm{“none”, “1/n”}, optional
  • “none”: Does not scale the forward or the adjoint FFT transforms. Default is “none”.

  • “1/n”: Scales both the forward and adjoint FFT transforms by \(1/N_F\).

realbool, optional

Model to which fft is applied has real numbers (True) or not (False). Used to enforce that the output of adjoint of a real model is real. Note that the real FFT is applied only to the first dimension to which the FFTND operator is applied (last element of axes)

ifftshift_beforetuple or bool, optional

Apply ifftshift (True) or not (False) to model vector (before FFT). Consider using this option when the model vector’s respective axis is symmetric with respect to the zero value sample. This will shift the zero value sample to coincide with the zero index sample. With such an arrangement, FFT will not introduce a sample-dependent phase-shift when compared to the continuous Fourier Transform. When passing a single value, the shift will the same for every direction. Pass a tuple to specify which dimensions are shifted.

fftshift_aftertuple or bool, optional

Apply fftshift (True) or not (False) to data vector (after FFT). Consider using this option when you require frequencies to be arranged naturally, from negative to positive. When not applying fftshift after FFT, frequencies are arranged from zero to largest positive, and then from negative Nyquist to the frequency bin before zero. When passing a single value, the shift will the same for every direction. Pass a tuple to specify which dimensions are shifted.

dtypestr, optional

Type of elements in input array. Note that the dtype of the operator is the corresponding complex type even when a real type is provided. In addition, note that the NumPy backend does not support returning dtype different from complex128.

base_commmpi4py.MPI.Comm, optional

MPI Base Communicator. Defaults to mpi4py.MPI.COMM_WORLD.

Attributes:
fstuple

Each element of the tuple corresponds to the Discrete Fourier Transform sample frequencies along the respective direction given by axes.

nfftstuple or int, optional

Number of samples in Fourier Transform for each axis in axes.

realbool

When True, uses real fast fourier transform

rdtypebool

Expected input type to the forward

cdtypebool

Output type of the forward. Complex equivalent to rdtype.

shapetuple

Operator shape.

clinearbool

Operator is complex-linear. Is false when either real=True or when dtype is not a complex type.

fftmpi4py_fft.mpifft.PFFT

Parallel FFT operator object handling the distributed transform across MPI processes. Configured with the base communicator, dimension decomposition, transform axes, and dtype.

Raises:
ValueError
  • If norm is not one of “none”, or “1/n”.

See also

MPIFFT2D

Two-dimensional FFT

Notes

The MPIFFTND operator applies the forward and inverse N-dimensional FFT to a pylops_mpi.DistributedArray, accepted as a 1D flattened array and reshaped internally to the layout defined by dims. The distributed FFT transform is performed by mpi4py_fft.mpifft.PFFT via mpi4py_fft.pencil.Subcomm. Since the 1D input is always distributed along axis=0 after reshaping, PFFT is configured to distribute along axis=0 by default. The exception is when axes[-1] == 0: PFFT requires the final transform axis to be local on each rank, so the distribution is shifted to axis=1 and the input is redistributed accordingly before the transform. After the transform, the output is flattened back to 1D.

The class uses PFFT’s two internal pencil layouts: pencil[False] for forward-input/backward-output and pencil[True] for forward-output/backward-input. During initialization, it records the distributed axes of these layouts as _pfft_in_axis and _pfft_out_axis, and redistributes the input pylops_mpi.DistributedArray as needed before each transform.

In the forward pass, PFFT.forward is called with normalize=False, computing:

\[D(k_1, \ldots, k_N) = \mathscr{F} (d) = \int\limits_{-\infty}^\infty \cdots \int\limits_{-\infty}^\infty d(x_1, \ldots, x_N) e^{-j2\pi k_1 x_1} \cdots e^{-j 2 \pi k_N x_N} \,\mathrm{d}x_1 \cdots \mathrm{d}x_N\]

When norm="1/n", the result is additionally scaled by \(1/N_F\).

In the adjoint pass, PFFT.backward is called with normalize=True, so PFFT internally divides by \(N_F = \prod_i N_i\), computing:

\[d(x_1, \ldots, x_N) = \mathscr{F}^{-1} (D) = \frac{1}{N_F} \int\limits_{-\infty}^\infty \cdots \int\limits_{-\infty}^\infty D(k_1, \ldots, k_N) e^{j2\pi k_1 x_1} \cdots e^{j 2 \pi k_N x_N} \,\mathrm{d}k_1 \cdots \mathrm{d}k_N\]

When norm="none", the adjoint multiplies by \(N_F\) to cancel this internal scaling, returning a true unscaled adjoint. The result is then flattened back to a 1D pylops_mpi.DistributedArray. All inter-rank data movement is handled internally by mpi4py_fft.

Methods

__init__(dims[, axes, sampling, norm, real, ...])

adjoint()

Adjoint MPI LinearOperator

conj()

Complex conjugate operator

dot(x)

Matrix Vector Multiplication

matvec(x)

Matrix-vector multiplication.

rmatvec(x)

Adjoint Matrix-vector multiplication.

transpose()

Transposition of MPI LinearOperator

Examples using pylops_mpi.signalprocessing.MPIFFTND#

Fourier Transform

Fourier Transform