All Numpy-experts, this is probably pretty straight forward for you guys. This question should exists, but I did not found something exact solving it. Something similar was Comparing two matrices row-wise by occurrence in NumPy and Numpy compare array to multiple scalars at once but not exactly there.
I need to compute numpy.array_equal for a multidimensional array but I'm pretty sure I don't need to use double for-loops. However, if I would compute using double for-loops, it would look as following:
M = numpy.array(
[
[
[1,2,3],
[1,3,4]
],
[
[3,4,5],
[1,2,3]
],
[
[1,2,3],
[1,3,4]
]
])
result = np.zeros((M.shape[0], M.shape[0]))
for i in range(M.shape[0]):
for j in range(M.shape[0]):
result[i,j] = numpy.array_equal(M[i], M[j])
I should end up with a M.shape[0]^2 large truth table, where at least the diagonal is true.