test_that("commutation matrix n = 2", { C <- commutation_mat(2) m <- matrix(c(1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1), ncol = 4, byrow = TRUE) expect_equal(C, m) }) test_that("commutation matrix n = 3", { C <- commutation_mat(3) m <- matrix(c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1), ncol = 9, byrow = TRUE) expect_equal(C, m) })