Closed ericagol closed 3 years ago
Note that in Julia v1.6 sinh
and cosh
are much faster: https://github.com/JuliaLang/julia/pull/37426
Julia v1.5:
julia> using BenchmarkTools
julia> @btime y .= sinh.(x) setup = (x = randn(1000); y = similar(x));
22.414 μs (0 allocations: 0 bytes)
julia> @btime y .= cosh.(x) setup = (x = randn(1000); y = similar(x));
15.094 μs (0 allocations: 0 bytes)
Julia v1.6:
julia> using BenchmarkTools
julia> @btime y .= sinh.(x) setup = (x = randn(1000); y = similar(x));
8.082 μs (0 allocations: 0 bytes)
julia> @btime y .= cosh.(x) setup = (x = randn(1000); y = similar(x));
6.833 μs (0 allocations: 0 bytes)
Thanks, @giordano ! It looks like these are ~twice as fast as the expressions I've written above; nice! Do you know if there is a function like sincos(x)
, but hyperbolic which computes sinh(x)
and cosh(x)
simultaneously (with time savings)?
Hehe, I also looked for it. There doesn't seem to be a sincosh
, but that'd probably a good addition. Mind opening an issue?
Leaving this for now.