Skip to content

Instantly share code, notes, and snippets.

@simonbyrne
Last active August 29, 2015 14:18
Show Gist options
  • Save simonbyrne/91c0aa3350a45d9068a3 to your computer and use it in GitHub Desktop.
Save simonbyrne/91c0aa3350a45d9068a3 to your computer and use it in GitHub Desktop.
function sincos(x::Float64)
s = Ref{Float64}()
c = Ref{Float64}()
ccall((:sincos,Base.Math.libm),Void,(Float64,Ref{Float64},Ref{Float64}),x,s,c)
return s.x, c.x
end
function test_sep(X)
t = 0.0
for x in X
t += sin(x) + cos(x)
end
t
end
function test_comb(X)
t = 0.0
for x in X
s,c = sincos(x)
t += s+c
end
t
end
X = 10*rand(10_000_000)
@time test_sep(X)
@time test_comb(X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment