I need a way to make a 2D array of tuples where each tuple is a pair of the indices at that position. I need this without for loops since i'm working with big matrices.
For example, the 3x3 case would be:
array([[(0, 0), (0, 1), (0, 2)],
[(1, 0), (1, 1), (1, 2)],
[(2, 0), (2, 1), (2, 2)]], dtype=object)
I know there is numpy.indices and there are pieces of advice online (there is a post asking about this here), but what they suggests basically gives a 3D array. I need a 2D one so I can pass it to a vectorized function (this one here). I need the function to work with the pair of indices and if I pass it the 3D version mentioned above, each individual index value gets passed to the function, instead of the pair.
But this doesn't happen if my indices come in a pair as a tuple. Tried it with small arrays and it works. Problem is, I can't figure out a way of getting this 2D array of tuples, aside from iterating with for loops. Tried it and it takes too long. But i'm new to programming, so maybe someone knows another way?