tests/testthat/test_cppalg.R

context("Custom C++ linear algebra routines")

test_that("Kronecker products (I x A)B with I=diag(N)", {
  set.seed(2018)
  
  dims = c(N=3, m=4, n=5, p=2)

  A = matrix(rnorm(dims['m'] * dims['n']), ncol=dims['n'])
  B = matrix(rnorm( dims['N'] * dims['n'] * dims['p']), ncol=dims['p'])
      
  expect_equal(
    kronecker(diag(dims['N']), A) %*% B,
    .Call(`_telefit_r_dgeikmm`, dims['N'], A, B),
    tolerance = 1e-3
  )
})

Try the telefit package in your browser

Any scripts or data that you put into this service are public.

telefit documentation built on Feb. 4, 2020, 9:08 a.m.