Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K
JAX  documentation - Home

jax.numpy.fft.hfft

Contents

jax.numpy.fft.hfft#

jax.numpy.fft.hfft(a,n=None,axis=-1,norm=None)[source]#

Compute a 1-D FFT of an array whose spectrum has Hermitian symmetry.

JAX implementation ofnumpy.fft.hfft().

Parameters:
  • a (ArrayLike) – input array.

  • n (int |None) – optional, int. Specifies the dimension of the result alongaxis. Ifnot specified,n=2*(m-1), wherem is the dimension ofaalongaxis.

  • axis (int) – optional, int, default=-1. Specifies the axis along which the transformis 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”.

Returns:

A real-valued array containing the one-dimensional discrete Fourier transformofa by exploiting its inherent Hermitian-symmetry, having a dimension ofn alongaxis.

Return type:

Array

See also

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 transformof the following arrayx1 computed 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 fromjnp.fft.hfft,n must be specifiedwith an odd value, as the default behavior produces an even-length resultalong the specifiedaxis.

>>>withjnp.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]]

Whenn=3 andaxis=0, dimension of the transform alongaxis0 willbe3 and 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)

x can be reconstructed (but of complex datatype) usingjnp.fft.ihfftfrom the result ofjnp.fft.hfft, only whenn is specified as2*(m-1)ifm is even or2*m-1 ifm is odd, wherem is the dimension ofinput 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)
Contents

[8]ページ先頭

©2009-2025 Movatter.jp