How about you do it in a loop (note this should be done in a function... globals will ruin performance):
C = Array(n,n-1) for i in 2:i for j in 1:j C[i,j] = A[i,1] * B[j,i] end end On Mon, Sep 14, 2015 at 8:45 PM, Patrick Kofod Mogensen < patrick.mogen...@gmail.com> wrote: > Sorry, something went wrong with my description. It was supposed to be: > > C =A[2:end, 1]' .* B[:, 2:end] > > A is n-by-2 and B is n-by-n (difference!). So B[:, 2:end] is n-by-(n-1) > and I expect C to be n-by-(n-1). Sorry for this mistakes! > > > > On Monday, September 14, 2015 at 8:39:59 PM UTC-4, Tom Breloff wrote: >> >> What size do you expect your result to be? Are you creating a 1 x (b-1) >> row vector? If so, I would check out the ArrayViews package and do >> something like: >> >> using ArrayViews >> A1 = view(A,:,1) >> C = Float64[dot(A1, view(B,:,i)) for in 2:size(B,2)] >> >> On Mon, Sep 14, 2015 at 7:27 PM, Patrick Kofod Mogensen < >> patrick....@gmail.com> wrote: >> >>> I have a line in my code that seems to really allocate a lot of memory, >>> and I think it might be slowing down my program. I have two matrices. The >>> first matrix A is n-by-2 and the second matrix B is n-by-b. What I need to >>> do is to multiply the first column of A element by element to each row in >>> B[:, 2:end]. I use broadcasting (.*) to achieve this along with a transpose >>> of A[:,1]: >>> >>> C=A[:,1]'.*B[:,2:end] >>> >>> However, it seems to allocate a lot of temporary memory (the number >>> memory number in .mem overflows even for small problems). Is there anything >>> I can do here? >>> >>> >>> P >>> >> >>