Lets say that i have the following array (note that there is a 1 in the [2,0] position and a 2 in the [3,4] position):
[0, 0, 0, 0, 0]
[0, 0, 0, 0, 0]
[1, 0, 0, 0, 0]
[0, 0, 0, 0, 2]
[0, 0, 0, 0, 0]
and I want to flip it along the diagonal efficiently such that:
[0, 0, 1, 0, 0]
[0, 0, 0, 0, 0]
[0, 0, 0, 0, 0]
[0, 0, 0, 0, 0]
[0, 0, 0, 2, 0]
This does not work with fliplr or rot90 or flipud. Would like efficient answer rather than just an answer since unfortunately this is not being performed on matrices this small.