Task: Consider the following simple python code to interchange rows i
and j
of a numpy array A
.
def swaprow(i, j, A):
tmp = A[i, :]
A[i, :] = A[j, :]
A[j, :] = tmp
If there are problems with this (correctness? efficiency? elegance? brevity?), explain them, and produce a better function. (Please do check for correctness before you check anything else.)