[Rcpp-commits] r3100 - in pkg/RcppEigen: man tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 23 16:54:58 CEST 2011


Author: dmbates
Date: 2011-06-23 16:54:58 +0200 (Thu, 23 Jun 2011)
New Revision: 3100

Added:
   pkg/RcppEigen/tests/simple.R
Modified:
   pkg/RcppEigen/man/fastLm.Rd
Log:
Add examples and test cases for simple crossprod and tcrossprod functions


Modified: pkg/RcppEigen/man/fastLm.Rd
===================================================================
--- pkg/RcppEigen/man/fastLm.Rd	2011-06-23 14:53:50 UTC (rev 3099)
+++ pkg/RcppEigen/man/fastLm.Rd	2011-06-23 14:54:58 UTC (rev 3100)
@@ -83,16 +83,22 @@
 }
 \examples{
   data(trees, package="datasets")
+  data(trees, package="datasets")
+  mm <- cbind(1, log(trees$Girth))   # model matrix
+  y  <- log(trees$Volume)            # response
+  crossprod(mm)
+  .Call("crossprod1", mm, PACKAGE="RcppEigen")  # doesn't use wrap
+  .Call("crossprod", mm, PACKAGE="RcppEigen")   # uses wrap
 
   ## bare-bones direct interface
-  flm <- fastLmPure( cbind(1, log(trees$Girth)), log(trees$Volume) )
+  flm <- fastLmPure(mm, y)
   print(flm)
 
   ## standard R interface for formula or data returning object of class fastLm
   flmmod <- fastLm( log(Volume) ~ log(Girth), data=trees)
   summary(flmmod)
 
-  ## case where fastLm breaks down
+  ## case where non-rank-revealing methods break down
   dd <- data.frame(f1 = gl(4, 6, labels = LETTERS[1:4]),
                    f2 = gl(3, 2, labels = letters[1:3]))[-(7:8), ]
   xtabs(~ f2 + f1, dd)     # one missing cell
@@ -104,7 +110,3 @@
   try(summary(fastLm(y ~ f1 * f2, dd))) # also detects rank deficiency
 }
 \keyword{regression}
-
-
-
-

Added: pkg/RcppEigen/tests/simple.R
===================================================================
--- pkg/RcppEigen/tests/simple.R	                        (rev 0)
+++ pkg/RcppEigen/tests/simple.R	2011-06-23 14:54:58 UTC (rev 3100)
@@ -0,0 +1,9 @@
+require("RcppEigen", character=TRUE, quietly=TRUE)
+data(Formaldehyde, package="datasets")
+(mm <- cbind(1, Formaldehyde$carb))
+crossprod(mm)
+.Call("crossprod", mm, PACKAGE="RcppEigen")
+.Call("crossprod1", mm, PACKAGE="RcppEigen")
+tcrossprod(mm)
+.Call("tcrossprod", mm, PACKAGE="RcppEigen")
+.Call("tcrossprod1", mm, PACKAGE="RcppEigen")



More information about the Rcpp-commits mailing list