Is there a technique to non-recursively generate all pair combinations of numbers in an integer sequence. For example for the sequence 0 ... 4:
(1,0)
(2,0) (2,1)
(3,0) (3,1) (3,2)
(4,0) (4,1) (4,2) (4,3)
To clarify: I would like generate a unique combination(i,j) from an arbitrary "index" k. Here's my motivation. I'm writing a GPU kernel in CUDA where each thread considers all pairs of elements from a list and does a computation on them. But the only information that I have is a thread index. And from this thread index I'd like to generate the pair (i,j)
Table[{i, j}, {i, 4}, {j, 0, i - 1}] // MatrixFormin Mathematica – David G. Stork May 17 '17 at 20:44