Thank you so much for all your help! ;)

On Tuesday, October 4, 2016 at 4:12:43 PM UTC+2, Greg Plowman wrote:
>
> Not sure what the best way is, especially on Julia 0.5 where maybe some 
> sort of view.
>
> But you could always use an Array of Arrays if you don't really need a 
> true multi-dimensional array elsewhere:
>
> d = randn(3,n)
> d2 = [ d[:,i]::Vector{Float64} for i=1:n ]
> r = randn(3,m)
> r2 = [ r[:,i]::Vector{Float64} for i=1:m ]
>
> function nested_loop!(Y::Array{Complex{Float64}},X::Array{Complex{Float64
> }},
>                       d::Vector{Vector{Float64}},r::Vector{Vector{Float64
> }},n::Int64,m::Int64,f::Int64)
>         for i_1 = 1:f
>                 for i_3 = 1:n
>                         k = 2*π*i_1*d[i_3]
>                         for i_2 = 1:m
>                                 A = exp(im*dot(k,r[i_2]))
>                                 Y[i_1,i_2] += X[i_1,i_3] * A
>                         end
>                 end
>         end
> end
>
>  nested_loop!(Y,X,d2,r2,n,m,f)
>
> On V0.4 this has less allocations and runs slightly faster (maybe 2-3x)
>
>
> On Tuesday, October 4, 2016 at 11:45:53 PM UTC+11, Niccolo' Antonello 
> wrote:
>
>> what is the best way to slice an array without allocating? I thank you!
>>
>> On Tuesday, October 4, 2016 at 1:20:29 PM UTC+2, Kristoffer Carlsson 
>> wrote:
>>>
>>> The slicing of "r" will also make a new array and thus allocate. 
>>
>>

Reply via email to