Skip to content

Instantly share code, notes, and snippets.

@getzdan
Created May 9, 2017 17:07
Show Gist options
  • Save getzdan/aa287ce691673d40c9f953dfc23ad038 to your computer and use it in GitHub Desktop.
Save getzdan/aa287ce691673d40c9f953dfc23ad038 to your computer and use it in GitHub Desktop.
a quick method for generating grid of matrix subscripts
function f6(xs, ys)
lx, ly = length(xs), length(ys)
lxly = lx*ly
res = Array{Base.promote_eltype(xs, ys), 2}(lxly, 2)
ind = 1
while ind<=lxly
@inbounds for x in xs
res[ind] = x
ind += 1
end
end
for y in ys
@inbounds for i=1:lx
res[ind] = y
ind += 1
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment