Create a gist now

Instantly share code, notes, and snippets.

@chyanju /dSplitFast.jl Secret
Created Jan 18, 2016

What would you like to do?
Distributed Splitting Function, Splitting M into N pieces
"Distributed Splitting Function, Splitting M into N pieces"
function dSplitFast(M,N)
a = [floor(Int64,M/N)+(i<=M%N) for i=1:N]
b = unshift!([sum(a[1:j]) for j=1:N],0)
c = [p[1]+1:p[2] for p in[b[k:k+1] for k=1:N]]
return c
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment