You haven't passed in r as argument to function.
Try nested_loop!(Y,X,d,r,n,m,f)
On Tuesday, October 4, 2016 at 8:05:41 PM UTC+11, Niccolo' Antonello wrote:
> Hi all,
>
> I'm trying to make this code to go faster:
>
> n,m = 100,25
> f = 100
> d = randn(3,n)
> r = randn(3,m)
>
> Y = zeros(Complex{Float64},f,m)
> X = ones(f,n)+im*ones(f,n)
>
> function
> nested_loop!(Y::Array{Complex{Float64}},X::Array{Complex{Float64}},
> d::Array{Float64,2},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
>
> @time nested_loop!(Y,X,d,n,m,f)
> Profile.clear_malloc_data()
> Y = zeros(Complex{Float64},f,m)
> @time nested_loop!(Y,X,d,n,m,f)
>
> I see that it is allocating a lot of memory.
> So I also tried to put k and A on Arrays and preallocate that, but this
> didn't remove the allocations.
> Could you please tell me what could be possibly done to make this code
> faster?
> I thank you!
>
>