tests/testthat/test-commutation_mat.R

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)
})
alexanderlange53/BEKKs documentation built on Nov. 27, 2024, 7:37 p.m.