Yes, that was an excellent suggestion! I am sorry I did not realize that
was you meant in your first post.
Now my two versions allocate exactly the same amount of memory. A bit
cumbersome to have to do the unrolling yourself but not so bad.
Again, thanks.
On Monday, February 2, 2015 at 11:59:58 AM UTC+1, Yuuki Soho wrote:
>
> I think you can just add a loop over the dimensions to do the copy and
> avoid the allocations:
>
> function slow(points::Array{Float64,2})
> n_dim = size(points,1)
> n_points::Int = size(points,2)
> point_2 = zeros(n_dim)
> cum = 0.0
> for i in 1:n_points
> for j in (i+1):n_points
> for k=1:n_dim
> point_2[k] = points[k, j]
> end
> cum += myDist(point_2)
> end
> end
> return cum
> end
>