You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PR to merge hilbert transform into Jax is pending since a year with credit to @joglekara (thanks!), so we can vendor in the code from there in the meantime,
importscipy.signalasosp_signalfromjax._src.numpy.utilimport_wraps, check_arraylikeimportjax.numpyasjnp@_wraps(osp_signal.hilbert)defhilbert(x, N=None, axis=-1):
check_arraylike('hilbert', x)
x=jnp.asarray(x)
ifx.ndim>1:
raiseNotImplementedError("x must be 1D.")
ifjnp.iscomplexobj(x):
raiseValueError("x must be real.")
ifNisNone:
N=x.shape[axis]
ifN<=0:
raiseValueError("N must be positive.")
Xf=jnp.fft.fft(x, N, axis=axis)
ifN%2==0:
h=jnp.zeros(N, Xf.dtype).at[0].set(1).at[1:N//2].set(2).at[N//2].set(1)
else:
h=jnp.zeros(N, Xf.dtype).at[0].set(1).at[1:(N+1) //2].set(2)
x=jnp.fft.ifft(Xf*h, axis=axis)
returnx
The text was updated successfully, but these errors were encountered:
The PR to merge
hilbert
transform into Jax is pending since a year with credit to @joglekara (thanks!), so we can vendor in the code from there in the meantime,The text was updated successfully, but these errors were encountered: