I want to perform some operations on a matrix depending on some condition. The matrix is:
- when the element in the first column is less than 0.5: nothing should happen to that specific row;
- when the element in the first column is larger than 0.5: I want to swap the second and the third element and define the fourth as their ratio;
For the above matrix, this operation should return:
I would also like to keep track of the rows where it was necessary to make the swap operation.
what is the most efficient way to perform this operation in Mathematica?