library(testthat)
library(domstruc)
a_matrix <- matrix(
c(
0.0, 10.0, 2.0, 18.0, 2.0, 5.0, 40.0, 45.0, 20.0, 31.0,
1.0, 0.0, 0.0, 2.0, 0.0, 0.0, 2.0, 4.0, 2.0, 2.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 8.0, 11.0, 0.0, 4.0,
0.0, 0.0, 0.0, 0.0, 0.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, 2.0, 2.0, 3.0,
3.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 9.0, 3.0, 5.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 3.0, 8.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 5.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0
),
nrow = 10, ncol = 10, byrow = TRUE
)
# This result was computed using Simon's original Ruby code, with eps = 0.69
eigen_vector <- c(0.0700609705868091, 0.05423401782968841, 0.04933214387535999,
0.0848923037859565, 0.04521997613672991, 0.04918593365024021,
0.1540856765567929, 0.1546065086178176, 0.12693323999058814,
0.2114492289700173)
# FIXME: It should be possible to have lower tolerance for this test
test_that("output is correct", {
expect_equal(dom_ec(a_matrix, eps = 0.69),
eigen_vector,
tolerance = 1e-3)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.