Method 1 lowers to getindex
i.e. makes another slice. Method 2 lowers to setindex!
julia> Meta.@lower mul!(out2[:,1], A, b)
:($(Expr(:thunk, CodeInfo(
@ none within `top-level scope`
1 ─ %1 = Base.getindex(out2, :, 1)
│ %2 = A
│ %3 = mul!(%1, %2, b)
└── return %3
))))
julia> Meta.@lower out2[:,1] = A*b
:($(Expr(:thunk, CodeInfo(
@ none within `top-level scope`
1 ─ %1 = A * b
│ Base.setindex!(out2, %1, :, 1)
└── return %1
))))
what is the motivation for using mul!
specifically rather than *
? also I think if you use another view
this will work as intended
# equivalently, mul!(view(out2, :, 1), A, b)
julia> @views mul!(out2[:,1], A, b)
10-element view(::Matrix{Float64}, :, 3) with eltype Float64:
10.0
10.0
10.0
10.0
10.0
10.0
10.0
10.0
10.0
10.0