In dealing with non-square matrices, I find that I am unable to swap 2 columns or 2 rows

asked 2025-12-04 23:20:06 +0100

rj gravatar image

I tried using the built-in swap function and also tried to do this manually by saving the value of a given column, then copying the other column to it, and copying back the saved value into the other column. Both worked fine for square matrices, but gave me errors for any non-square matrix. I could not understand the reason, why it only works for square matrices.

Help on this would be really appreciated. Roy Joshua. E-mail: joshua.1@osu.edu

edit retag flag offensive close merge delete

Comments

Can you provide more details? Please tell us exactly what commands you used and what error messages you got. (m.swap_rows(0,1) works for me, and the same with swap_columns, both for non-square matrices.) Note that the rows and columns are numbered starting with 0, not 1.

John Palmieri gravatar imageJohn Palmieri ( 2025-12-07 02:42:47 +0100 )edit