scico.numpy.fft¶
Discrete Fourier Transform functions.
Functions
|
Compute a one-dimensional discrete Fourier transform along a given axis. |
|
Compute a two-dimensional discrete Fourier transform along given axes. |
|
Return sample frequencies for the discrete Fourier transform. |
|
Compute a multidimensional discrete Fourier transform along given axes. |
|
Shift zero-frequency fft component to the center of the spectrum. |
|
Compute a 1-D FFT of an array whose spectrum has Hermitian symmetry. |
|
Compute a one-dimensional inverse discrete Fourier transform. |
|
Compute a two-dimensional inverse discrete Fourier transform. |
|
Compute a multidimensional inverse discrete Fourier transform. |
|
The inverse of |
|
Compute a 1-D inverse FFT of an array whose spectrum has Hermitian-symmetry. |
|
Compute a real-valued one-dimensional inverse discrete Fourier transform. |
|
Compute a real-valued two-dimensional inverse discrete Fourier transform. |
|
Compute a real-valued multidimensional inverse discrete Fourier transform. |
|
Compute a one-dimensional discrete Fourier transform of a real-valued array. |
|
Compute a two-dimensional discrete Fourier transform of a real-valued array. |
|
Return sample frequencies for the discrete Fourier transform. |
|
Compute a multidimensional discrete Fourier transform of a real-valued array. |
- scico.numpy.fft.fft(a, n=None, axis=-1, norm=None)¶
Compute a one-dimensional discrete Fourier transform along a given axis.
JAX implementation of
numpy.fft.fft.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input arrayn (
int|None) – int. Specifies the dimension of the result alongaxis. If not specified, it will default to the dimension ofaalongaxis.axis (
int) – int, default=-1. Specifies the axis along which the transform is computed. If not specified, the transform is computed along axis -1.norm (
str|None) – string. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
An array containing the one-dimensional discrete Fourier transform of
a.
See also
jax.numpy.fft.ifft: Computes a one-dimensional inverse discrete Fourier transform.jax.numpy.fft.fftn: Computes a multidimensional discrete Fourier transform.jax.numpy.fft.ifftn: Computes a multidimensional inverse discrete Fourier transform.
Examples
jnp.fft.fftcomputes the transform alongaxis -1by default.>>> x = jnp.array([[1, 2, 4, 7], ... [5, 3, 1, 9]]) >>> jnp.fft.fft(x) Array([[14.+0.j, -3.+5.j, -4.+0.j, -3.-5.j], [18.+0.j, 4.+6.j, -6.+0.j, 4.-6.j]], dtype=complex64)
When
n=3, dimension of the transform along axis -1 will be3and dimension along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... print(jnp.fft.fft(x, n=3)) [[ 7.+0.j -2.+1.73j -2.-1.73j] [ 9.+0.j 3.-1.73j 3.+1.73j]]
When
n=3andaxis=0, dimension of the transform alongaxis 0will be3and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... print(jnp.fft.fft(x, n=3, axis=0)) [[ 6. +0.j 5. +0.j 5. +0.j 16. +0.j ] [-1.5-4.33j 0.5-2.6j 3.5-0.87j 2.5-7.79j] [-1.5+4.33j 0.5+2.6j 3.5+0.87j 2.5+7.79j]]
jnp.fft.ifftcan be used to reconstructxfrom the result ofjnp.fft.fft.>>> x_fft = jnp.fft.fft(x) >>> jnp.allclose(x, jnp.fft.ifft(x_fft)) Array(True, dtype=bool)
- scico.numpy.fft.fft2(a, s=None, axes=(-2, -1), norm=None)¶
Compute a two-dimensional discrete Fourier transform along given axes.
JAX implementation of
numpy.fft.fft2.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input array. Must havea.ndim >= 2.s (
Sequence[int] |None) – optional length-2 sequence of integers. Specifies the size of the output along each specified axis. If not specified, it will default to the size ofaalong the specifiedaxes.axes (
Sequence[int]) – optional length-2 sequence of integers, default=(-2,-1). Specifies the axes along which the transform is computed.norm (
str|None) – string, default=”backward”. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
An array containing the two-dimensional discrete Fourier transform of
aalong givenaxes.
See also
jax.numpy.fft.fft: Computes a one-dimensional discrete Fourier transform.jax.numpy.fft.fftn: Computes a multidimensional discrete Fourier transform.jax.numpy.fft.ifft2: Computes a two-dimensional inverse discrete Fourier transform.
Examples
jnp.fft.fft2computes the transform along the last two axes by default.>>> x = jnp.array([[[1, 3], ... [2, 4]], ... [[5, 7], ... [6, 8]]]) >>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.fft2(x) Array([[[10.+0.j, -4.+0.j], [-2.+0.j, 0.+0.j]], [[26.+0.j, -4.+0.j], [-2.+0.j, 0.+0.j]]], dtype=complex64)
When
s=[2, 3], dimension of the transform alongaxes (-2, -1)will be(2, 3)and dimension along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.fft2(x, s=[2, 3]) Array([[[10. +0.j , -0.5 -6.06j, -0.5 +6.06j], [-2. +0.j , -0.5 +0.87j, -0.5 -0.87j]], [[26. +0.j , 3.5-12.99j, 3.5+12.99j], [-2. +0.j , -0.5 +0.87j, -0.5 -0.87j]]], dtype=complex64)
When
s=[2, 3]andaxes=(0, 1), shape of the transform alongaxes (0, 1)will be(2, 3)and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.fft2(x, s=[2, 3], axes=(0, 1)) Array([[[14. +0.j , 22. +0.j ], [ 2. -6.93j, 4.-10.39j], [ 2. +6.93j, 4.+10.39j]], [[-8. +0.j , -8. +0.j ], [-2. +3.46j, -2. +3.46j], [-2. -3.46j, -2. -3.46j]]], dtype=complex64)
jnp.fft.ifft2can be used to reconstructxfrom the result ofjnp.fft.fft2.>>> x_fft2 = jnp.fft.fft2(x) >>> jnp.allclose(x, jnp.fft.ifft2(x_fft2)) Array(True, dtype=bool)
- scico.numpy.fft.fftfreq(n, d=1.0, *, dtype=None, device=None)¶
Return sample frequencies for the discrete Fourier transform.
JAX implementation of
numpy.fft.fftfreq. Returns frequencies appropriate for use with the outputs offftandifft.- Parameters:
n (
int) – length of the FFT windowd (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – optional scalar sample spacing (default: 1.0)dtype (
Union[str,type[Any],dtype,SupportsDType,None]) – optional dtype of returned frequencies. If not specified, JAX’s default floating point dtype will be used.device (
Device|Sharding|None) – optionalDeviceorShardingto which the created array will be committed.
- Return type:
- Returns:
Array of sample frequencies, length
n.
See also
jax.numpy.fft.rfftfreq: frequencies for use withrfftandirfft.
- scico.numpy.fft.fftn(a, s=None, axes=None, norm=None)¶
Compute a multidimensional discrete Fourier transform along given axes.
JAX implementation of
numpy.fft.fftn.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input arrays (
Sequence[int] |None) – sequence of integers. Specifies the shape of the result. If not specified, it will default to the shape ofaalong the specifiedaxes.axes (
Sequence[int] |None) – sequence of integers, default=None. Specifies the axes along which the transform is computed.norm (
str|None) – string. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
An array containing the multidimensional discrete Fourier transform of
a.
See also
jax.numpy.fft.fft: Computes a one-dimensional discrete Fourier transform.jax.numpy.fft.ifft: Computes a one-dimensional inverse discrete Fourier transform.jax.numpy.fft.ifftn: Computes a multidimensional inverse discrete Fourier transform.
Examples
jnp.fft.fftncomputes the transform along all the axes by default whenaxesargument isNone.>>> x = jnp.array([[1, 2, 5, 6], ... [4, 1, 3, 7], ... [5, 9, 2, 1]]) >>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.fftn(x) Array([[ 46. +0.j , 0. +2.j , -6. +0.j , 0. -2.j ], [ -2. +1.73j, 6.12+6.73j, 0. -1.73j, -18.12-3.27j], [ -2. -1.73j, -18.12+3.27j, 0. +1.73j, 6.12-6.73j]], dtype=complex64)
When
s=[2], dimension of the transform alongaxis -1will be2and dimension along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... print(jax.numpy.fft.fftn(x, s=[2])) [[ 3.+0.j -1.+0.j] [ 5.+0.j 3.+0.j] [14.+0.j -4.+0.j]]
When
s=[2]andaxes=[0], dimension of the transform alongaxis 0will be2and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... print(jax.numpy.fft.fftn(x, s=[2], axes=[0])) [[ 5.+0.j 3.+0.j 8.+0.j 13.+0.j] [-3.+0.j 1.+0.j 2.+0.j -1.+0.j]]
When
s=[2, 3], shape of the transform will be(2, 3).>>> with jnp.printoptions(precision=2, suppress=True): ... print(jax.numpy.fft.fftn(x, s=[2, 3])) [[16. +0.j -0.5+4.33j -0.5-4.33j] [ 0. +0.j -4.5+0.87j -4.5-0.87j]]
jnp.fft.ifftncan be used to reconstructxfrom the result ofjnp.fft.fftn.>>> x_fftn = jnp.fft.fftn(x) >>> jnp.allclose(x, jnp.fft.ifftn(x_fftn)) Array(True, dtype=bool)
- scico.numpy.fft.fftshift(x, axes=None)¶
Shift zero-frequency fft component to the center of the spectrum.
JAX implementation of
numpy.fft.fftshift.- Parameters:
- Return type:
- Returns:
A shifted copy of
x.
See also
jax.numpy.fft.ifftshift: inverse offftshift.jax.numpy.fft.fftfreq: generate FFT frequencies.
Examples
Generate FFT frequencies with
fftfreq:>>> freq = jnp.fft.fftfreq(5) >>> freq Array([ 0. , 0.2, 0.4, -0.4, -0.2], dtype=float32)
Use
fftshiftto shift the zero-frequency entry to the middle of the array:>>> shifted_freq = jnp.fft.fftshift(freq) >>> shifted_freq Array([-0.4, -0.2, 0. , 0.2, 0.4], dtype=float32)
Unshift with
ifftshiftto recover the original frequencies:>>> jnp.fft.ifftshift(shifted_freq) Array([ 0. , 0.2, 0.4, -0.4, -0.2], dtype=float32)
- scico.numpy.fft.hfft(a, n=None, axis=-1, norm=None)¶
Compute a 1-D FFT of an array whose spectrum has Hermitian symmetry.
JAX implementation of
numpy.fft.hfft.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input array.n (
int|None) – optional, int. Specifies the dimension of the result alongaxis. If not specified,n = 2*(m-1), wheremis the dimension ofaalongaxis.axis (
int) – optional, int, default=-1. Specifies the axis along which the transform is computed. If not specified, the transform is computed along axis -1.norm (
str|None) – optional, string. The normalization mode. “backward”, “ortho” and “forward” are supported. Default is “backward”.
- Return type:
- Returns:
A real-valued array containing the one-dimensional discrete Fourier transform of
aby exploiting its inherent Hermitian-symmetry, having a dimension ofnalongaxis.
See also
jax.numpy.fft.ihfft: Computes a one-dimensional inverse FFT of an array whose spectrum has Hermitian symmetry.jax.numpy.fft.fft: Computes a one-dimensional discrete Fourier transform.jax.numpy.fft.rfft: Computes a one-dimensional discrete Fourier transform of a real-valued input.
Examples
>>> x = jnp.array([[1, 3, 5, 7], ... [2, 4, 6, 8]]) >>> jnp.fft.hfft(x) Array([[24., -8., 0., -2., 0., -8.], [30., -8., 0., -2., 0., -8.]], dtype=float32)
This value is equal to the real component of the discrete Fourier transform of the following array
x1computed usingjnp.fft.fft.>>> x1 = jnp.array([[1, 3, 5, 7, 5, 3], ... [2, 4, 6, 8, 6, 4]]) >>> jnp.fft.fft(x1) Array([[24.+0.j, -8.+0.j, 0.+0.j, -2.+0.j, 0.+0.j, -8.+0.j], [30.+0.j, -8.+0.j, 0.+0.j, -2.+0.j, 0.+0.j, -8.+0.j]], dtype=complex64) >>> jnp.allclose(jnp.fft.hfft(x), jnp.fft.fft(x1)) Array(True, dtype=bool)
To obtain an odd-length output from
jnp.fft.hfft,nmust be specified with an odd value, as the default behavior produces an even-length result along the specifiedaxis.>>> with jnp.printoptions(precision=2, suppress=True): ... print(jnp.fft.hfft(x, n=5)) [[17. -5.24 -0.76 -0.76 -5.24] [22. -5.24 -0.76 -0.76 -5.24]]
When
n=3andaxis=0, dimension of the transform alongaxis 0will be3and dimension along other axes will be same as that of input.>>> jnp.fft.hfft(x, n=3, axis=0) Array([[ 5., 11., 17., 23.], [-1., -1., -1., -1.], [-1., -1., -1., -1.]], dtype=float32)
xcan be reconstructed (but of complex datatype) usingjnp.fft.ihfftfrom the result ofjnp.fft.hfft, only whennis specified as2*(m-1)if m is even or2*m-1ifmis odd, wheremis the dimension of input alongaxis.>>> jnp.fft.ihfft(jnp.fft.hfft(x, 2*(x.shape[-1]-1))) Array([[1.+0.j, 3.+0.j, 5.+0.j, 7.+0.j], [2.+0.j, 4.+0.j, 6.+0.j, 8.+0.j]], dtype=complex64) >>> jnp.allclose(x, jnp.fft.ihfft(jnp.fft.hfft(x, 2*(x.shape[-1]-1)))) Array(True, dtype=bool)
For complex-valued inputs:
>>> x2 = jnp.array([[1+2j, 3-4j, 5+6j], ... [2-3j, 4+5j, 6-7j]]) >>> jnp.fft.hfft(x2) Array([[ 12., -12., 0., 4.], [ 16., 6., 0., -14.]], dtype=float32)
- scico.numpy.fft.ifft(a, n=None, axis=-1, norm=None)¶
Compute a one-dimensional inverse discrete Fourier transform.
JAX implementation of
numpy.fft.ifft.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input arrayn (
int|None) – int. Specifies the dimension of the result alongaxis. If not specified, it will default to the dimension ofaalongaxis.axis (
int) – int, default=-1. Specifies the axis along which the transform is computed. If not specified, the transform is computed along axis -1.norm (
str|None) – string. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
An array containing the one-dimensional discrete Fourier transform of
a.
See also
jax.numpy.fft.fft: Computes a one-dimensional discrete Fourier transform.jax.numpy.fft.fftn: Computes a multidimensional discrete Fourier transform.jax.numpy.fft.ifftn: Computes a multidimensional inverse of discrete Fourier transform.
Examples
jnp.fft.ifftcomputes the transform alongaxis -1by default.>>> x = jnp.array([[3, 1, 4, 6], ... [2, 5, 7, 1]]) >>> jnp.fft.ifft(x) Array([[ 3.5 +0.j , -0.25-1.25j, 0. +0.j , -0.25+1.25j], [ 3.75+0.j , -1.25+1.j , 0.75+0.j , -1.25-1.j ]], dtype=complex64)
When
n=5, dimension of the transform along axis -1 will be5and dimension along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... print(jnp.fft.ifft(x, n=5)) [[ 2.8 +0.j -0.96-0.04j 1.06+0.5j 1.06-0.5j -0.96+0.04j] [ 3. +0.j -0.59+1.66j 0.09-0.55j 0.09+0.55j -0.59-1.66j]]
When
n=3andaxis=0, dimension of the transform alongaxis 0will be3and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... print(jnp.fft.ifft(x, n=3, axis=0)) [[ 1.67+0.j 2. +0.j 3.67+0.j 2.33+0.j ] [ 0.67+0.58j -0.5 +1.44j 0.17+2.02j 1.83+0.29j] [ 0.67-0.58j -0.5 -1.44j 0.17-2.02j 1.83-0.29j]]
- scico.numpy.fft.ifft2(a, s=None, axes=(-2, -1), norm=None)¶
Compute a two-dimensional inverse discrete Fourier transform.
JAX implementation of
numpy.fft.ifft2.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input array. Must havea.ndim >= 2.s (
Sequence[int] |None) – optional length-2 sequence of integers. Specifies the size of the output in each specified axis. If not specified, it will default to the size ofaalong the specifiedaxes.axes (
Sequence[int]) – optional length-2 sequence of integers, default=(-2,-1). Specifies the axes along which the transform is computed.norm (
str|None) – string, default=”backward”. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
An array containing the two-dimensional inverse discrete Fourier transform of
aalong givenaxes.
See also
jax.numpy.fft.ifft: Computes a one-dimensional inverse discrete Fourier transform.jax.numpy.fft.ifftn: Computes a multidimensional inverse discrete Fourier transform.jax.numpy.fft.fft2: Computes a two-dimensional discrete Fourier transform.
Examples
jnp.fft.ifft2computes the transform along the last two axes by default.>>> x = jnp.array([[[1, 3], ... [2, 4]], ... [[5, 7], ... [6, 8]]]) >>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.ifft2(x) Array([[[ 2.5+0.j, -1. +0.j], [-0.5+0.j, 0. +0.j]], [[ 6.5+0.j, -1. +0.j], [-0.5+0.j, 0. +0.j]]], dtype=complex64)
When
s=[2, 3], dimension of the transform alongaxes (-2, -1)will be(2, 3)and dimension along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.ifft2(x, s=[2, 3]) Array([[[ 1.67+0.j , -0.08+1.01j, -0.08-1.01j], [-0.33+0.j , -0.08-0.14j, -0.08+0.14j]], [[ 4.33+0.j , 0.58+2.17j, 0.58-2.17j], [-0.33+0.j , -0.08-0.14j, -0.08+0.14j]]], dtype=complex64)
When
s=[2, 3]andaxes=(0, 1), shape of the transform alongaxes (0, 1)will be(2, 3)and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.ifft2(x, s=[2, 3], axes=(0, 1)) Array([[[ 2.33+0.j , 3.67+0.j ], [ 0.33+1.15j, 0.67+1.73j], [ 0.33-1.15j, 0.67-1.73j]], [[-1.33+0.j , -1.33+0.j ], [-0.33-0.58j, -0.33-0.58j], [-0.33+0.58j, -0.33+0.58j]]], dtype=complex64)
- scico.numpy.fft.ifftn(a, s=None, axes=None, norm=None)¶
Compute a multidimensional inverse discrete Fourier transform.
JAX implementation of
numpy.fft.ifftn.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input arrays (
Sequence[int] |None) – sequence of integers. Specifies the shape of the result. If not specified, it will default to the shape ofaalong the specifiedaxes.axes (
Sequence[int] |None) – sequence of integers, default=None. Specifies the axes along which the transform is computed. If None, computes the transform along all the axes.norm (
str|None) – string. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
An array containing the multidimensional inverse discrete Fourier transform of
a.
See also
jax.numpy.fft.fftn: Computes a multidimensional discrete Fourier transform.jax.numpy.fft.fft: Computes a one-dimensional discrete Fourier transform.jax.numpy.fft.ifft: Computes a one-dimensional inverse discrete Fourier transform.
Examples
jnp.fft.ifftncomputes the transform along all the axes by default whenaxesargument isNone.>>> x = jnp.array([[1, 2, 5, 3], ... [4, 1, 2, 6], ... [5, 3, 2, 1]]) >>> with jnp.printoptions(precision=2, suppress=True): ... print(jnp.fft.ifftn(x)) [[ 2.92+0.j 0.08-0.33j 0.25+0.j 0.08+0.33j] [-0.08+0.14j -0.04-0.03j 0. -0.29j -1.05-0.11j] [-0.08-0.14j -1.05+0.11j 0. +0.29j -0.04+0.03j]]
When
s=[3], dimension of the transform alongaxis -1will be3and dimension along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... print(jnp.fft.ifftn(x, s=[3])) [[ 2.67+0.j -0.83-0.87j -0.83+0.87j] [ 2.33+0.j 0.83-0.29j 0.83+0.29j] [ 3.33+0.j 0.83+0.29j 0.83-0.29j]]
When
s=[2]andaxes=[0], dimension of the transform alongaxis 0will be2and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... print(jnp.fft.ifftn(x, s=[2], axes=[0])) [[ 2.5+0.j 1.5+0.j 3.5+0.j 4.5+0.j] [-1.5+0.j 0.5+0.j 1.5+0.j -1.5+0.j]]
When
s=[2, 3], shape of the transform will be(2, 3).>>> with jnp.printoptions(precision=2, suppress=True): ... print(jnp.fft.ifftn(x, s=[2, 3])) [[ 2.5 +0.j 0. -0.58j 0. +0.58j] [ 0.17+0.j -0.83-0.29j -0.83+0.29j]]
- scico.numpy.fft.ifftshift(x, axes=None)¶
The inverse of
jax.numpy.fft.fftshift.JAX implementation of
numpy.fft.ifftshift.- Parameters:
- Return type:
- Returns:
A shifted copy of
x.
See also
jax.numpy.fft.fftshift: inverse ofifftshift.jax.numpy.fft.fftfreq: generate FFT frequencies.
Examples
Generate FFT frequencies with
fftfreq:>>> freq = jnp.fft.fftfreq(5) >>> freq Array([ 0. , 0.2, 0.4, -0.4, -0.2], dtype=float32)
Use
fftshiftto shift the zero-frequency entry to the middle of the array:>>> shifted_freq = jnp.fft.fftshift(freq) >>> shifted_freq Array([-0.4, -0.2, 0. , 0.2, 0.4], dtype=float32)
Unshift with
ifftshiftto recover the original frequencies:>>> jnp.fft.ifftshift(shifted_freq) Array([ 0. , 0.2, 0.4, -0.4, -0.2], dtype=float32)
- scico.numpy.fft.ihfft(a, n=None, axis=-1, norm=None)¶
Compute a 1-D inverse FFT of an array whose spectrum has Hermitian-symmetry.
JAX implementation of
numpy.fft.ihfft.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input array.n (
int|None) – optional, int. Specifies the effective dimension of the input alongaxis. If not specified, it will default to the dimension of input alongaxis.axis (
int) – optional, int, default=-1. Specifies the axis along which the transform is computed. If not specified, the transform is computed along axis -1.norm (
str|None) – optional, string. The normalization mode. “backward”, “ortho” and “forward” are supported. Default is “backward”.
- Return type:
- Returns:
An array containing one-dimensional discrete Fourier transform of
aby exploiting its inherent Hermitian symmetry. The dimension of the array alongaxisis(n/2)+1, ifnis even and(n+1)/2, ifnis odd.
See also
jax.numpy.fft.hfft: Computes a one-dimensional FFT of an array whose spectrum has Hermitian symmetry.jax.numpy.fft.fft: Computes a one-dimensional discrete Fourier transform.jax.numpy.fft.rfft: Computes a one-dimensional discrete Fourier transform of a real-valued input.
Examples
>>> x = jnp.array([[1, 3, 5, 7], ... [2, 4, 6, 8]]) >>> jnp.fft.ihfft(x) Array([[ 4.+0.j, -1.-1.j, -1.-0.j], [ 5.+0.j, -1.-1.j, -1.-0.j]], dtype=complex64)
When
n=4andaxis=0, dimension of the transform alongaxis 0will be(4/2)+1 =3and dimension along other axes will be same as that of input.>>> jnp.fft.ihfft(x, n=4, axis=0) Array([[ 0.75+0.j , 1.75+0.j , 2.75+0.j , 3.75+0.j ], [ 0.25+0.5j, 0.75+1.j , 1.25+1.5j, 1.75+2.j ], [-0.25-0.j , -0.25-0.j , -0.25-0.j , -0.25-0.j ]], dtype=complex64)
- scico.numpy.fft.irfft(a, n=None, axis=-1, norm=None)¶
Compute a real-valued one-dimensional inverse discrete Fourier transform.
JAX implementation of
numpy.fft.irfft.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input array.n (
int|None) – int. Specifies the dimension of the result alongaxis. If not specified,n = 2*(m-1), wheremis the dimension ofaalongaxis.axis (
int) – int, default=-1. Specifies the axis along which the transform is computed. If not specified, the transform is computed along axis -1.norm (
str|None) – string. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
A real-valued array containing the one-dimensional inverse discrete Fourier transform of
a, with a dimension ofnalongaxis.
See also
jax.numpy.fft.ifft: Computes a one-dimensional inverse discrete Fourier transform.jax.numpy.fft.irfft: Computes a one-dimensional inverse discrete Fourier transform for real input.jax.numpy.fft.rfftn: Computes a multidimensional discrete Fourier transform for real input.jax.numpy.fft.irfftn: Computes a multidimensional inverse discrete Fourier transform for real input.
Examples
jnp.fft.rfftcomputes the transform alongaxis -1by default.>>> x = jnp.array([[1, 3, 5], ... [2, 4, 6]]) >>> jnp.fft.irfft(x) Array([[ 3., -1., 0., -1.], [ 4., -1., 0., -1.]], dtype=float32)
When
n=3, dimension of the transform along axis -1 will be3and dimension along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.irfft(x, n=3) Array([[ 2.33, -0.67, -0.67], [ 3.33, -0.67, -0.67]], dtype=float32)
When
n=4andaxis=0, dimension of the transform alongaxis 0will be4and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.irfft(x, n=4, axis=0) Array([[ 1.25, 2.75, 4.25], [ 0.25, 0.75, 1.25], [-0.75, -1.25, -1.75], [ 0.25, 0.75, 1.25]], dtype=float32)
- scico.numpy.fft.irfft2(a, s=None, axes=(-2, -1), norm=None)¶
Compute a real-valued two-dimensional inverse discrete Fourier transform.
JAX implementation of
numpy.fft.irfft2.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input array. Must havea.ndim >= 2.s (
Sequence[int] |None) – optional length-2 sequence of integers. Specifies the size of the output in each specified axis. If not specified, the dimension of output along axisaxes[1]is2*(m-1),mis the size of input along axisaxes[1]and the dimension along other axes will be the same as that of input.axes (
Sequence[int]) – optional length-2 sequence of integers, default=(-2,-1). Specifies the axes along which the transform is computed.norm (
str|None) – string, default=”backward”. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
A real-valued array containing the two-dimensional inverse discrete Fourier transform of
a.
See also
jax.numpy.fft.rfft2: Computes a two-dimensional discrete Fourier transform of a real-valued array.jax.numpy.fft.irfft: Computes a real-valued one-dimensional inverse discrete Fourier transform.jax.numpy.fft.irfftn: Computes a real-valued multidimensional inverse discrete Fourier transform.
Examples
jnp.fft.irfft2computes the transform along the last two axes by default.>>> x = jnp.array([[[1, 3, 5], ... [2, 4, 6]], ... [[7, 9, 11], ... [8, 10, 12]]]) >>> jnp.fft.irfft2(x) Array([[[ 3.5, -1. , 0. , -1. ], [-0.5, 0. , 0. , 0. ]], [[ 9.5, -1. , 0. , -1. ], [-0.5, 0. , 0. , 0. ]]], dtype=float32)
When
s=[3, 3], dimension of the transform alongaxes (-2, -1)will be(3, 3)and dimension along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.irfft2(x, s=[3, 3]) Array([[[ 1.89, -0.44, -0.44], [ 0.22, -0.78, 0.56], [ 0.22, 0.56, -0.78]], [[ 5.89, -0.44, -0.44], [ 1.22, -1.78, 1.56], [ 1.22, 1.56, -1.78]]], dtype=float32)
When
s=[2, 3]andaxes=(0, 1), shape of the transform alongaxes (0, 1)will be(2, 3)and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.irfft2(x, s=[2, 3], axes=(0, 1)) Array([[[ 4.67, 6.67, 8.67], [-0.33, -0.33, -0.33], [-0.33, -0.33, -0.33]], [[-3. , -3. , -3. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]]], dtype=float32)
- scico.numpy.fft.irfftn(a, s=None, axes=None, norm=None)¶
Compute a real-valued multidimensional inverse discrete Fourier transform.
JAX implementation of
numpy.fft.irfftn.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – input array.s (
Sequence[int] |None) – optional sequence of integers. Specifies the size of the output in each specified axis. If not specified, the dimension of output along axisaxes[-1]is2*(m-1),mis the size of input along axisaxes[-1]and the dimension along other axes will be the same as that of input.axes (
Sequence[int] |None) – optional sequence of integers, default=None. Specifies the axes along which the transform is computed. If not specified, the transform is computed along the lastlen(s)axes. If neitheraxesnorsis specified, the transform is computed along all the axes.norm (
str|None) – string, default=”backward”. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
A real-valued array containing the multidimensional inverse discrete Fourier transform of
awith sizesalong specifiedaxes, and the same as the input along other axes.
See also
jax.numpy.fft.rfftn: Computes a multidimensional discrete Fourier transform of a real-valued array.jax.numpy.fft.irfft: Computes a real-valued one-dimensional inverse discrete Fourier transform.jax.numpy.fft.irfft2: Computes a real-valued two-dimensional inverse discrete Fourier transform.
Examples
jnp.fft.irfftncomputes the transform along all the axes by default.>>> x = jnp.array([[[1, 3, 5], ... [2, 4, 6]], ... [[7, 9, 11], ... [8, 10, 12]]]) >>> jnp.fft.irfftn(x) Array([[[ 6.5, -1. , 0. , -1. ], [-0.5, 0. , 0. , 0. ]], [[-3. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. ]]], dtype=float32)
When
s=[3, 4], size of the transform alongaxes (-2, -1)will be(3, 4)and size along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.irfftn(x, s=[3, 4]) Array([[[ 2.33, -0.67, 0. , -0.67], [ 0.33, -0.74, 0. , 0.41], [ 0.33, 0.41, 0. , -0.74]], [[ 6.33, -0.67, 0. , -0.67], [ 1.33, -1.61, 0. , 1.28], [ 1.33, 1.28, 0. , -1.61]]], dtype=float32)
When
s=[3]andaxes=[0], size of the transform alongaxes 0will be3and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.irfftn(x, s=[3], axes=[0]) Array([[[ 5., 7., 9.], [ 6., 8., 10.]], [[-2., -2., -2.], [-2., -2., -2.]], [[-2., -2., -2.], [-2., -2., -2.]]], dtype=float32)
- scico.numpy.fft.rfft(a, n=None, axis=-1, norm=None)¶
Compute a one-dimensional discrete Fourier transform of a real-valued array.
JAX implementation of
numpy.fft.rfft.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – real-valued input array.n (
int|None) – int. Specifies the effective dimension of the input alongaxis. If not specified, it will default to the dimension of input alongaxis.axis (
int) – int, default=-1. Specifies the axis along which the transform is computed. If not specified, the transform is computed along axis -1.norm (
str|None) – string. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
An array containing the one-dimensional discrete Fourier transform of
a. The dimension of the array alongaxisis(n/2)+1, ifnis even and(n+1)/2, ifnis odd.
See also
jax.numpy.fft.fft: Computes a one-dimensional discrete Fourier transform.jax.numpy.fft.irfft: Computes a one-dimensional inverse discrete Fourier transform for real input.jax.numpy.fft.rfftn: Computes a multidimensional discrete Fourier transform for real input.jax.numpy.fft.irfftn: Computes a multidimensional inverse discrete Fourier transform for real input.
Examples
jnp.fft.rfftcomputes the transform alongaxis -1by default.>>> x = jnp.array([[1, 3, 5], ... [2, 4, 6]]) >>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.rfft(x) Array([[ 9.+0.j , -3.+1.73j], [12.+0.j , -3.+1.73j]], dtype=complex64)
When
n=5, dimension of the transform along axis -1 will be(5+1)/2 =3and dimension along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.rfft(x, n=5) Array([[ 9. +0.j , -2.12-5.79j, 0.12+2.99j], [12. +0.j , -1.62-7.33j, 0.62+3.36j]], dtype=complex64)
When
n=4andaxis=0, dimension of the transform alongaxis 0will be(4/2)+1 =3and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.rfft(x, n=4, axis=0) Array([[ 3.+0.j, 7.+0.j, 11.+0.j], [ 1.-2.j, 3.-4.j, 5.-6.j], [-1.+0.j, -1.+0.j, -1.+0.j]], dtype=complex64)
- scico.numpy.fft.rfft2(a, s=None, axes=(-2, -1), norm=None)¶
Compute a two-dimensional discrete Fourier transform of a real-valued array.
JAX implementation of
numpy.fft.rfft2.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – real-valued input array. Must havea.ndim >= 2.s (
Sequence[int] |None) – optional length-2 sequence of integers. Specifies the effective size of the output along each specified axis. If not specified, it will default to the dimension of input alongaxes.axes (
Sequence[int]) – optional length-2 sequence of integers, default=(-2,-1). Specifies the axes along which the transform is computed.norm (
str|None) – string, default=”backward”. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
An array containing the two-dimensional discrete Fourier transform of
a. The size of the output along the axisaxes[1]is(s[1]/2)+1, ifs[1]is even and(s[1]+1)/2, ifs[1]is odd. The size of the output along the axisaxes[0]iss[0].
See also
jax.numpy.fft.rfft: Computes a one-dimensional discrete Fourier transform of real-valued array.jax.numpy.fft.rfftn: Computes a multidimensional discrete Fourier transform of real-valued array.jax.numpy.fft.irfft2: Computes a real-valued two-dimensional inverse discrete Fourier transform.
Examples
jnp.fft.rfft2computes the transform along the last two axes by default.>>> x = jnp.array([[[1, 3, 5], ... [2, 4, 6]], ... [[7, 9, 11], ... [8, 10, 12]]]) >>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.rfft2(x) Array([[[21.+0.j , -6.+3.46j], [-3.+0.j , 0.+0.j ]], [[57.+0.j , -6.+3.46j], [-3.+0.j , 0.+0.j ]]], dtype=complex64)
When
s=[2, 4], dimension of the transform alongaxis -2will be2, alongaxis -1will be(4/2)+1) = 3and dimension along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.rfft2(x, s=[2, 4]) Array([[[21. +0.j, -8. -7.j, 7. +0.j], [-3. +0.j, 0. +1.j, -1. +0.j]], [[57. +0.j, -8.-19.j, 19. +0.j], [-3. +0.j, 0. +1.j, -1. +0.j]]], dtype=complex64)
When
s=[3, 5]andaxes=(0, 1), shape of the transform alongaxis 0will be3, alongaxis 1will be(5+1)/2 = 3and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.rfft2(x, s=[3, 5], axes=(0, 1)) Array([[[ 18. +0.j , 26. +0.j , 34. +0.j ], [ 11.09 -9.51j, 16.33-13.31j, 21.56-17.12j], [ -0.09 -5.88j, 0.67 -8.23j, 1.44-10.58j]], [[ -4.5 -12.99j, -2.5 -16.45j, -0.5 -19.92j], [ -9.71 -6.3j , -10.05 -9.52j, -10.38-12.74j], [ -4.95 +0.72j, -5.78 -0.2j , -6.61 -1.12j]], [[ -4.5 +12.99j, -2.5 +16.45j, -0.5 +19.92j], [ 3.47+10.11j, 6.43+11.42j, 9.38+12.74j], [ 3.19 +1.63j, 4.4 +1.38j, 5.61 +1.12j]]], dtype=complex64)
- scico.numpy.fft.rfftfreq(n, d=1.0, *, dtype=None, device=None)¶
Return sample frequencies for the discrete Fourier transform.
JAX implementation of
numpy.fft.fftfreq. Returns frequencies appropriate for use with the outputs ofrfftandirfft.- Parameters:
n (
int) – length of the FFT windowd (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – optional scalar sample spacing (default: 1.0)dtype (
Union[str,type[Any],dtype,SupportsDType,None]) – optional dtype of returned frequencies. If not specified, JAX’s default floating point dtype will be used.device (
Device|Sharding|None) – optionalDeviceorShardingto which the created array will be committed.
- Return type:
- Returns:
Array of sample frequencies, length
n // 2 + 1.
See also
jax.numpy.fft.fftfreq: frequencies for use withfftandifft.
- scico.numpy.fft.rfftn(a, s=None, axes=None, norm=None)¶
Compute a multidimensional discrete Fourier transform of a real-valued array.
JAX implementation of
numpy.fft.rfftn.- Parameters:
a (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – real-valued input array.s (
Sequence[int] |None) – optional sequence of integers. Controls the effective size of the input along each specified axis. If not specified, it will default to the dimension of input alongaxes.axes (
Sequence[int] |None) – optional sequence of integers, default=None. Specifies the axes along which the transform is computed. If not specified, the transform is computed along the lastlen(s)axes. If neitheraxesnorsis specified, the transform is computed along all the axes.norm (
str|None) – string, default=”backward”. The normalization mode. “backward”, “ortho” and “forward” are supported.
- Return type:
- Returns:
An array containing the multidimensional discrete Fourier transform of
ahaving size specified insalong the axesaxesexcept along the axisaxes[-1]. The size of the output along the axisaxes[-1]iss[-1]//2+1.
See also
jax.numpy.fft.rfft: Computes a one-dimensional discrete Fourier transform of real-valued array.jax.numpy.fft.rfft2: Computes a two-dimensional discrete Fourier transform of real-valued array.jax.numpy.fft.irfftn: Computes a real-valued multidimensional inverse discrete Fourier transform.
Examples
>>> x = jnp.array([[[1, 3, 5], ... [2, 4, 6]], ... [[7, 9, 11], ... [8, 10, 12]]]) >>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.rfftn(x) Array([[[ 78.+0.j , -12.+6.93j], [ -6.+0.j , 0.+0.j ]], [[-36.+0.j , 0.+0.j ], [ 0.+0.j , 0.+0.j ]]], dtype=complex64)
When
s=[3, 3, 4], size of the transform alongaxes (-3, -2)will be (3, 3), and alongaxis -1will be4//2+1 = 3and size along other axes will be the same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.rfftn(x, s=[3, 3, 4]) Array([[[ 78. +0.j , -16. -26.j , 26. +0.j ], [ 15. -36.37j, -16.12 +1.93j, 5. -12.12j], [ 15. +36.37j, 8.12-11.93j, 5. +12.12j]], [[ -7.5 -49.36j, -20.45 +9.43j, -2.5 -16.45j], [-25.5 -7.79j, -0.6 +11.96j, -8.5 -2.6j ], [ 19.5 -12.99j, -8.33 -6.5j , 6.5 -4.33j]], [[ -7.5 +49.36j, 12.45 -4.43j, -2.5 +16.45j], [ 19.5 +12.99j, 0.33 -6.5j , 6.5 +4.33j], [-25.5 +7.79j, 4.6 +5.04j, -8.5 +2.6j ]]], dtype=complex64)
When
s=[3, 5]andaxes=(0, 1), size of the transform alongaxis 0will be3, alongaxis 1will be5//2+1 = 3and dimension along other axes will be same as that of input.>>> with jnp.printoptions(precision=2, suppress=True): ... jnp.fft.rfftn(x, s=[3, 5], axes=[0, 1]) Array([[[ 18. +0.j , 26. +0.j , 34. +0.j ], [ 11.09 -9.51j, 16.33-13.31j, 21.56-17.12j], [ -0.09 -5.88j, 0.67 -8.23j, 1.44-10.58j]], [[ -4.5 -12.99j, -2.5 -16.45j, -0.5 -19.92j], [ -9.71 -6.3j , -10.05 -9.52j, -10.38-12.74j], [ -4.95 +0.72j, -5.78 -0.2j , -6.61 -1.12j]], [[ -4.5 +12.99j, -2.5 +16.45j, -0.5 +19.92j], [ 3.47+10.11j, 6.43+11.42j, 9.38+12.74j], [ 3.19 +1.63j, 4.4 +1.38j, 5.61 +1.12j]]], dtype=complex64)
For 1-D input:
>>> x1 = jnp.array([1, 2, 3, 4]) >>> jnp.fft.rfftn(x1) Array([10.+0.j, -2.+2.j, -2.+0.j], dtype=complex64)