and I would like multi each column of x by W element-wise then take the maximum of the column. I should end up with a vector with the same size as the number of coumns of x
The best way I can think of is
[maximum(x[:,j] .* W) for j in 1:size(x, 2)]
but I think there should a more efficient way
Actual, I wanted to do this in Flux.jl so the code is more like
# start random parameters
x = rand(12, 1000)
W = param([1 for i=1:12])
x1 = [maximum(x[:,j] .* W) for j in 1:size(x, 2)]
x .* W allocates an intermediate array of the same shape as x which is not necessary, hence my LazyArrays solution which doesn’t materialize the array.