[Rcpp-commits] r1947 - pkg/Rcpp/inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Aug 6 16:36:05 CEST 2010


Author: edd
Date: 2010-08-06 16:36:05 +0200 (Fri, 06 Aug 2010)
New Revision: 1947

Modified:
   pkg/Rcpp/inst/unitTests/runit.stats.R
Log:
reinstated qt test that had been swallowed by the svn gremlines


Modified: pkg/Rcpp/inst/unitTests/runit.stats.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.stats.R	2010-08-06 14:16:28 UTC (rev 1946)
+++ pkg/Rcpp/inst/unitTests/runit.stats.R	2010-08-06 14:36:05 UTC (rev 1947)
@@ -87,7 +87,7 @@
 				  ')
 
 				  ,
-				  runit_pbeta = list(
+				  "runit_pbeta" = list(
 				  signature(x = "numeric",
 							a = "numeric", b = "numeric"),
 				  '
@@ -237,8 +237,20 @@
 									  _["upper"] = stats::qpois( xx, 0.5, false));
 				  ')
 
-				  ) ## end of list of test function sources
 
+                  ,
+                  "runit_qt" = list(
+                  signature( x = "numeric", df = "integer", lower = "logical", log = "logical" ),
+                  '
+				  NumericVector xx(x);
+                  int d = as<int>(df);
+                  bool lt = as<bool>(lower);
+                  bool lg = as<bool>(log);
+			      return wrap(stats::qt( xx, d, lt, lg));
+				  ')
+
+                  ) ## end of list of test function sources
+
 		signatures <- lapply( f, "[[", 1L )
 		bodies <- lapply( f, "[[", 2L )
 		fx <- cxxfunction( signatures, bodies, plugin = "Rcpp")
@@ -467,6 +479,19 @@
                 msg = " stats.dunif")
 }
 
+test.stats.qt <- function( ) {
+	fx <- .rcpp.stats$runit_qt
+    v <- seq(0.05, 0.95, by=0.05)
+    checkEquals(fx(v, df=5, lower=FALSE, log=FALSE),
+                qt(v, df=5, lower=FALSE, log=FALSE), msg="stats.qt.f.f")
+    checkEquals(fx(v, df=5, lower=TRUE,  log=FALSE),
+                qt(v, df=5, lower=TRUE,  log=FALSE), msg="stats.qt.t.f")
+    checkEquals(fx(-v, df=5, lower=FALSE, log=TRUE),
+                qt(-v, df=5, lower=FALSE, log=TRUE), msg="stats.qt.f.t")
+    checkEquals(fx(-v, df=5, lower=TRUE,  log=TRUE),
+                qt(-v, df=5, lower=TRUE,  log=TRUE), msg="stats.qt.t.t")
+}
+
 # TODO: test.stats.qgamma
 # TODO: test.stats.(dpq)chisq
 



More information about the Rcpp-commits mailing list