The best way to check this type is to dump the lowered code with @code_loweredmacro:
julia> @code_lowered A * B * x
CodeInfo(:(begin
nothing
return (Core._apply)(Base.afoldl, (Core.tuple)(Base.*, (a * b) * c), xs)
end))
Like many other languages, Julia does y = (A*B)*xinstead y = A*(B*x), so you need to use parsers explicitly to reduce selection.
julia> using BenchmarkTools
julia> @btime $A * ($B * $x);
6.800 μs (2 allocations: 1.75 KiB)
julia> @btime $A * $B * $x;
45.453 μs (3 allocations: 79.08 KiB)
source
share