Thank you very much Douglas! I learned a lot there. I didn't get it to work
straight away (running julia studio so its using julia 0.2). But these
changes made it work:
function subinds(k, N)
step = iceil(N/k)
rng = 1:step
res = [rng + j * step for j in 0:k-2]
push!(res, ((k - 1) * step + 1):N)
res
end
function edist(a::AbstractMatrix, nblocks::Int, threshold)
N = size(a,2)
si = subinds(nblocks,N)
i = Int[]
j = Int[]
x = eltype(a)[]
for ii in si, jj in si
#r = pairwise(Euclidean(), view(a,:,ii), view(a,:,jj))
r = pairwise(Euclidean(), a[:,si[2]], a[:,si[2]])
ioffset = ii[1] - 1
joffset = jj[1] - 1
for ir in 1:size(r,1), jr in 1:size(r,2)
if (ie = ioffset + ir) != (je = joffset + jr) && (rij = r[ir,jr]) <
threshold
push!(i,ie)
push!(j,je)
push!(x,rij)
end
end
end
sparse(i,j,x)
end