R Under development (unstable) (2023-11-08 r85496 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ### > ### polyfit.R +++ Test suite +++ > ### > > > test.polyfit <- function(input, expected) { + output <- do.call(getFromNamespace("polyfit", "pracma"), input) + identical(all.equal(output, + expected, + tolerance=1e-7), + TRUE + ) + } > > polyfit.expected.n1 <- c(1, 0) > polyfit.expected.n23 <- c(0, 1, 1, 1) > polyfit.expected.n4 <- c(-1, 0, 7, 0, 0) / 6 > polyfit.expected.mat <- c(0, 1, -14, 65, -112, 60) / 12 > > test.polyfit(list(x=c(1,2,3), y=c(1,2,3)), polyfit.expected.n1) [1] TRUE > test.polyfit(list(x=c(-2,-1,0,1,2), y=c(3,1,1,3,7), n=3), polyfit.expected.n23) [1] TRUE > test.polyfit(list(x=c(-2,-1,0,1,2), y=c(2,1,0,1,2), n=4), polyfit.expected.n4) [1] TRUE > test.polyfit(list(x=matrix(1:6, nrow=2, ncol=3, byrow=TRUE), + y=matrix(c(0,0,1,1,0,0), nrow=2, ncol=3, byrow=TRUE), + n=5), polyfit.expected.mat) [1] TRUE > > > proc.time() user system elapsed 0.12 0.03 0.15