Created
May 31, 2019 21:52
-
-
Save tclements/d08278b96611a1bf7d6e59382b1e4fc5 to your computer and use it in GitHub Desktop.
Hilbert transform on the GPU with Julia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using GPUArrays, FFTW | |
""" | |
hilbert(x) | |
Computes the analytic representation of x, ``x_a = x + j | |
\\hat{x}``, where ``\\hat{x}`` is the Hilbert transform of x, | |
along the first dimension of x. | |
""" | |
function hilbert(x::GPUArray{T}) where T<:Real | |
N = size(x, 1) | |
Xf = fft(x,1) | |
Xf[2:div(N,2)+isodd(N),:] .*= 2 | |
Xf[div(N,2)+isodd(N)+1:end,:] .*= 0 | |
out = ifft(Xf,1) | |
return out | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment