Given an array
A = np.array([
[1, 2, 3, 4],
[10, 20, 30, 40]
])
I want to get in the vectorized way an array of k combinations, for example for k=3
array([
[[1, 2, 3],
[1, 2, 4],
[1, 3, 4],
[2, 3, 4]],
[[10, 20, 30],
[10, 20, 40],
[10, 30, 40],
[20, 30, 40]]
])
and for k=2
array([
[[1, 2],
[1, 3],
[1, 4],
[2, 3],
[2, 4],
[3, 4]],
[[10, 20],
[10, 30],
[10, 40],
[20, 30],
[20, 40],
[30, 40]]
])
Any ideas how to achieve that?