[julia-users] Best way to minimize memory allocation in iterative method?

2014-12-17 Thread DumpsterDoofus
So I have a piece of code with 4 Float arrays (let's call them temp, arr1, 
arr2, arr3), and this is basically what happens:

for i in [1:1000]
# Some code that modifies the entries of temp.
arr1 = 2*arr2 - arr3 + constants*temp
arr3 = arr2
arr2 = arr1
end

As it turns out, the #Some code that... step is actually only 1/3 of the 
execution time, i.e., the majority of the execution time is in the 3 lines 
which juggle arr1, arr2 and arr3. Using the @time macro also shows that 
most of the memory allocation and garbage collection is occurring in those 
3 steps.

What, if anything, is the best way to minimize memory allocation time in 
such a situation?


[julia-users] Best way to minimize memory allocation in iterative method?

2014-12-17 Thread Steven G. Johnson
Just write a single loop; all do those updates can be done in place.

Re: [julia-users] Best way to minimize memory allocation in iterative method?

2014-12-17 Thread Stefan Karpinski
Also note that instead of `for i in [1:1000]` you can do `for i in 1:1000`
for the same effect with no allocation.

On Wed, Dec 17, 2014 at 9:35 PM, Steven G. Johnson 
wrote:

> Just write a single loop; all do those updates can be done in place.