AtheMathmo / rulinalg

A linear algebra library written in Rust

Home Page:https://crates.io/crates/rulinalg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PermutationMatrix swap_rows() may be misleading

Andlon opened this issue · comments

The docs for swap_rows() currently say:

Swaps rows i and j in the permutation matrix.

If one thinks of a permutation matrix as a full matrix of 1's and 0's, then this statement is not correct. What it does is swap the rows of the permuted matrix when the permutation matrix is applied from the left. This actually corresponds to swapping the columns in the matrix representation of the permutation matrix, and so can be interpreted to mean the exact opposite of what it does.

At the very least, the documentation should be updated to make it clear exactly what the function does. However, the name swap_rows() itself can very easily be misinterpreted, as it does not work quite the same way as e.g. BaseMatrix::swap_rows(). Therefore I propose the following:

Remove swap_rows altogether in favor of simply swap, whose name is somewhat intentionally ambiguous. This way users are more inclined to look up in the documentation what it actually does. It is of course paramount that the documentation is very clear on this point. Since I believe PermutationMatrix has not yet made it into any release yet, I think this can be safely done without worrying about backwards compatibility.

Thoughts?