void () { Matrix matrix = Matrix.create(3, /*row:*/ 11, 12, /*row:*/ 21, 22, /*row:*/ 31, 32); Matrix result = matrix.transpose(); assertEquals(matrix.getColumns(), result.getRows()); assertEquals(matrix.getColumn(0), result.getRow(0)); assertEquals(matrix.getColumn(1), result.getRow(1)); assertEquals(matrix.getRows(), result.getColumns()); assertEquals(matrix.getRow(0), result.getColumn(0)); assertEquals(matrix.getRow(1), result.getColumn(1)); assertEquals(matrix.getRow(2), result.getColumn(2)); // see http://ru.onlinemschool.com/math/library/matrix/transpose/ assertEquals(Matrix.create(2, 4, 9, 2, 0), Matrix.create(2, 4, 2, 9, 0).transpose()); assertEquals(Matrix.create(2, 2, -3, 4, 1, 0, -1), Matrix.create(3, 2, 1, -3, 0, 4, -1).transpose()); assertEquals(Matrix.create(3, 2, 1, -3, 0, 4, -1), Matrix.create(2, 2, -3, 4, 1, 0, -1).transpose()); }