You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Left-multiplication of a vector of length N by an N-by-N diagonal matrix should require a total of N multiplications. However, there are certain cases when (at least according to GFlops.jl) Julia appears to perform an additional N additions, effectively doubling the cost of such an operation. For example, the following code, which uses an out-of-place matrix-vector multiplication,
using LinearAlgebra, GFlops
A =Diagonal(rand(10))
x =rand(10)
@count_ops y = A * x
Left-multiplication of a vector of length N by an N-by-N diagonal matrix should require a total of N multiplications. However, there are certain cases when (at least according to GFlops.jl) Julia appears to perform an additional N additions, effectively doubling the cost of such an operation. For example, the following code, which uses an out-of-place matrix-vector multiplication,
produces the following output:
However, the equivalent in-place operation,
returns the following:
It seems like these additions are not necessary; the same operation could be done without any addition as follows:
Is this an oversight or is there a reason for such behaviour?
The text was updated successfully, but these errors were encountered: