In Julia 0.6.4:
julia> @btime expm([1 0; 2 0])
3.601 μs (46 allocations: 4.55 KiB)
In Julia 0.7 and 1.0:
julia> @btime exp([1 0; 2 0])
16.710 μs (67 allocations: 4.55 KiB)
Any idea what’s causing this? Perhaps the implementation changed as part of the rename?
2 Likes
Thanks. I filed a github issue.
rdeits
4
By the way, if tiny matrix exponentials are actually your target use case, then StaticArrays are 40X faster than even the 0.6 version:
julia> using StaticArrays
julia> m = @SMatrix [1 0; 2 0]
2×2 SArray{Tuple{2,2},Int64,2,4}:
1 0
2 0
julia> using BenchmarkTools
julia> @btime exp($m)
87.196 ns (0 allocations: 0 bytes)
2×2 SArray{Tuple{2,2},Float64,2,4}:
2.71828 0.0
3.43656 1.0
6 Likes
Thanks. That’s very interesting.
And thanks to @kristoffer.carlsson for the quick resolution of the github issue!
DNF
7
Can someone explain this, by the way?
julia> m = @SMatrix [1 0; 2 0];
julia> @btime exp($m);
93.038 ns (0 allocations: 0 bytes)
julia> @btime exp(@SMatrix [1 0; 2 0]);
60.237 ns (0 allocations: 0 bytes)
This seems backwards to me.
It is not backwards. It is the difference between
f(m) = exp(m)
and
f() = exp(@SMatrix [1 0; 2 0]);
In the second, the matrix is a known constant and the function can be further optimized.
1 Like