On Monday, October 5, 2015 at 10:21:08 AM UTC-4, Patrick Kofod Mogensen 
wrote:
>
> Say I have an array with come results of a computation, and I have to do 
> this computation many times. I want to use the memory I've already 
> allocated, but I want to start from zero. Is the best way to zero an array:
>
> A = rand(3000,3000)
> A[:] = 0.
>
> Or is there a better way?
>

No, I don't think so.

A = rand(3000,3000)
@time A[:] = 0.
@time fill!(A, 0.);
@time ccall(:memset, Ptr{Void}, (Ptr{Void}, Cint, Csize_t), A, 0, 
sizeof(A)) 


all give about the same time on my machine.

Reply via email to