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 < > [email protected] <javascript:>> 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 >> > >
