Real-Valued Transforms
rfft, irfft, hfft, ihfft – real-input and Hermitian-symmetric
transforms following numpy.fft conventions. Wrappers that call the complex
FFT from mpmath_fft via lazy import to avoid circular dependencies.
Real-valued FFT transforms for mpmath.
- mpmath_fft._real_transforms.hfft(x, n=None, axis=-1)[source]
Hermitian FFT.
Computes the inverse FFT of a Hermitian-symmetric half-spectrum. Equivalent to n_used * irfft(conj(x), n=n, axis=axis).
Parameters
- xndarray[dtype=object] of mp.mpc
Half-spectrum input.
- nint, optional
Output length. Default: 2 * (x.shape[axis] - 1).
- axisint
Transform axis (default -1).
Returns
- yndarray[dtype=object] of mp.mpf
Real-valued output.
- mpmath_fft._real_transforms.ihfft(x, n=None, axis=-1)[source]
Inverse Hermitian FFT.
Computes the forward FFT of a real signal and returns the non-redundant half-spectrum, with 1/n scaling. Equivalent to conj(rfft(x, n=n, axis=axis)) / n_used.
Parameters
- xndarray[dtype=object] of mp.mpf
Real-valued input.
- nint, optional
Transform length. Default: x.shape[axis].
- axisint
Transform axis (default -1).
Returns
- yndarray[dtype=object] of mp.mpc
Half-spectrum output.
- mpmath_fft._real_transforms.irfft(x, n=None, axis=-1)[source]
Complex-to-real inverse FFT.
Reconstructs the full Hermitian-symmetric spectrum from the non-redundant half, computes the inverse DFT, and returns the real part.
Parameters
- xndarray[dtype=object] of mp.mpc
Half-spectrum, shape = (…, M, …) where M = n_orig//2 + 1.
- nint, optional
Output length along transform axis. Default: 2 * (x.shape[axis] - 1).
- axisint
Transform axis (default -1).
Returns
- yndarray[dtype=object] of mp.mpf
Real-valued inverse transform.
- mpmath_fft._real_transforms.rfft(x, n=None, axis=-1)[source]
Real-to-complex FFT.
Computes the forward DFT of real-valued input and returns only the non-redundant half of the spectrum (indices 0..n//2).
Parameters
- xndarray[dtype=object] of mp.mpf
Real-valued input array.
- nint, optional
Transform length. If n > x.shape[axis], zero-pad. If n < x.shape[axis], truncate. Default: x.shape[axis].
- axisint
Transform axis (default -1).
Returns
- yndarray[dtype=object] of mp.mpc
Half-spectrum, shape = (…, n//2 + 1, …).
- mpmath_fft._real_transforms.rfftfreq(n, d=1.0)[source]
Frequency bins for an n-point real FFT.
Returns the non-negative frequencies f_k = k / (n*d) for k = 0..n//2.
Parameters
- nint
Number of sample points.
- dfloat or mpmath scalar, optional
Sample spacing (default 1.0).
Returns
- fndarray[dtype=object] of mp.mpf
Frequencies, shape (n//2 + 1,).