Created
February 14, 2019 19:34
-
-
Save tclements/02ae40dc26571292c909cc624a8943f5 to your computer and use it in GitHub Desktop.
sin, cos, exp with complex numbers on 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 | |
using CuArrays | |
import Base.sin, Base.cos, Base.exp | |
function sin(A::GPUArray{ComplexF64}) | |
return sin.(real(A)) .* cosh.(imag(A)) .+ im .* cos.(real(A)) .* sinh.(imag(A)) | |
end | |
function cos(A::GPUArray{ComplexF64}) | |
return cos.(real(A)) .* cosh.(imag(A)) .- im .* sin.(real(A)) .* sinh.(imag(A)) | |
end | |
function exp(A::GPUArray{ComplexF64}) | |
return exp.(real(A)) .* (cos.(imag(A)) .+ im .* sin.(imag(A))) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment