[Rcpp-commits] r3077 - in pkg/RcppEigen: inst/unitTests man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 15 13:22:28 CEST 2011


Author: edd
Date: 2011-06-15 13:22:28 +0200 (Wed, 15 Jun 2011)
New Revision: 3077

Modified:
   pkg/RcppEigen/inst/unitTests/runit.fastLm.R
   pkg/RcppEigen/man/fastLm.Rd
Log:
added unit tests for fastLm{Bench,Chol1,Chol2}


Modified: pkg/RcppEigen/inst/unitTests/runit.fastLm.R
===================================================================
--- pkg/RcppEigen/inst/unitTests/runit.fastLm.R	2011-06-15 01:59:47 UTC (rev 3076)
+++ pkg/RcppEigen/inst/unitTests/runit.fastLm.R	2011-06-15 11:22:28 UTC (rev 3077)
@@ -36,6 +36,48 @@
                 msg="fastLm.stderr")
 }
 
+test.fastLm.Bench <- function() {
+    data(trees)
+    flm <- .Call("fastLmBench",
+                 cbind(1, log(trees$Girth)),
+                 log(trees$Volume),
+                 package="RcppEigen")
+    fit <- lm(log(Volume) ~ log(Girth), data=trees)
+
+    checkEquals(as.numeric(flm$coefficients), as.numeric(coef(fit)),
+                msg="fastLm.coef")
+    checkEquals(as.numeric(flm$se), as.numeric(coef(summary(fit))[,2]),
+                msg="fastLm.stderr")
+}
+
+test.fastLm.Chol1 <- function() {
+    data(trees)
+    flm <- .Call("fastLmChol1",
+                 cbind(1, log(trees$Girth)),
+                 log(trees$Volume),
+                 package="RcppEigen")
+    fit <- lm(log(Volume) ~ log(Girth), data=trees)
+
+    checkEquals(as.numeric(flm$coefficients), as.numeric(coef(fit)),
+                msg="fastLm.coef")
+    checkEquals(as.numeric(flm$se), as.numeric(coef(summary(fit))[,2]),
+                msg="fastLm.stderr")
+}
+
+test.fastLm.Chol2 <- function() {
+    data(trees)
+    flm <- .Call("fastLmChol2",
+                 cbind(1, log(trees$Girth)),
+                 log(trees$Volume),
+                 package="RcppEigen")
+    fit <- lm(log(Volume) ~ log(Girth), data=trees)
+
+    checkEquals(as.numeric(flm$coefficients), as.numeric(coef(fit)),
+                msg="fastLm.coef")
+    checkEquals(as.numeric(flm$se), as.numeric(coef(summary(fit))[,2]),
+                msg="fastLm.stderr")
+}
+
 test.fastLm.formula <- function() {
     data(trees)
     flm <- fastLm(log(Volume) ~ log(Girth), data=trees)

Modified: pkg/RcppEigen/man/fastLm.Rd
===================================================================
--- pkg/RcppEigen/man/fastLm.Rd	2011-06-15 01:59:47 UTC (rev 3076)
+++ pkg/RcppEigen/man/fastLm.Rd	2011-06-15 11:22:28 UTC (rev 3077)
@@ -78,8 +78,7 @@
   Romain Francois, Dirk Eddelbuettel and Douglas Bates.
 }
 \examples{
-  require(datasets)
-#  data(trees)  # Unnecessary - the datasets package uses LazyData
+  require(datasets)	# makes trees available via LazyData mechanism
 
   ## bare-bones direct interface
   flm <- fastLmPure( cbind(1, log(trees$Girth)), log(trees$Volume) )



More information about the Rcpp-commits mailing list