solprop.backends.numpy_ref.transforms#
The reference backend’s discrete Fourier transforms, chosen by the operand’s format.
A binary64 operand goes to numpy.fft, which keeps the scalar oracle’s transform
arithmetic bit for bit. A binary32 operand goes to scipy.fft, which sums in
binary32. NumPy’s float32 transforms return complex64 but are computed in binary64 and
rounded once, so every bin is accurate to binary64. That under-represents the binary32
transform error a reduced-precision backend carries, of order \(u_{32}\log n\) of
the input’s norm in every bin, which a resonant response such as stimulated Raman
scattering amplifies from below the true spectrum. The single-precision oracle
(SEP 33) must round as its backends do.
Each function takes the arguments of its numpy.fft namesake that the backend uses.
out, where given, receives the result, which is also returned.
Examples#
>>> import numpy as np
>>> from solprop.backends.numpy_ref import transforms
>>> transforms.rfft(np.ones(4, dtype=np.float32)).dtype
dtype('complex64')
>>> transforms.rfft(np.ones(4)).dtype
dtype('complex128')
Functions
|
Return the forward complex transform along an axis. |
|
Return the forward two-dimensional transform over two axes. |
|
Return the inverse complex transform along an axis. |
|
Return the inverse two-dimensional transform over two axes. |
|
Return the inverse real transform along an axis. |
|
Return the forward real transform along an axis. |
- solprop.backends.numpy_ref.transforms.fft(values, axis=-1)[source]#
Return the forward complex transform along an axis.
- Parameters:
- valuesnumpy.ndarray
Input.
- axisint, optional
The transformed axis, the last by default.
- Returns:
- numpy.ndarray
The spectrum, complex in the operand’s precision.
- solprop.backends.numpy_ref.transforms.fft2(values, axes=(0, 1), out=None)[source]#
Return the forward two-dimensional transform over two axes.
- Parameters:
- valuesnumpy.ndarray
Input.
- axestuple of int, optional
The transformed axes, the first two by default.
- outnumpy.ndarray or None, optional
Where to write the result.
- Returns:
- numpy.ndarray
The spectrum, in out when given.
- solprop.backends.numpy_ref.transforms.ifft(values, axis=-1)[source]#
Return the inverse complex transform along an axis.
- Parameters:
- valuesnumpy.ndarray
Spectrum.
- axisint, optional
The transformed axis, the last by default.
- Returns:
- numpy.ndarray
The signal, complex in the operand’s precision.
- solprop.backends.numpy_ref.transforms.ifft2(values, axes=(0, 1), out=None)[source]#
Return the inverse two-dimensional transform over two axes.
- Parameters:
- valuesnumpy.ndarray
Spectrum.
- axestuple of int, optional
The transformed axes, the first two by default.
- outnumpy.ndarray or None, optional
Where to write the result.
- Returns:
- numpy.ndarray
The signal, in out when given.
- solprop.backends.numpy_ref.transforms.irfft(values, n=None, axis=-1)[source]#
Return the inverse real transform along an axis.
- Parameters:
- valuesnumpy.ndarray
Half spectrum.
- nint or None, optional
Length of the real output;
Nonetakes2 * (m - 1).- axisint, optional
The transformed axis, the last by default.
- Returns:
- numpy.ndarray
The real signal in the operand’s precision.
- solprop.backends.numpy_ref.transforms.rfft(values, n=None, axis=-1)[source]#
Return the forward real transform along an axis.
- Parameters:
- valuesnumpy.ndarray
Real input.
- nint or None, optional
Length to zero-pad or crop the axis to;
Nonekeeps it.- axisint, optional
The transformed axis, the last by default.
- Returns:
- numpy.ndarray
The half spectrum, complex in the operand’s precision.