Columnwise/rowwise elementwise multiplication?

array

#1

Is there an easier way of element-wise multiplying a vector, x, by each column in an array? Below I do it with a for loop. I’ve tried using mapslices but I still need to broadcast x over each slice.

julia> x = [1;2;3]
3-element Array{Int64,1}:
 1
 2
 3

julia> y = [1 2 3 4 5;6 7 8 9 10;11 12 13 14 15]
3×5 Array{Int64,2}:
  1   2   3   4   5
  6   7   8   9  10
 11  12  13  14  15

julia> z = zeros(3,5)
3×5 Array{Float64,2}:
 0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0

julia> for i=1:size(y,2);z[:,i] = x.*y[:,i];end

julia> z
3×5 Array{Float64,2}:
  1.0   2.0   3.0   4.0   5.0
 12.0  14.0  16.0  18.0  20.0
 33.0  36.0  39.0  42.0  45.0


#2
julia> x.*y
3×5 Array{Int64,2}:
  1   2   3   4   5
 12  14  16  18  20
 33  36  39  42  45

julia> Float64.(x.*y)
3×5 Array{Float64,2}:
  1.0   2.0   3.0   4.0   5.0
 12.0  14.0  16.0  18.0  20.0
 33.0  36.0  39.0  42.0  45.0

#3

:man_facepalming:

How I missed that I have no idea. Thanks.