https://github.com/cran/pracma
Raw File
Tip revision: 1305bf51cc38adca02d0c8a834c61a4c7e038309 authored by Hans W. Borchers on 08 February 2015, 00:00:00 UTC
version 1.8.3
Tip revision: 1305bf5
roots.R
###
### roots.R  +++ Test suite +++
###


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

roots.expected.empty <- matrix(0, nrow=0, ncol=0)
roots.expected.singl <- matrix(0, nrow=0, ncol=0)
roots.expected.bspl1 <-  c(0, 2, -2, 1, -1)  # Matlab: c(0, -2, -1, 1, 2)
                         c(0, 2, -2, 1, -1)
roots.expected.bspl2 <-  c(0.5, -0.2)
roots.expected.bspl3 <- -c(0, 0, -1, 1)

test.roots(list(p=c()), roots.expected.empty)
test.roots(list(p=c(0)), roots.expected.singl)
#test.roots(list(p=c(1,0,-5,0,4,0)), roots.expected.bspl1)  # zapsmall
test.roots(list(p=c(1,-0.3,-0.1)), roots.expected.bspl2)
test.roots(list(p=c(1,0,-1,0,0)), roots.expected.bspl3)
back to top