Dot product of multi-dimensional arrays

Ok, thanks. You don’t want .* here at all–it’s not a “dot product” in the linear algebra sense, it’s an elementwise product.

Note also that the v you get from Julia is the adjoint of what you got in Python, but that’s easy to deal with. We can also use Diagonal to create a very cheap reference to s that behaves like a diagonal matrix, without actually filling in all the pointless zeros:

julia> h = v * Diagonal(s) * v'
5×5 Matrix{Float64}:
 0.447214  0.0      0.0  0.0  0.894427
 0.0       2.82843  0.0  0.0  0.0
 0.0       0.0      3.0  0.0  0.0
 0.0       0.0      0.0  0.0  0.0
 0.894427  0.0      0.0  0.0  1.78885
4 Likes