On Tue, Mar 29, 2016 at 10:00 AM, 博陈 <[email protected]> wrote:
> Actually, I know the arrays allocated in every loop, my problem is that I
> don't know the strategy to pre-allocate such arrays.
> In short, this is the pre-allocating problem of arrays like array a
> described below:
>
>
> n = 1024; nt = 1000;
> dt = 0.1
> a = Array(Float64, n, n)
> for i in 1:nt
>     t = i*dt
>     for j in eachindex(a)
>          a[j] = exp(pi * t) * a0
>     end
>     .......  scripts to use a[j] for a single i........
> end
>
> In my problem, such arrays are hard to pre-allocate, do you have any
> suggestions?

The code above shouldn't have any allocation in the loop?
Can you point out the part of the code that allocates a lot in loops?

>
> 在 2016年3月29日星期二 UTC+8下午9:27:27,Stefan Karpinski写道:
>>
>> Have you tried:
>>
>> (a) calling @code_typewarn on your function
>> (b) using the built-in profiler?
>>
>>
>

Reply via email to