https://github.com/cran/pracma
Raw File
Tip revision: d50cda4811eb3cdb8d2ce9e01ddb5e07d4a8c24f authored by HwB on 11 September 2013, 00:00:00 UTC
version 1.5.5
Tip revision: d50cda4
polyval.R
###
### polyval.R  +++ Test suite +++
###


test.polyval <- function(input, expected) {
   output <- do.call(getFromNamespace("polyval", "pracma"), input)
   identical(output, expected)
}

polyval.expected.empty1 <- c()
polyval.expected.empty2 <- c(0, 0)
polyval.expected.vec <- c(3, 1, 1, 3, 7)
polyval.expected.mat <- matrix(c(1, 4, 9, 16), nrow=2, ncol=2)

test.polyval(list(p=c(1,1), x=c()), polyval.expected.empty1)
test.polyval(list(p=c(), x=c(1,1)), polyval.expected.empty2)
test.polyval(list(p=c(1,1,1), x=-2:2), polyval.expected.vec)
test.polyval(list(p=c(1,0,0), x=matrix(1:4, 2, 2)), polyval.expected.mat)
back to top