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. > ## > ## i n t e r p 2 . R Test suite > ## > > > interp2 <- pracma::interp2 > > x <- c(0.0, 0.2, 0.4, 0.6, 0.8, 1.0) > y <- c(1, 2, 3) > > Z <- matrix(c( + 1, 1.04, 1.16, 1.36, 1.64, 2, + 4, 4.04, 4.16, 4.36, 4.64, 5, + 9, 9.04, 9.16, 9.36, 9.64, 10), nrow = 3, byrow = TRUE) > > all.equal(interp2(x, y, Z, 0.55, 2.55, method = "constant"), 4.16) [1] TRUE > all.equal(interp2(x, y, Z, 0.55, 2.55, method = "nearest"), 9.36) [1] TRUE > > all.equal(interp2(x, y, Z, 0.5, 2.5, method = "linear"), 6.76) [1] TRUE > all.equal(interp2(x, y, Z, 0.55, 2.5, method = "linear"), 6.81) [1] TRUE > all.equal(interp2(x, y, Z, 0.5, 2.55, method = "linear"), 7.01) [1] TRUE > all.equal(interp2(x, y, Z, 0.55, 2.55, method = "linear"), 7.06) [1] TRUE > > all.equal(interp2(x, y, Z, 0.0, 1.5, method = "linear"), 2.5) [1] TRUE > all.equal(interp2(x, y, Z, 0.1, 1.0, method = "linear"), 1.02) [1] TRUE > all.equal(interp2(x, y, Z, 1.0, 2.5, method = "linear"), 7.5) [1] TRUE > all.equal(interp2(x, y, Z, 0.9, 3.0, method = "linear"), 9.82) [1] TRUE > > proc.time() user system elapsed 0.09 0.07 0.15