perm_matrix(rperm(1,9))
p1 <- rperm(1,40)
M1 <- perm_matrix(p1)
p2 <- rperm(1,40)
M2 <- perm_matrix(p2)
stopifnot(is.perm_matrix(M1))
stopifnot(all(solve(M1) == perm_matrix(inverse(p1))))
stopifnot(all(M1 %*% M2 == perm_matrix(p1*p2)))
stopifnot(p1 == pm_to_perm(perm_matrix(p1)))
data("megaminx")
image(perm_matrix(permprod(megaminx)),asp=1,axes=FALSE)
Run the code above in your browser using DataLab