That's what A_mul_B! does.

On Tue, Oct 18, 2016 at 1:45 PM, Jérémy Béjanin <jeremy.beja...@gmail.com>
wrote:

> I think this is something I might have read about in the past, but are
> there plans to make y = a*b use an already allocated y?
>
> On Tuesday, October 18, 2016 at 12:38:00 PM UTC-4, Stefan Karpinski wrote:
>>
>>   A_mul_B!(Y, A, B) -> Y
>>
>>   Calculates the matrix-matrix or matrix-vector product A⋅B and stores
>> the result in Y, overwriting the
>>   existing value of Y. Note that Y must not be aliased with either A or B.
>>
>>   julia> A=[1.0 2.0; 3.0 4.0]; B=[1.0 1.0; 1.0 1.0]; Y = similar(B);
>> A_mul_B!(Y, A, B);
>>
>>   julia> Y
>>   2×2 Array{Float64,2}:
>>    3.0  3.0
>>    7.0  7.0
>>
>> On Tue, Oct 18, 2016 at 10:27 AM, <zamani.m...@gmail.com> wrote:
>>
>>> hi guys
>>> is there a way to reduce allocated memory in matrix multiplications?
>>>
>>> for example this code blew in my machine gives :
>>>
>>> function test4(n)
>>>   a = rand(n,n)
>>>   for i = 1:100
>>>      a*a
>>>    end
>>>  end
>>>
>>>
>>> ---------------------- answer  ----------------------
>>> test4(1)
>>> # force compiling
>>>
>>> @time test4(1000)
>>> 16.589743 seconds (433 allocations: 770.587 MB, 0.68% gc time)
>>>
>>
>>

Reply via email to