rowColIndexing function

Convert between row- and column-style indexing of matrices