I want to produce a i,j
vector where every i
is combined with every j
, a simple version of the code would be this:
n = 5
m = 3
for i in range(n):
for j in range(m):
print str(i) + ',' + str(j)
Resulting:
0,0
0,1
0,2
1,0
1,1
1,2
2,0
2,1
2,2
3,0
3,1
3,2
4,0
4,1
4,2
However if n
is 8e6
and m
is 200
(like in my case) this loop nesting becomes very slow.
- Is there a numpy procedure to produce this combination in a C-like speed?
- Is there any other way?
Thanks in advance.