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
axesof 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 lastaxes, 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=Trueas it stores the values of the Fourier transform of the last axis inaxesat positive frequencies only as values at negative frequencies are simply their complex conjugates.- Parameters:
- dims
tuple Number of samples for each dimension
- axes
tuple, optional Axes (or axis) along which FFTND is applied
- sampling
tupleorfloat, 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\).
- real
bool, 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 ofaxes)- ifftshift_before
tupleorbool, 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_after
tupleorbool, 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.- dtype
str, optional Type of elements in input array. Note that the
dtypeof the operator is the corresponding complex type even when a real type is provided. In addition, note that the NumPy backend does not support returningdtypedifferent fromcomplex128.- base_comm
mpi4py.MPI.Comm, optional MPI Base Communicator. Defaults to
mpi4py.MPI.COMM_WORLD.
- dims
- Attributes:
- fs
tuple Each element of the tuple corresponds to the Discrete Fourier Transform sample frequencies along the respective direction given by
axes.- nffts
tupleorint, optional Number of samples in Fourier Transform for each axis in
axes.- real
bool When
True, uses real fast fourier transform- rdtype
bool Expected input type to the forward
- cdtype
bool Output type of the forward. Complex equivalent to
rdtype.- shape
tuple Operator shape.
- clinear
bool Operator is complex-linear. Is false when either
real=Trueor whendtypeis not a complex type.- fft
mpi4py_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.
- fs
- Raises:
- ValueError
If
normis not one of “none”, or “1/n”.
See also
MPIFFT2DTwo-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 bydims. The distributed FFT transform is performed bympi4py_fft.mpifft.PFFTviampi4py_fft.pencil.Subcomm. Since the 1D input is always distributed alongaxis=0after reshaping, PFFT is configured to distribute alongaxis=0by default. The exception is whenaxes[-1] == 0: PFFT requires the final transform axis to be local on each rank, so the distribution is shifted toaxis=1and 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 andpencil[True]for forward-output/backward-input. During initialization, it records the distributed axes of these layouts as_pfft_in_axisand_pfft_out_axis, and redistributes the inputpylops_mpi.DistributedArrayas needed before each transform.In the forward pass,
PFFT.forwardis called withnormalize=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.backwardis called withnormalize=True, soPFFTinternally 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 1Dpylops_mpi.DistributedArray. All inter-rank data movement is handled internally bympi4py_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